Skip to content

Commit

Permalink
Merge pull request #199 from sabify/fix-currency-docs
Browse files Browse the repository at this point in the history
fix: docs and json translation with currency code
  • Loading branch information
Baptistemontan authored Feb 27, 2025
2 parents e61def8 + 4417091 commit d739ad2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/book/src/declare/08_formatters.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ Enable the "format_currency" feature to use the number formatter.

### Arguments

There are two arguments at the moment for the currency formatter: `width` and `country_code`, which are based on [`icu_experimental::dimension::currency::options::Width`](https://docs.rs/icu_experimental/0.1.0/icu_experimental/dimension/currency/options/enum.Width.html) and [`icu_experimental::dimension::currency::formatter::CountryCode`](https://docs.rs/icu_experimental/0.1.0/icu_experimental/dimension/currency/formatter/struct.CurrencyCode.html).
There are two arguments at the moment for the currency formatter: `width` and `currency_code`, which are based on [`icu_experimental::dimension::currency::options::Width`](https://docs.rs/icu_experimental/0.1.0/icu_experimental/dimension/currency/options/enum.Width.html) and [`icu_experimental::dimension::currency::formatter::CurrencyCode`](https://docs.rs/icu_experimental/0.1.0/icu_experimental/dimension/currency/formatter/struct.CurrencyCode.html).

`width` values:

- short (default)
- narrow

`country_code` value should be a [currency code](https://www.iban.com/currency-codes), such as USD or EUR. The USD is the default value.
`currency_code` value should be a [currency code](https://www.iban.com/currency-codes), such as USD or EUR. The USD is the default value.

### Example

Expand Down
2 changes: 1 addition & 1 deletion tests/json/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"number_formatting": "{{ num, number }}",
"number_formatting_grouping": "{{ num, number(grouping_strategy: never) }}",
"currency_formatting": "{{ num, currency(currency_code: USD) }}",
"currency_formatting_width": "{{ num, currency(width: narrow; country_code: EUR) }}",
"currency_formatting_width": "{{ num, currency(width: narrow; currency_code: EUR) }}",
"cardinal_plural": "{{ count }}",
"ordinal_plural_ordinal_one": "{{ count }}re place",
"ordinal_plural_ordinal_other": "{{ count }}e place",
Expand Down
2 changes: 1 addition & 1 deletion tests/json/src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ fn currency_formatting() {
let en = td!(Locale::en, currency_formatting_width, num);
assert_eq_rendered!(en, "$2000.5");
let fr = td!(Locale::fr, currency_formatting_width, num);
assert_eq_rendered!(fr, "2000.5\u{a0}$");
assert_eq_rendered!(fr, "2000.5\u{a0}");
}

0 comments on commit d739ad2

Please sign in to comment.