Skip to content

Commit 7f5fbbd

Browse files
committed
Release preparation: guide accuracy fixes, changelog, version bump
1 parent 6131dd4 commit 7f5fbbd

6 files changed

Lines changed: 43 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ All notable changes to this project will be documented in this file.
44

55
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).
66

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.
810

911
### Changed
1012

@@ -18,14 +20,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
1820

1921
* **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`.
2022

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-
2323
### Documentation
2424

2525
* `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).
2626

2727
### Fixed
2828

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+
2933
* `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`.
3034

3135
* 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").

guides/interval_and_duration_formatting.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,41 @@ iex> Localize.Interval.to_string(nil, ~D[2020-01-01], locale: :ja)
4444

4545
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.
4646

47-
### Styles and formats
47+
### Fields and formats
4848

49-
The `:style` option controls which fields appear in the output:
49+
Two independent options shape the output. `:fields` selects *which* date fields appear:
5050

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 |
5757

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`.
5959

6060
```elixir
6161
iex> {:ok, result} =
6262
...> Localize.Interval.to_string(~D[2022-04-22], ~D[2022-04-25],
6363
...> locale: :en,
64-
...> style: :month_and_day,
64+
...> fields: :month_and_day,
6565
...> format: :long
6666
...> )
6767
iex> String.contains?(result, "Fri") and String.contains?(result, "Mon")
6868
true
6969
```
7070

71+
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:
72+
73+
```elixir
74+
iex> Localize.Interval.known_fields()
75+
%{
76+
month: %{short: :M, full: :MMM, long: :MMM, medium: :MMM},
77+
month_and_day: %{short: :Md, full: :MMMEd, long: :MMMEd, medium: :MMMd},
78+
year_and_month: %{short: :yM, full: :yMMMM, long: :yMMMM, medium: :yMMM}
79+
}
80+
```
81+
7182
### Intervals for times and datetimes
7283

7384
`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
173184
```elixir
174185
iex> d = Localize.Duration.new_from_seconds(3665)
175186
iex> Localize.Duration.to_string(d, locale: :en, except: [:microsecond, :second])
176-
{:ok, "1 hour and 1 minute"}
187+
{:ok, "1 hour, 1 minute"}
177188
```
178189

179190
Other locales format durations using their native unit names and list separator:

guides/migration.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,13 @@ Set the locale for the current process:
101101
iex> {:ok, _} = Localize.put_locale(:de)
102102
iex> Localize.get_locale().cldr_locale_id
103103
:de
104+
iex> {:ok, _} = Localize.put_locale(:en)
105+
iex> Localize.get_locale().cldr_locale_id
106+
:en
104107
```
105108

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+
106111
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.
107112

108113
Use `Localize.with_locale/2` for temporary locale changes:

guides/number_formatting.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ Available RBNF rules vary by locale. Query them with:
126126
```elixir
127127
iex> {:ok, rules} = Localize.Number.Rbnf.rule_names_for_locale(:en)
128128
iex> rules
129-
["spellout_cardinal", "spellout_ordinal", "digits_ordinal",
130-
"spellout_numbering", "spellout_numbering_year", "spellout_cardinal_verbose",
131-
"spellout_numbering_verbose", "spellout_ordinal_verbose"]
129+
["digits_ordinal", "spellout_cardinal", "spellout_cardinal_verbose",
130+
"spellout_numbering", "spellout_numbering_verbose", "spellout_numbering_year",
131+
"spellout_ordinal", "spellout_ordinal_verbose"]
132132
```
133133

134134
The root locale (`:und`) provides universal rules like `roman_upper`, `roman_lower`, `hebrew`, `ethiopic`, `greek_upper`, `greek_lower`, `armenian_upper`, `armenian_lower`, `cyrillic_lower`, `georgian`, and `tamil`.

lib/localize/calendar.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,11 @@ defmodule Localize.Calendar do
836836
* `part` is one of `:era`, `:quarter`, `:month`,
837837
`:day_of_week`, `:days_of_week`, or `:day_period`.
838838
839-
* `options` is a keyword list of options. See `localize/3`.
839+
* `options` is a keyword list of options.
840+
841+
### Options
842+
843+
See `localize/3` for the supported options.
840844
841845
### Returns
842846

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Localize.MixProject do
22
use Mix.Project
33

4-
@version "1.0.0-rc.6"
4+
@version "1.0.0-rc.7"
55
@cldr_version_path "priv/localize/version"
66
@localize_patch_version_path "priv/localize/localize_patch_version"
77

0 commit comments

Comments
 (0)