You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,14 @@
2
2
3
3
**Note that `ex_cldr` version 2.39.0 and later are supported on Elixir 1.12 and later only.**
4
4
5
+
## Cldr v2.40.0
6
+
7
+
This is the changelog for Cldr v2.40.0 released on ______, 2024. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr/tags)
8
+
9
+
### Enhancements
10
+
11
+
* Support OTP's `:json` module. `ex_cldr` uses json formatted locale data and supports configuring a `json` library to decode it. Where no library is configured `ex_cldr` will attempt to identify one. This release adds auto-configuring OTP 27's `:json` module through a proxy implemented in `Cldr.Json` (which is part of `cldr_utils`).
12
+
5
13
## Cldr v2.39.2
6
14
7
15
This is the changelog for Cldr v2.39.2 released on June 22nd, 2024. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr/tags)
Copy file name to clipboardExpand all lines: README.md
+22-23Lines changed: 22 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,10 +12,10 @@
12
12
> does not attempt to read the configuration of either Phoenix of Ecto.
13
13
>
14
14
> Specifing the `:json_library` parameter under the `:ex_cldr`
15
-
> configuration key in `config.exs` is recommended however the availability
16
-
> of `Jason` or `Poison` will still be automatically detected and configured
15
+
> configuration key in `config.exs` is recommended however the availability
16
+
> of `Jason` or `Poison` will still be automatically detected and configured
17
17
> if the `:json_library` key is not set.
18
-
18
+
19
19
## Introduction
20
20
21
21
`ex_cldr` is an Elixir library for the [Unicode Consortium's](http://unicode.org)[Common Locale Data Repository (CLDR)](http://cldr.unicode.org). The intentions of CLDR, and this library, is to simplify the locale specific formatting and parsing of numbers, lists, currencies, calendars, units of measure and dates/times. As of April 28th 2023 and `ex_cldr` Version 2.37.0, `ex_cldr` is based upon [CLDR version 43.0](http://cldr.unicode.org/index/downloads/cldr-43).
@@ -39,7 +39,7 @@ end
39
39
```
40
40
41
41
This strategy means that different configurations can be defined and it also
42
-
means that one `Cldr` implementation won't interfere with implementations in other,
42
+
means that one `ex_cldr` implementation won't interfere with implementations in other,
43
43
potentially dependent, applications.
44
44
45
45
The functions you are mostly likely to use are:
@@ -67,11 +67,11 @@ Use this library if you need to:
67
67
68
68
## Elixir Version Requirements
69
69
70
-
*[ex_cldr](https://hex.pm/packages/ex_cldr) requires Elixir 1.11 or later.
70
+
*[ex_cldr](https://hex.pm/packages/ex_cldr) requires Elixir 1.12 or later.
71
71
72
72
## Installation
73
73
74
-
Add `ex_cldr` and the JSON library of your choice as a dependencies to your `mix` project:
74
+
Add `ex_cldr` and the JSON library of your choice as a dependencies to your `mix` project. If running on OTP 27 or later, this step is not required since `ex_cldr` will detect and use the built-in `:json` module.
75
75
76
76
```elixir
77
77
defpdepsdo
@@ -99,7 +99,7 @@ mix deps.compile
99
99
* Plugs for setting the locale from an HTTP request: [ex_cldr_plugs](https://hex.pm/packages/ex_cldr_plugs)
100
100
* Number formatting: [ex_cldr_numbers](https://hex.pm/packages/ex_cldr_numbers)
101
101
* List formatting: [ex_cldr_lists](https://hex.pm/packages/ex_cldr_lists)
102
-
* Unit formatting: [ex_cldr_units](https://hex.pm/packages/ex_cldr_units)
102
+
* Unit or measure formatting: [ex_cldr_units](https://hex.pm/packages/ex_cldr_units)
* Person name formatting: [ex_cldr_person_names](https://hex.pm/packages/ex_cldr_person_names)
112
113
* Territories localization and information: [ex_cldr_territories](https://hex.pm/packages/ex_cldr_territories) by @Schultzer
113
114
* Languages localization: [ex_cldr_languages](https://hex.pm/packages/ex_cldr_languages) by @lostkobrakai
114
115
115
116
Each of these packages includes `ex_cldr` as a dependency so configuring any of these additional packages will automatically install `ex_cldr`.
116
117
117
118
## Configuration
118
119
119
-
`Cldr` attempts to maximise runtime performance at the expense of additional compile time. Where possible `Cldr` will create functions to encapsulate data at compile time. To perform these optimizations for all 541 locales known to Cldr wouldn't be an effective use of your time or your computer's. Therefore `Cldr` requires that you configure the locales you want to use.
120
+
`ex_cldr` attempts to maximise runtime performance at the expense of additional compile time. Where possible `ex_cldr` will create functions to encapsulate data at compile time. To perform these optimizations for all 541 locales known to Cldr wouldn't be an effective use of your time or your computer's. Therefore `ex_cldr` requires that you configure the locales you want to use.
120
121
121
-
The preferred way to configure `Cldr` is to define the configuration in your backend module. This removes any dependency on your `mix.exs` and therefore simplifies deployment as a release.
122
+
`ex_cldr` is configured in your backend module. This removes any dependency on your `mix.exs` and therefore simplifies deployment as a release.
122
123
123
124
### Backend Module Configuration
124
125
@@ -137,11 +138,9 @@ The preferred way to configure `Cldr` is to define the configuration in your bac
137
138
> of these additional modules is determined by the modules
138
139
> configured under the `:providers` option to `use Cldr`.
139
140
>
140
-
> It is not recommended that a module that invoke`use Cldr`
141
+
> It is not recommended that a module that invokes`use Cldr`
141
142
> define any other functions.
142
143
143
-
The preferred configuration method is to define the configuration in the backend module. Using the backend configuration in `config.exs` is discouraged and will result in a warning at compile time. The configuration keys are the same so the preferred way to achieve the same configuration as defined in the global example is:
144
-
145
144
```elixir
146
145
defmoduleMyApp.Cldrdo
147
146
useCldr,
@@ -161,7 +160,7 @@ end
161
160
162
161
### Otp App Configuration
163
162
164
-
In the backend configuration example above the `:otp_app` key has been defined. This means that `Cldr` will look for additional configuration, defined under the key `:my_app` with the sub-key `MyApp.Cldr`. For example:
163
+
In the backend configuration example above the `:otp_app` key has been defined. This means that `ex_cldr` will look for additional configuration, defined under the key `:my_app` with the sub-key `MyApp.Cldr`. For example:
165
164
166
165
```elixir
167
166
# cldr.ex
@@ -196,7 +195,7 @@ Multiple backends can be configured under a single `:otp_app` if required.
196
195
197
196
### Global configuration.
198
197
199
-
In `config.exs` a global configuration can be defined under the `:ex_cldr` key. Although any valid configuration keys can be used here, only the keys `:json_library`, `:default_locale`, `:default_backend`, `:cacertfile`, `:data_dir`, `:force_locale_download` are considered valid. Other configuration keys may be used to aid migration from `Cldr` version 1.x but a deprecation message will be printed during compilation. Here's an example of global configuration:
198
+
In `config.exs` a global configuration can be defined under the `:ex_cldr` key. Although any valid configuration keys can be used here, only the keys `:json_library`, `:default_locale`, `:default_backend`, `:cacertfile`, `:data_dir`, `:force_locale_download` are considered valid. Other configuration keys may be used to aid migration from `ex_cldr` version 1.x but a deprecation message will be printed during compilation. Here's an example of global configuration:
200
199
201
200
```elixir
202
201
config :ex_cldr,
@@ -222,15 +221,15 @@ When building the consolidated configuration the following priority applies:
222
221
223
222
### Backend Configuration Keys
224
223
225
-
The configuration keys available for `Cldr` are:
224
+
The configuration keys available for `ex_cldr` are:
226
225
227
226
*`default_locale` specifies the default locale to be used for this backend. The default locale in case no other locale has been set is `"en-001"`. The default locale calculated as follows:
228
227
229
228
* If set by the `:default_locale` key, then this is the priority
230
229
* If no `:default_locale` key, then a configured `Gettext` default locale for this backend is chosen
231
230
* If no `:default_locale` key is specified and no `Gettext` module is configured, or is configured but has no default set, use `Cldr.default_locale/0` which returns either the default locale configurated in `mix.exs` under the `ex_cldr` key or then the system default locale will is currently `en-001`
232
231
233
-
*`locales`: Defines what locales will be configured in `Cldr`. Only these locales will be available and an exception `Cldr.UnknownLocaleError` will be raised if there is an attempt to use an unknown locale. This is the same behaviour as `Gettext`. Locales are configured as a list of binaries (strings). For convenience it is possible to use wildcard matching of locales which is particulalry helpful when there are many regional variances of a single language locale. For example, there are over 100 regional variants of the "en" locale in CLDR. A wildcard locale is detected by the presence of `.`, `[`, `*` and `+` in the locale string. This locale is then matched using the pattern as a `regex` to match against all available locales. The example below will configure all locales that start with `en-` and the locale `fr`.
232
+
*`locales`: Defines what locales will be configured in `ex_cldr`. Only these locales will be available and an exception `Cldr.UnknownLocaleError` will be raised if there is an attempt to use an unknown locale. This is the same behaviour as `Gettext`. Locales are configured as a list of binaries (strings). For convenience it is possible to use wildcard matching of locales which is particulalry helpful when there are many regional variances of a single language locale. For example, there are over 100 regional variants of the "en" locale in CLDR. A wildcard locale is detected by the presence of `.`, `[`, `*` and `+` in the locale string. This locale is then matched using the pattern as a `regex` to match against all available locales. The example below will configure all locales that start with `en-` and the locale `fr`.
234
233
235
234
```elixir
236
235
useCldr,
@@ -242,7 +241,7 @@ use Cldr,
242
241
243
242
*`:add_fallback_locales` is a boolean key which when `true` results in the fallback locales being added for each of the configured locales. The default is `false`. The reason to set this option to `true` is that some data such as rules based number formats and subdivision data are inherited from their language roots. For example, the locale `en-001` is inherited from the locale `en`. Locale `en-001` does not have any rules based number formats or subdivision data defined for it. However locale `en` does. Including the fallback locales maximises the opportunity to resolve localised data.
244
243
245
-
*`:gettext`: specifies the name of a Gettext module that informs `Cldr` to use that module as an additional source of locales you want to configure. Since `Gettext` uses the Posix locale name format (locales with an '\_' in them) and `Cldr` uses the Unicode format (a '-' as the subtag separator), `Cldr` will transliterate locale names from `Gettext` into the `Cldr` canonical form. For example:
244
+
*`:gettext`: specifies the name of a Gettext module that informs `ex_cldr` to use that module as an additional source of locales you want to configure. Since `Gettext` uses the Posix locale name format (locales with an '\_' in them) and `ex_cldr` uses the Unicode format (a '-' as the subtag separator), `ex_cldr` will transliterate locale names from `Gettext` into the `ex_cldr` canonical form. For example:
246
245
247
246
```elixir
248
247
useCldr,
@@ -263,7 +262,7 @@ use Cldr,
263
262
264
263
*`:default_currency_format` determines whether `Cldr.Number.to_string/2` will use `:currency` or `:accounting` if no format is specified but a currency is. The default is `nil` which means that the format will be derived from the locale.
265
264
266
-
*`:providers`: a list of modules that provide `Cldr` functionality to be compiled into the backend module. See the [providers](#providers) section below.
265
+
*`:providers`: a list of modules that provide `ex_cldr` functionality to be compiled into the backend module. See the [providers](#providers) section below.
267
266
268
267
*`:generate_docs` defines whether or not to generate documentation for the modules built as part of the backend. Since these modules represent the public API for `ex_cldr`, the default is `true`. Setting this key to `false` (the atom `false`, not a *falsy* value) will prevent the generation of docs for this backend.
269
268
@@ -284,7 +283,7 @@ end
284
283
285
284
### Providers
286
285
287
-
The data maintained by [CLDR](https://cldr.unicode.org) is quite large and not all capabilities are required by all applications. Hence `Cldr` has additional optional functionality that can be provided through additional `hex` packages. In order to support compile-time additions to a configured `backend`, any package can define a provider that will be called at compile time.
286
+
The data maintained by [CLDR](https://cldr.unicode.org) is quite large and not all capabilities are required by all applications. Hence `ex_cldr` has additional optional functionality that can be provided through additional `hex` packages. In order to support compile-time additions to a configured `backend`, any package can define a provider that will be called at compile time.
288
287
289
288
The currently known providers and their `hex` package names are:
290
289
@@ -313,7 +312,7 @@ defmodule MyApp.Cldr do
313
312
providers: [Cldr.Number, Cldr.List]
314
313
end
315
314
```
316
-
**If :providers is `nil` (the default), `Cldr` will attempt to configure all of the providers described above if they have been installed as `deps`. If you don't wish to invoke any providers, use the empty list `[]`.**
315
+
**If :providers is `nil` (the default), `ex_cldr` will attempt to configure all of the providers described above if they have been installed as `deps`. If you don't wish to invoke any providers, use the empty list `[]`.**
317
316
318
317
## Migrating from Cldr 1.x
319
318
@@ -324,7 +323,7 @@ end
324
323
325
324
## Downloading Locales
326
325
327
-
`Cldr` can be installed from either [github](https://github.com/elixir-cldr/cldr)
326
+
`ex_cldr` can be installed from either [github](https://github.com/elixir-cldr/cldr)
328
327
or from [hex](https://hex.pm/packages/ex_cldr).
329
328
330
329
* If installed from github then all 571 locales are installed when the repo is cloned into your application deps.
@@ -540,7 +539,7 @@ Other libraries in the family will progressively implement other extension keys.
540
539
### Notes
541
540
542
541
* A language code is an ISO-3166 language code.
543
-
* Potentially one or more modifiers separated by `-` (dash), not a `_`. (underscore). If you configure a `Gettext` module then `Cldr` will transliterate `Gettext`'s `_` into `-` for compatibility.
542
+
* Potentially one or more modifiers separated by `-` (dash), not a `_`. (underscore). If you configure a `Gettext` module then `ex_cldr` will transliterate `Gettext`'s `_` into `-` for compatibility.
544
543
* Typically the modifier is a territory code. This is commonly a two-letter uppercase combination. For example `pt-PT` is the locale referring to Portuguese as used in Portugal.
545
544
* In `ex_cldr` a locale name is always a `binary` and never an `atom`. Internally a locale is parsed and stored as a `t:Cldr.LanguageTag` struct.
546
545
* The locales known to `ex_cldr` can be retrieved by `Cldr.known_locale_names/1` to get the locales known to this configuration of `ex_cldr` and `Cldr.all_locale_names/0` to get the locales available in the CLDR data repository.
@@ -551,7 +550,7 @@ See the file `DEVELOPMENT.md` in the github repository.
551
550
552
551
### Testing
553
552
554
-
Tests cover the full ~700 locales defined in CLDR. Since `Cldr` attempts to maximize the work done at compile time in order to minimize runtime execution, the compilation phase for tests is several minutes.
553
+
Tests cover the full ~700 locales defined in CLDR. Since `ex_cldr` attempts to maximize the work done at compile time in order to minimize runtime execution, the compilation phase for tests is several minutes.
555
554
556
555
Tests are run on Elixir 1.11 and later. `ex_cldr` is not supported on Elixir versions before 1.11.
0 commit comments