Giter Club home page Giter Club logo

cldr_territories's Introduction

Cldr for Territories

main

Introduction and Getting Started

ex_cldr_territories is an add-on library for ex_cldr that provides localization for territories.

Examples

iex> MyCldr.Territory.from_territory_code(:GB)
{:ok, "United Kingdom"}

iex> MyCldr.Territory.translate_territory("Reino Unido", "pt", "en")
{:ok, "UK"}

iex> MyCldr.Territory.contains?(:EU, :GB)
false

iex> MyCldr.Territory.contains?(:EU, :DE)
true

iex> MyCldr.Territory.parent(:GB)
{:ok, [:"154", :UN]}

iex> MyCldr.Territory.children(:EU)
{:ok,
 [:AT, :BE, :CY, :CZ, :DE, :DK, :EE, :ES, :FI, :FR, :GR, :HR, :HU, :IE,
  :IT, :LT, :LU, :LV, :MT, :NL, :PL, :PT, :SE, :SI, :SK, :BG, :RO]}

iex> MyCldr.Territory.info(:GB)
{:ok,
 %{
   currency: [GBP: %{from: ~D[1694-07-27]}],
   gdp: 2925000000000,
   language_population: %{
     "bn" => %{population_percent: 0.67},
     "cy" => %{official_status: "official_regional", population_percent: 0.77},
     "de" => %{population_percent: 6},
     "el" => %{population_percent: 0.33},
     "en" => %{official_status: "official", population_percent: 99},
     "fr" => %{population_percent: 19},
     "ga" => %{official_status: "official_regional", population_percent: 0.026},
     "gd" => %{
       official_status: "official_regional",
       population_percent: 0.099,
       writing_percent: 5
     },
     "it" => %{population_percent: 0.33},
     "ks" => %{population_percent: 0.19},
     "kw" => %{population_percent: 0.003},
     "ml" => %{population_percent: 0.035},
     "pa" => %{population_percent: 0.79},
     "sco" => %{population_percent: 2.7, writing_percent: 5},
     "syl" => %{population_percent: 0.51},
     "yi" => %{population_percent: 0.049},
     "zh-Hant" => %{population_percent: 0.54}
   },
   literacy_percent: 99,
   measurement_system: %{
     default: :uksystem,
     paper_size: :a4,
     temperature: :uksystem
   },
   population: 65761100
 }}

iex> MyCldr.Territory.to_unicode_flag(:US)
{:ok, "๐Ÿ‡บ๐Ÿ‡ธ"}

iex> MyCldr.Territory.to_currency_code(:US)
{:ok, :USD}

For help in iex:

iex> h MyCldr.Territory.from_territory_code

Documentation

hex documentation for ex_cldr

hex documentation for ex_cldr_territories

Installation

Note that :ex_cldr_territories requires Elixir 1.12 or later.

Add ex_cldr_territories as a dependency to your mix project:

    defp deps do
      [
        {:ex_cldr_territories, "~> 2.9.0"}
      ]
    end

then retrieve ex_cldr_territories from hex:

mix deps.get
mix deps.compile

In order to use this library, a backend module for ex_cldr must be defined. This is described in full in the ex_cldr readme. To get started, define a backend module in your project as follows:

defmodule MyApp.Cldr do
  use Cldr,
    locales: [:en],
    providers: [Cldr.Territory]
end

LICENSE

(The MIT License)

Copyright (c) 2017 Benjamin Schultzer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

cldr_territories's People

Contributors

alappe avatar jeroenvisser101 avatar jfpedroza avatar kipcole9 avatar leandrocp avatar linusdm avatar mskv avatar richard-ash avatar schultzer avatar tomciopp avatar zorbash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cldr_territories's Issues

Compiler warning on app cldr module since 2.8.0

On 2.8.0 a compiler warning is generated when compiling the app Cldr module:

warning: MyApp.Cldr.List.wrap/1 is undefined or private

This wouldn't be a problem but is generated when compiling the app, not ex_cldr_territories and if you have a strict no warnings policy on your code (e.g. mix compile --warnings-as-errors) like we do it fails in CI.

CLDR version 33 data is release

Unicode Consortium released CLDR version 33 today and I have updated ex_cldr, ex_cldr_numbers, ex_cldr_lists, ex_cldr_dates_times, ex_unitsandex_money` to use the new data.

There aren't any new locales but I can see there are changes and additions to territory information. I found this upgrade to have no issues in any of my code so hopefully the same for you.

Just bump your version requirements to {ex_cldr, "~> 1.5.0} and hopefully you're good to go.

No default :ex_cldr backend is configured when calling `known_territories`

Hi! Thanks for the amazing work with this lib... I was reviewing this old code today and I noticed that when calling known_territories I get an exception: No default :ex_cldr backend is configured. The same doesn't happen when calling known_languages... IIRC configuring the backend in config.exs is discouraged and I don't remember it being necessary ๐Ÿค”.

defmodule MyBackend.Cldr do
  use Cldr,
    locales: ["en", "pt"],
    default_locale: "en",
    providers: [Cldr.Language, Cldr.Territory]

  def language_options() do
    languages = __MODULE__.Language.known_languages()

    languages
    |> Enum.map(fn {key, %{standard: name}} -> {name, key} end)
    |> Enum.sort()
  end

  def valid_languages() do
    languages = __MODULE__.Language.known_languages()
    Enum.map(languages, fn {key, _} -> to_string(key) end)
  end

  def location_options() do
    territories = __MODULE__.Territory.known_territories()

    territories
    |> Enum.map(fn {key, %{standard: name}} -> {name, key} end)
    |> Enum.sort()
  end

  def valid_locations() do
    territories = __MODULE__.Territory.known_territories()
    Enum.map(territories, fn {key, _} -> to_string(key) end)
  end
end

Here's the mix file:

 {:ex_cldr, "~> 2.38"},
 {:ex_cldr_languages, "~> 0.3.3"},
 {:ex_cldr_territories, "~> 2.7"}

ex_cldr_territories 2.2.0 fails dialyzer checks

Upgrading from 2.1.0, which passed Dialyzer fine. 2.2.0 produces this:

lib/myapp/cldr.ex:1: Invalid type specification for function 'Elixir.MyApp.Cldr.Territory':'from_subdivision_code!'/2. The success typing is (binary() | #{'__struct__':='Elixir.Cldr.LanguageTag', 'backend':=atom(), 'canonical_locale_name':=binary(), 'cldr_locale_name':='nil' | binary(), 'extensions':=map(), 'gettext_locale_name':='nil' | binary(), 'language':=binary(), 'language_subtags':=[binary()], 'language_variant':='nil' | binary(), 'locale':=map(), 'private_use':=[binary()], 'rbnf_locale_name':='nil' | binary(), 'requested_locale_name':=binary(), 'script':='nil' | binary(), 'territory':=atom(), 'transform':=map()},[{'locale',binary() | #{'__struct__':='Elixir.Cldr.LanguageTag', 'cldr_locale_name':='nil' | binary() | map(), _=>_}},...]) -> <<_:16,_:_*8>>
done in 0m33.77s
lib/myapp/cldr.ex:1: Invalid type specification for function 'Elixir.MyApp.Cldr.Territory':'translate_subdivision!'/3. The success typing is (binary(),#{'__struct__':='Elixir.Cldr.LanguageTag', 'cldr_locale_name':=binary() | #{'__struct__':='Elixir.Cldr.LanguageTag', 'backend':=atom(), 'canonical_locale_name':=binary(), 'cldr_locale_name':='nil' | binary(), 'extensions':=map(), 'gettext_locale_name':='nil' | binary(), 'language':=binary(), 'language_subtags':=[binary()], 'language_variant':='nil' | binary(), 'locale':=map(), 'private_use':=[binary()], 'rbnf_locale_name':='nil' | binary(), 'requested_locale_name':=binary(), 'script':='nil' | binary(), 'territory':=atom(), 'transform':=map()}, _=>_},binary() | #{'__struct__':='Elixir.Cldr.LanguageTag', 'backend':=atom(), 'canonical_locale_name':=binary(), 'cldr_locale_name':='nil' | binary(), 'extensions':=map(), 'gettext_locale_name':='nil' | binary(), 'language':=binary(), 'language_subtags':=[binary()], 'language_variant':='nil' | binary(), 'locale':=map(), 'private_use':=[binary()], 'rbnf_locale_name':='nil' | binary(), 'requested_locale_name':=binary(), 'script':='nil' | binary(), 'territory':=atom(), 'transform':=map()}) -> {'error',{'Elixir.Cldr.UnknownLocaleError',<<_:64,_:_*8>>} | {'Elixir.Cldr.UnknownSubdivisionError',<<_:64,_:_*8>>}}
lib/cldr/backend.ex:277: The call 'Elixir.MyApp.Cldr.Territory':from_subdivision_code(_@4::atom() | binary(),_@5::'nil' | binary()) breaks the contract ('Elixir.Cldr.Territory':binary_tag(),[{'locale','Elixir.Cldr.Territory':binary_tag()}]) -> {'ok',binary()} | {'error','Elixir.Cldr.Territory':error()}
lib/cldr/backend.ex:523: The pattern {'ok', _@6} can never match the type {'error',{'Elixir.Cldr.UnknownLocaleError',<<_:64,_:_*8>>} | {'Elixir.Cldr.UnknownSubdivisionError',<<_:64,_:_*8>>}}
lib/cldr/backend.ex:896: The call 'Elixir.MyApp.Cldr.Territory':from_subdivision_code(_@5::<<_:16,_:_*8>>,_@3::<<_:16,_:_*16>>) breaks the contract ('Elixir.Cldr.Territory':binary_tag(),[{'locale','Elixir.Cldr.Territory':binary_tag()}]) -> {'ok',binary()} | {'error','Elixir.Cldr.Territory':error()}
done (warnings were emitted)
Halting VM with exit status 2

Enhancement idea: Support for alpha-3 and M49 codes

Many APIs are using 3-letter codes instead of 2-letter equivalents. Also, all teritories have their numeric codes (not only teritories like Europe etc).

For starters we can provide these codes in the info function but I think it's possible to support all these three code formats everywhere.

1.0 release

This is whats need to be done for the 1.0 release.

  • update mix.exs to depend on {:ex_cldr "~> 1.0"}
  • write release notes
  • add CHANGELOG.md

missing en subdivisions

๐Ÿ‘‹

These subdivisions seem to be missing from en locale:

DZ-49
DZ-50
DZ-51
DZ-52
DZ-53
DZ-54
DZ-55
DZ-56
DZ-57
DZ-58
ET-SW
FI-01
FR-BL
FR-CP
FR-MF
FR-NC
FR-PF
FR-PM
FR-TF
FR-WF
GB-NNH
GB-WNH
ID-PD
ID-PE
ID-PS
ID-PT
IN-CG
IN-OD
IN-TS
IN-UK
IS-HUG
IS-SKR
KP-15
KZ-10
KZ-11
KZ-15
KZ-19
KZ-23
KZ-27
KZ-31
KZ-33
KZ-35
KZ-39
KZ-43
KZ-47
KZ-55
KZ-59
KZ-61
KZ-62
KZ-63
KZ-71
KZ-75
KZ-79
ME-25
NL-AW
NL-CW
NL-SX
PH-MGN
PH-MGS
SH-TA
US-AS
US-GU
US-MP
US-PR
US-UM
US-VI

Cldr.Territory.from_subdivision_code/2 should resolve aliases

Copied from elixir-cldr/cldr#209

Summary

When resolving the names associated with a subdivision, such as uspr, no name is returned even though it's a valid subdivision code. This is because uspr is an alias to the territory PR (Puerto Rico). It can also be the case that a subdivision is deprecated and therefore it is also aliased.

CLDR provides a database of aliases that is returned by Cldr.Config.aliases/0 which is a map, including the key :subdivision under which the subdivision aliases are stored.

This issue is to request that Cldr.Territory.from_subdivision_code/2 resolve aliases to either base subdivision or, in situations like the above, territory code.

Suggested approach

  1. Add Cldr.Territory.subdivision_aliases/0 which encapsulates the alias information. This information can be obtained at compile time from Cldr.Config.aliases[:subdivision]
  2. Which resolving a subdivision, recursively resolve the subdivision name through the aliases until no more aliases are found.
  3. If the result is a territory code (an uncased atom) then use that territory code. If the result is a string its a subdivision code, use the subdivision code.
  4. Resolve the territory name - subdivision or territory

Subdivision alias data

Today, Cldr.Config.aliases/0 will return subdivision aliases as strings no matter whether they are territories or subdivisions. By definition, territories should be of the type t:Cldr.Locale.territory_code/0 which is an uncased atom. The following code is suggested to overcome this bug (which will be fixed in the next ex_cldr release:

  @subdivision_aliases Cldr.Config.aliases()
    |> Map.fetch!(:subdivision)
    |> Enum.map(fn 
      {k, v} when is_binary(v) ->
        if String.length(v) == 2, do: {k, String.to_atom(v)}, else: {k, v}
      other -> other
    end)
    |> Map.new()
    
  def subdivision_aliases do
    @subdivision_aliases
  end

Thoughts on cldr_territories

@Schultzer Really appreciate your collaboration on this.

What CLDR provides

There are four sources of data that CLDR provides:

What cldr_territories could provide

  1. Localised territory names - which is where you have started. These names are only available for "country" level names (not subdivisions)
  2. Territory includes - which would return the territories within a given territory. The repo includes only country level data. CLDR also includes subdivisions - some work would be required by me to include it.
  3. Territory parent - the parent of the given territory - same as for inclusion
  4. Territory info - returns the population, GDP, language usage etc from territory info - this isn't locale specific

API thoughts

Just some ideas for discussion (based upon the Twitter ruby cldr implementation to which we have both referred):

# Return a map of all known territories in the given locale
# @spec Cldr.Territory,known_territories(Cldr.Locale.name) :: %{territory_code: String.t, ...}
iex> Cldr.Territory.known_territories(locale \\ Cldr.get_current_locale)
%{"001": "World", TL: "East Timor", TM: "Turkmenistan", ...}

# Return the territory name for a given territory code
# @spec Cldr.Territory.from_territory_code(territory_code, options] :: String.t
iex> Cldr.Territory.from_territory_code(:GB, locale: "en")
"UK"

# Get the territories parents.  Note that a territory
# may have more than one parent
# @spec Cldr.Territory.parent(locale_name, options) :: [territory_code, ...]
iex> Cldr.Territory,parent(:GB)
[:EU, :"154"]

# Get territory subdivision
# @spec Cldr.Territory.contains(locale_name, options) :: [territory_code, ...]
iex> Cldr.Territory.contains(:EU)
[:AT, :BE, :CY, :CZ, :DE, :DK, ...]

# and for a subdivision below country.  A few challenges here:
# 1. Work required (by me) to have the data provided in the repo and in ex_cldr
# 2. Localised data (beyond english) is very sparse
# 3. The data is not hierarchical - for example it mixes (for GB) county and city names
# Personally I think this may be better deferred until a later release
# @spec Cldr.Territory.contains(territory_code) :: [subdivision_code :: String.t, ...]
iex> Cldr.Territory.contains(:GB)
["gbeaw", "gbeng", "gbgbn", "gbnir", "gbsct", "gbukm", ...]

# Get the territory info
# @spec Cldr.Territory.info(territory_code) :: Map.t
iex> Cldr.Territory.info(:GB)
%{gdp: 2788000000000, literacy_percent: 99, population: 64430400, ...}

Thoughts?

Enhancement idea: flags for territories

@Schultzer Had a spare moment on a plane and thought maybe adding unicode flags to cldr_territories might be worth while (I know I have a couple of use cases). I created a simple module below, happy to do a PR if that suits you.

defmodule Cldr.Territory do
  @flags File.read!("priv/flags.csv")
  Enum.each String.split(@flags, "\n"), fn line ->
    case String.split(line, ",") do
      [flag, territory] ->
        def flag_for(unquote(String.to_atom(territory))), do: {:ok, unquote(String.trim(flag))}
      [_] ->
        nil
    end
  end

  def flag_for(territory) do
    {:error, {Cldr.UnknownTerritoryError, "Unknown territory #{inspect territory}"}}
  end

  def flag_for!(territory) do
    case flag_for(territory) do
      {:ok, flag} -> flag
      {:error, {exception, reason}} -> raise exception, reason
    end
  end
end

The flags file is nothing more than:

๐Ÿ‡ฆ๐Ÿ‡จ,AC
๐Ÿ‡ฆ๐Ÿ‡ฉ,AD
๐Ÿ‡ฆ๐Ÿ‡ช,AE
๐Ÿ‡ฆ๐Ÿ‡ซ,AF
๐Ÿ‡ฆ๐Ÿ‡ฌ,AG
๐Ÿ‡ฆ๐Ÿ‡ฎ,AI
๐Ÿ‡ฆ๐Ÿ‡ฑ,AL
๐Ÿ‡ฆ๐Ÿ‡ฒ,AM
๐Ÿ‡ฆ๐Ÿ‡ด,AO
๐Ÿ‡ฆ๐Ÿ‡ถ,AQ
๐Ÿ‡ฆ๐Ÿ‡ท,AR
๐Ÿ‡ฆ๐Ÿ‡ธ,AS
๐Ÿ‡ฆ๐Ÿ‡น,AT
๐Ÿ‡ฆ๐Ÿ‡บ,AU
๐Ÿ‡ฆ๐Ÿ‡ผ,AW
๐Ÿ‡ฆ๐Ÿ‡ฝ,AX
๐Ÿ‡ฆ๐Ÿ‡ฟ,AZ
๐Ÿ‡ง๐Ÿ‡ฆ,BA
๐Ÿ‡ง๐Ÿ‡ง,BB
๐Ÿ‡ง๐Ÿ‡ฉ,BD
๐Ÿ‡ง๐Ÿ‡ช,BE
๐Ÿ‡ง๐Ÿ‡ซ,BF
๐Ÿ‡ง๐Ÿ‡ฌ,BG
๐Ÿ‡ง๐Ÿ‡ญ,BH
๐Ÿ‡ง๐Ÿ‡ฎ,BI
๐Ÿ‡ง๐Ÿ‡ฏ,BJ
๐Ÿ‡ง๐Ÿ‡ฑ,BL
๐Ÿ‡ง๐Ÿ‡ฒ,BM
๐Ÿ‡ง๐Ÿ‡ณ,BN
๐Ÿ‡ง๐Ÿ‡ด,BO
๐Ÿ‡ง๐Ÿ‡ถ,BQ
๐Ÿ‡ง๐Ÿ‡ท,BR
๐Ÿ‡ง๐Ÿ‡ธ,BS
๐Ÿ‡ง๐Ÿ‡น,BT
๐Ÿ‡ง๐Ÿ‡ป,BV
๐Ÿ‡ง๐Ÿ‡ผ,BW
๐Ÿ‡ง๐Ÿ‡พ,BY
๐Ÿ‡ง๐Ÿ‡ฟ,BZ
๐Ÿ‡จ๐Ÿ‡ฆ,CA
๐Ÿ‡จ๐Ÿ‡จ,CC
๐Ÿ‡จ๐Ÿ‡ฉ,CD
๐Ÿ‡จ๐Ÿ‡ซ,CF
๐Ÿ‡จ๐Ÿ‡ฌ,CG
๐Ÿ‡จ๐Ÿ‡ญ,CH
๐Ÿ‡จ๐Ÿ‡ฎ,CI
๐Ÿ‡จ๐Ÿ‡ฐ,CK
๐Ÿ‡จ๐Ÿ‡ฑ,CL
๐Ÿ‡จ๐Ÿ‡ฒ,CM
๐Ÿ‡จ๐Ÿ‡ณ,CN
๐Ÿ‡จ๐Ÿ‡ด,CO
๐Ÿ‡จ๐Ÿ‡ต,CP
๐Ÿ‡จ๐Ÿ‡ท,CR
๐Ÿ‡จ๐Ÿ‡บ,CU
๐Ÿ‡จ๐Ÿ‡ป,CV
๐Ÿ‡จ๐Ÿ‡ผ,CW
๐Ÿ‡จ๐Ÿ‡ฝ,CX
๐Ÿ‡จ๐Ÿ‡พ,CY
๐Ÿ‡จ๐Ÿ‡ฟ,CZ
๐Ÿ‡ฉ๐Ÿ‡ช,DE
๐Ÿ‡ฉ๐Ÿ‡ฌ,DG
๐Ÿ‡ฉ๐Ÿ‡ฏ,DJ
๐Ÿ‡ฉ๐Ÿ‡ฐ,DK
๐Ÿ‡ฉ๐Ÿ‡ฒ,DM
๐Ÿ‡ฉ๐Ÿ‡ด,DO
๐Ÿ‡ฉ๐Ÿ‡ฟ,DZ
๐Ÿ‡ช๐Ÿ‡ฆ,EA
๐Ÿ‡ช๐Ÿ‡จ,EC
๐Ÿ‡ช๐Ÿ‡ช,EE
๐Ÿ‡ช๐Ÿ‡ฌ,EG
๐Ÿ‡ช๐Ÿ‡ญ,EH
๐Ÿ‡ช๐Ÿ‡ท,ER
๐Ÿ‡ช๐Ÿ‡ธ,ES
๐Ÿ‡ช๐Ÿ‡น,ET
๐Ÿ‡ช๐Ÿ‡บ,EU
๐Ÿ‡ซ๐Ÿ‡ฎ,FI
๐Ÿ‡ซ๐Ÿ‡ฏ,FJ
๐Ÿ‡ซ๐Ÿ‡ฐ,FK
๐Ÿ‡ซ๐Ÿ‡ฒ,FM
๐Ÿ‡ซ๐Ÿ‡ด,FO
๐Ÿ‡ซ๐Ÿ‡ท,FR
๐Ÿ‡ฌ๐Ÿ‡ฆ,GA
๐Ÿ‡ฌ๐Ÿ‡ง,GB
๐Ÿ‡ฌ๐Ÿ‡ฉ,GD
๐Ÿ‡ฌ๐Ÿ‡ช,GE
๐Ÿ‡ฌ๐Ÿ‡ซ,GF
๐Ÿ‡ฌ๐Ÿ‡ฌ,GG
๐Ÿ‡ฌ๐Ÿ‡ญ,GH
๐Ÿ‡ฌ๐Ÿ‡ฎ,GI
๐Ÿ‡ฌ๐Ÿ‡ฑ,GL
๐Ÿ‡ฌ๐Ÿ‡ฒ,GM
๐Ÿ‡ฌ๐Ÿ‡ณ,GN
๐Ÿ‡ฌ๐Ÿ‡ต,GP
๐Ÿ‡ฌ๐Ÿ‡ถ,GQ
๐Ÿ‡ฌ๐Ÿ‡ท,GR
๐Ÿ‡ฌ๐Ÿ‡ธ,GS
๐Ÿ‡ฌ๐Ÿ‡น,GT
๐Ÿ‡ฌ๐Ÿ‡บ,GU
๐Ÿ‡ฌ๐Ÿ‡ผ,GW
๐Ÿ‡ฌ๐Ÿ‡พ,GY
๐Ÿ‡ญ๐Ÿ‡ฐ,HK
๐Ÿ‡ญ๐Ÿ‡ฒ,HM
๐Ÿ‡ญ๐Ÿ‡ณ,HN
๐Ÿ‡ญ๐Ÿ‡ท,HR
๐Ÿ‡ญ๐Ÿ‡น,HT
๐Ÿ‡ญ๐Ÿ‡บ,HU
๐Ÿ‡ฎ๐Ÿ‡จ,IC
๐Ÿ‡ฎ๐Ÿ‡ฉ,ID
๐Ÿ‡ฎ๐Ÿ‡ช,IE
๐Ÿ‡ฎ๐Ÿ‡ฑ,IL
๐Ÿ‡ฎ๐Ÿ‡ฒ,IM
๐Ÿ‡ฎ๐Ÿ‡ณ,IN
๐Ÿ‡ฎ๐Ÿ‡ด,IO
๐Ÿ‡ฎ๐Ÿ‡ถ,IQ
๐Ÿ‡ฎ๐Ÿ‡ท,IR
๐Ÿ‡ฎ๐Ÿ‡ธ,IS
๐Ÿ‡ฎ๐Ÿ‡น,IT
๐Ÿ‡ฏ๐Ÿ‡ช,JE
๐Ÿ‡ฏ๐Ÿ‡ฒ,JM
๐Ÿ‡ฏ๐Ÿ‡ด,JO
๐Ÿ‡ฏ๐Ÿ‡ต,JP
๐Ÿ‡ฐ๐Ÿ‡ช,KE
๐Ÿ‡ฐ๐Ÿ‡ฌ,KG
๐Ÿ‡ฐ๐Ÿ‡ญ,KH
๐Ÿ‡ฐ๐Ÿ‡ฎ,KI
๐Ÿ‡ฐ๐Ÿ‡ฒ,KM
๐Ÿ‡ฐ๐Ÿ‡ณ,KN
๐Ÿ‡ฐ๐Ÿ‡ต,KP
๐Ÿ‡ฐ๐Ÿ‡ท,KR
๐Ÿ‡ฐ๐Ÿ‡ผ,KW
๐Ÿ‡ฐ๐Ÿ‡พ,KY
๐Ÿ‡ฐ๐Ÿ‡ฟ,KZ
๐Ÿ‡ฑ๐Ÿ‡ฆ,LA
๐Ÿ‡ฑ๐Ÿ‡ง,LB
๐Ÿ‡ฑ๐Ÿ‡จ,LC
๐Ÿ‡ฑ๐Ÿ‡ฎ,LI
๐Ÿ‡ฑ๐Ÿ‡ฐ,LK
๐Ÿ‡ฑ๐Ÿ‡ท,LR
๐Ÿ‡ฑ๐Ÿ‡ธ,LS
๐Ÿ‡ฑ๐Ÿ‡น,LT
๐Ÿ‡ฑ๐Ÿ‡บ,LU
๐Ÿ‡ฑ๐Ÿ‡ป,LV
๐Ÿ‡ฑ๐Ÿ‡พ,LY
๐Ÿ‡ฒ๐Ÿ‡ฆ,MA
๐Ÿ‡ฒ๐Ÿ‡จ,MC
๐Ÿ‡ฒ๐Ÿ‡ฉ,MD
๐Ÿ‡ฒ๐Ÿ‡ช,ME
๐Ÿ‡ฒ๐Ÿ‡ซ,MF
๐Ÿ‡ฒ๐Ÿ‡ฌ,MG
๐Ÿ‡ฒ๐Ÿ‡ญ,MH
๐Ÿ‡ฒ๐Ÿ‡ฐ,MK
๐Ÿ‡ฒ๐Ÿ‡ฑ,ML
๐Ÿ‡ฒ๐Ÿ‡ฒ,MM
๐Ÿ‡ฒ๐Ÿ‡ณ,MN
๐Ÿ‡ฒ๐Ÿ‡ด,MO
๐Ÿ‡ฒ๐Ÿ‡ต,MP
๐Ÿ‡ฒ๐Ÿ‡ถ,MQ
๐Ÿ‡ฒ๐Ÿ‡ท,MR
๐Ÿ‡ฒ๐Ÿ‡ธ,MS
๐Ÿ‡ฒ๐Ÿ‡น,MT
๐Ÿ‡ฒ๐Ÿ‡บ,MU
๐Ÿ‡ฒ๐Ÿ‡ป,MV
๐Ÿ‡ฒ๐Ÿ‡ผ,MW
๐Ÿ‡ฒ๐Ÿ‡ฝ,MX
๐Ÿ‡ฒ๐Ÿ‡พ,MY
๐Ÿ‡ฒ๐Ÿ‡ฟ,MZ
๐Ÿ‡ณ๐Ÿ‡ฆ,NA
๐Ÿ‡ณ๐Ÿ‡จ,NC
๐Ÿ‡ณ๐Ÿ‡ช,NE
๐Ÿ‡ณ๐Ÿ‡ซ,NF
๐Ÿ‡ณ๐Ÿ‡ฌ,NG
๐Ÿ‡ณ๐Ÿ‡ฎ,NI
๐Ÿ‡ณ๐Ÿ‡ฑ,NL
๐Ÿ‡ณ๐Ÿ‡ด,NO
๐Ÿ‡ณ๐Ÿ‡ต,NP
๐Ÿ‡ณ๐Ÿ‡ท,NR
๐Ÿ‡ณ๐Ÿ‡บ,NU
๐Ÿ‡ณ๐Ÿ‡ฟ,NZ
๐Ÿ‡ด๐Ÿ‡ฒ,OM
๐Ÿ‡ต๐Ÿ‡ฆ,PA
๐Ÿ‡ต๐Ÿ‡ช,PE
๐Ÿ‡ต๐Ÿ‡ซ,PF
๐Ÿ‡ต๐Ÿ‡ฌ,PG
๐Ÿ‡ต๐Ÿ‡ญ,PH
๐Ÿ‡ต๐Ÿ‡ฐ,PK
๐Ÿ‡ต๐Ÿ‡ฑ,PL
๐Ÿ‡ต๐Ÿ‡ฒ,PM
๐Ÿ‡ต๐Ÿ‡ณ,PN
๐Ÿ‡ต๐Ÿ‡ท,PR
๐Ÿ‡ต๐Ÿ‡ธ,PS
๐Ÿ‡ต๐Ÿ‡น,PT
๐Ÿ‡ต๐Ÿ‡ผ,PW
๐Ÿ‡ต๐Ÿ‡พ,PY
๐Ÿ‡ถ๐Ÿ‡ฆ,QA
๐Ÿ‡ท๐Ÿ‡ช,RE
๐Ÿ‡ท๐Ÿ‡ด,RO
๐Ÿ‡ท๐Ÿ‡ธ,RS
๐Ÿ‡ท๐Ÿ‡บ,RU
๐Ÿ‡ท๐Ÿ‡ผ,RW
๐Ÿ‡ธ๐Ÿ‡ฆ,SA
๐Ÿ‡ธ๐Ÿ‡ง,SB
๐Ÿ‡ธ๐Ÿ‡จ,SC
๐Ÿ‡ธ๐Ÿ‡ฉ,SD
๐Ÿ‡ธ๐Ÿ‡ช,SE
๐Ÿ‡ธ๐Ÿ‡ฌ,SG
๐Ÿ‡ธ๐Ÿ‡ญ,SH
๐Ÿ‡ธ๐Ÿ‡ฎ,SI
๐Ÿ‡ธ๐Ÿ‡ฏ,SJ
๐Ÿ‡ธ๐Ÿ‡ฐ,SK
๐Ÿ‡ธ๐Ÿ‡ฑ,SL
๐Ÿ‡ธ๐Ÿ‡ฒ,SM
๐Ÿ‡ธ๐Ÿ‡ณ,SN
๐Ÿ‡ธ๐Ÿ‡ด,SO
๐Ÿ‡ธ๐Ÿ‡ท,SR
๐Ÿ‡ธ๐Ÿ‡ธ,SS
๐Ÿ‡ธ๐Ÿ‡น,ST
๐Ÿ‡ธ๐Ÿ‡ป,SV
๐Ÿ‡ธ๐Ÿ‡ฝ,SX
๐Ÿ‡ธ๐Ÿ‡พ,SY
๐Ÿ‡ธ๐Ÿ‡ฟ,SZ
๐Ÿ‡น๐Ÿ‡ฆ,TA
๐Ÿ‡น๐Ÿ‡จ,TC
๐Ÿ‡น๐Ÿ‡ฉ,TD
๐Ÿ‡น๐Ÿ‡ซ,TF
๐Ÿ‡น๐Ÿ‡ฌ,TG
๐Ÿ‡น๐Ÿ‡ญ,TH
๐Ÿ‡น๐Ÿ‡ฏ,TJ
๐Ÿ‡น๐Ÿ‡ฐ,TK
๐Ÿ‡น๐Ÿ‡ฑ,TL
๐Ÿ‡น๐Ÿ‡ฒ,TM
๐Ÿ‡น๐Ÿ‡ณ,TN
๐Ÿ‡น๐Ÿ‡ด,TO
๐Ÿ‡น๐Ÿ‡ท,TR
๐Ÿ‡น๐Ÿ‡น,TT
๐Ÿ‡น๐Ÿ‡ป,TV
๐Ÿ‡น๐Ÿ‡ผ,TW
๐Ÿ‡น๐Ÿ‡ฟ,TZ
๐Ÿ‡บ๐Ÿ‡ฆ,UA
๐Ÿ‡บ๐Ÿ‡ฌ,UG
๐Ÿ‡บ๐Ÿ‡ฒ,UM
๐Ÿ‡บ๐Ÿ‡ณ,UN
๐Ÿ‡บ๐Ÿ‡ธ,US
๐Ÿ‡บ๐Ÿ‡พ,UY
๐Ÿ‡บ๐Ÿ‡ฟ,UZ
๐Ÿ‡ป๐Ÿ‡ฆ,VA
๐Ÿ‡ป๐Ÿ‡จ,VC
๐Ÿ‡ป๐Ÿ‡ช,VE
๐Ÿ‡ป๐Ÿ‡ฌ,VG
๐Ÿ‡ป๐Ÿ‡ฎ,VI
๐Ÿ‡ป๐Ÿ‡ณ,VN
๐Ÿ‡ป๐Ÿ‡บ,VU
๐Ÿ‡ผ๐Ÿ‡ซ,WF
๐Ÿ‡ผ๐Ÿ‡ธ,WS
๐Ÿ‡ฝ๐Ÿ‡ฐ,XK
๐Ÿ‡พ๐Ÿ‡ช,YE
๐Ÿ‡พ๐Ÿ‡น,YT
๐Ÿ‡ฟ๐Ÿ‡ฆ,ZA
๐Ÿ‡ฟ๐Ÿ‡ฒ,ZM
๐Ÿ‡ฟ๐Ÿ‡ผ,ZW

CLDR version 35 is out and supported in ex_cldr 2.6

CLDR 35 is out and I've published ex_cldr version 2.6 which uses that data. I note there are updates to territory data in the release. No release for cldr_territories should be required since you're using ~> 2.0 as the version dependency. So feel free to close the issue. I bumped minor version only because the data that is returned by some functions is data dependent on CLDR release.

Loosen the cldr version requirement

I think the base of cldr is stable enough to have {:ex_cldr, "~> 1.0"} instead of {:ex_cldr, "~> 1.0.0"}. This way one can use 1.2 without the need to override the version requirements for all packages.

Q: Short format for subdivisions

@Schultzer @kipcole9

In my use-case there's a need for abbreviated US state names and I don't see the ex_cldr_territories supporting this. Those are considered subdivisions in CLDR so I wonder if you guys have any intention to add the subdivision abbreviations in the future, for if not, I'll do it in my app on an on-demand basis.

For the time being I'm simply splitting the "us" prefix from the rest of the subdivision string and using the remaining part in upper case. This works for the US subdivision codes as they derive from the state name abbreviations, but it certainly won't work with I'd say vast majority of other territories and their subdivisions.

I'd also like to hear your thoughts on this one in general.

Thanks,

Damir

Dialyzer failure - `translate_territory!`, `translate_subdivision!` and `translate_language_tag!`

I recently started getting this dialyzer failure:

mix dialyzer



deps/ex_cldr_territories/lib/cldr/backend.ex:465:pattern_match
The pattern can never match the type.

Pattern:
{:ok, _}

Type:
{:error, {atom(), binary()}}

________________________________________________________________________________
deps/ex_cldr_territories/lib/cldr/backend.ex:486:pattern_match
The pattern can never match the type.

Pattern:
{:ok, _}

Type:
{:error, {atom(), binary()}}

________________________________________________________________________________
deps/ex_cldr_territories/lib/cldr/backend.ex:543:pattern_match
The pattern can never match the type.

Pattern:
{:ok, _}

Type:
{:error, {atom(), binary()}}

_______

versions:
elixir 1.17.0-rc.0
erlang 27.0

lib versions:
dialyxir 1.4.3
ex_cldr 2.38.1
ex_cldr_territories 2.9.0

Compilation Error When updating to ex_cldr 2.38.0

elixir: 1.16.2
erlang: 26.2.4
OS: MacOS 14.4.1

I'm running into issues compiling this package after updating to the latest releases of ex_cldr. I get the following error message.

==> ex_cldr_territories
Compiling 3 files (.ex)

== Compilation error in file lib/cldr/territory.ex ==
** (Protocol.UndefinedError) protocol Enumerable not implemented for :AW of type Atom
    (elixir 1.16.2) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir 1.16.2) lib/enum.ex:166: Enumerable.reduce/3
    (elixir 1.16.2) lib/enum.ex:4396: Enum.map/2
    lib/cldr/territory.ex:16: anonymous fn/1 in :elixir_compiler_2.__MODULE__/1
    (elixir 1.16.2) lib/map.ex:257: Map.do_map/2
    (elixir 1.16.2) lib/map.ex:257: Map.do_map/2
    (elixir 1.16.2) lib/map.ex:251: Map.new_from_map/2
    lib/cldr/territory.ex:14: (module)
could not compile dependency :ex_cldr_territories, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile ex_cldr_territories --force", update it with "mix deps.update ex_cldr_territories" or clean it with "mix deps.clean ex_cldr_territories"

I'm guessing that there's been some API change somewhere that has not been fixed upstream. Let me know if you need any more info or help debugging.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.