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
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,9 @@ All notable changes to this project will be documented in this file.
4
4
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
7
-
## [Unreleased]
7
+
## [1.0.0-rc.7] — July 28th, 2026
8
+
9
+
This release settles the `:format` / `:style` option naming across the library. The rule is now uniform: `:format` is how a **value** is rendered, `:style` is which variant of a **name or pattern** you get, and an option that selects something else again — `Localize.Interval`'s choice of which date fields appear — is named for what it selects. Every rename below is a hard break with no alias; each entry names its replacement.
8
10
9
11
### Changed
10
12
@@ -18,14 +20,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
18
20
19
21
***Breaking:**`Localize.Interval.to_string/3` renames its `:style` option to `:fields`, because it selects *which* date fields appear (`:date`, `:month`, `:month_and_day`, `:year_and_month`) rather than a width — `:format` remains the width axis, and the two are now named for what they do. `Localize.Interval.date_styles/0` becomes `known_fields/0`, and `Localize.DateTimeIntervalFormatError` carries `:fields` with reason `:unknown_fields` in place of `:style` / `:unknown_style`.
20
22
21
-
*`Localize.Calendar.display_name/3` reports an unusable `:style` as a `:style` error listing the widths the field actually has, instead of blaming the value: `display_name(:month, 3, style: :bogus)` said `value: 3, expected: "1..13"`. `style: :short` now resolves wherever CLDR carries it (the day parts) rather than silently returning `nil`.
22
-
23
23
### Documentation
24
24
25
25
*`Localize.DateTime.to_string/2` documents its `:style`, `:date_format`, and `:time_format` options, which were live but absent from the docs. `:style` selects the date/time wrapper (`:at` renders "April 8, 2026 at 12:00:00 PM", and falls back to the standard wrapper for `:medium` and `:short`, which CLDR does not define it for).
26
26
27
27
### Fixed
28
28
29
+
*`Localize.Calendar.display_name/3` reports an unusable `:style` as a `:style` error listing the widths the field actually has, instead of blaming the value: `display_name(:month, 3, style: :bogus)` said `value: 3, expected: "1..13"`. `style: :short` now resolves wherever CLDR carries it (the day parts) rather than silently returning `nil`.
30
+
31
+
*`Localize.Unit.to_string/2` no longer lets a stray `:style` option reach the SI-prefix and custom-unit paths, where it produced "5 MegaJoule" for `style: :short` instead of the correct "5 Megajoule". The option has been ignored since 1.0.0-rc.0 and is now ignored everywhere, as documented.
32
+
29
33
*`Localize.Duration.to_string/2` and `to_parts/2` join duration parts with CLDR's unit list patterns matched to the format width, per ECMA-402 `Intl.DurationFormat`, instead of the standard "and" conjunction: `:en` now renders "3 days, 2 hr" (was "3 days and 2 hr") and "3d 2h" for `format: :narrow`.
30
34
31
35
* Per-compound units whose denominator carries a constant keep that count in every width: `curr-usd-per-30-day` renders "$10.00/30 days" for `format: :short`, where the denominator's precomposed `per_unit_pattern` ("{0}/d") previously swallowed the count and gave "$10.00/d". Counted denominators now compose through the locale's `compound.per` pattern, which also stops a numerator whose symbol contains the denominator noun being corrupted (narrow `candela-per-30-day` gave "10c30 d/30 d", now "10cd/30 d").
The separator comes from CLDR's `intervalFormatFallback` pattern for the locale — most Western locales use an en-dash (`–`), Japanese uses a fullwidth tilde (`~`), and so on. Passing `nil` for both endpoints returns an error.
46
46
47
-
### Styles and formats
47
+
### Fields and formats
48
48
49
-
The `:style` option controls whichfields appear in the output:
49
+
Two independent options shape the output. `:fields` selects *which* date fields appear:
50
50
51
-
|Style| Description| Example skeleton|
52
-
|---|---|---|
53
-
|`:date`|Full date (default)|`:yMMMd`|
54
-
|`:month`| Month only |`:MMM`|
55
-
|`:month_and_day`| Month and day |`:MMMd`|
56
-
|`:year_and_month`| Year and month |`:yMMM`|
51
+
|Fields| Description |
52
+
|---|---|
53
+
|`:date`|The whole date (the default) |
54
+
|`:month`| Month only |
55
+
|`:month_and_day`| Month and day |
56
+
|`:year_and_month`| Year and month |
57
57
58
-
The `:format`option selects the detail level: `:short`, `:medium` (default), or `:long`.
58
+
`:format` selects *how wide* those fields render: `:short`, `:medium` (the default), `:long`, or `:full`.
The pair selects a CLDR skeleton. `Localize.Interval.known_fields/0` returns the mapping for the non-default selections; `:date` is resolved per-locale from the same table `Localize.Date.to_string/2` uses, so it has no fixed entry here:
`Localize.Interval.to_string/3` accepts `Date`, `Time`, `NaiveDateTime`, and `DateTime` values, as well as any map with the appropriate fields. The formatting strategy depends on what fields differ:
@@ -173,7 +184,7 @@ The `:except` option drops specific units from the output. By default, `:microse
Copy file name to clipboardExpand all lines: guides/migration.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,8 +101,13 @@ Set the locale for the current process:
101
101
iex> {:ok, _} =Localize.put_locale(:de)
102
102
iex>Localize.get_locale().cldr_locale_id
103
103
:de
104
+
iex> {:ok, _} =Localize.put_locale(:en)
105
+
iex>Localize.get_locale().cldr_locale_id
106
+
:en
104
107
```
105
108
109
+
The setting lasts for the life of the process, so the examples below reset it to `:en` first — otherwise every later result would come back in German.
110
+
106
111
All formatting functions default their `:locale` option to `Localize.get_locale()`. In a Phoenix application you would typically call `Localize.put_locale/1` in a plug early in your pipeline.
107
112
108
113
Use `Localize.with_locale/2` for temporary locale changes:
0 commit comments