More documentation (#1033)
* More documentation
* Changelog
* format
* Fixes per gemini review
* Add more examples
* readme update
* move example to lib folder
* move example to lib folder
* rename again
* simplify example
* add link
* ignore build files and fix workflow
* changes after review
* format
diff --git a/.github/workflows/intl4x.yml b/.github/workflows/intl4x.yml
index 6d3b656..4e4bc66 100644
--- a/.github/workflows/intl4x.yml
+++ b/.github/workflows/intl4x.yml
@@ -47,7 +47,7 @@
- run: dart test -p chrome
- - run: dart --enable-experiment=record-use build cli bin/example.dart
+ - run: dart --enable-experiment=record-use build cli --target example.dart
working-directory: pkgs/intl4x/example
- run: tree . -a
diff --git a/.gitignore b/.gitignore
index a13b04f..3ca347c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,4 @@
.vscode
doc/
+build/
\ No newline at end of file
diff --git a/pkgs/intl4x/CHANGELOG.md b/pkgs/intl4x/CHANGELOG.md
index a361e90..4a88f23 100644
--- a/pkgs/intl4x/CHANGELOG.md
+++ b/pkgs/intl4x/CHANGELOG.md
@@ -5,7 +5,7 @@
- Remove most ...Options objects from the public API, as they make it more verbose. Users now directly input the options to the top-level ...Format constructor.
- Use => instead of block bodies for methods where possible.
- Fix some imports
- - Add documentation to some classes (more to follow!)
+ - Add documentation to some classes.
- Remove some methods which are not implemented in ICU4X
## 0.14.0
diff --git a/pkgs/intl4x/README.md b/pkgs/intl4x/README.md
index c5f9340..85fb6f6 100644
--- a/pkgs/intl4x/README.md
+++ b/pkgs/intl4x/README.md
@@ -2,9 +2,9 @@
[](https://pub.dev/packages/intl4x)
[](https://pub.dev/packages/intl4x/publisher)
-A lightweight modular library for internationalization (i18n) functionality.
+# `intl4x`
-## Features
+A lightweight, modular library for internationalization (i18n) in Dart, providing locale-sensitive formatting, featuring:
* Formatting for dates, numbers, and lists.
* Collation.
@@ -13,40 +13,158 @@
## Status - experimental
-We're actively iterating on the API for this package (please provide feedback
-via our [issue tracker](https://github.com/dart-lang/i18n/issues)).
+We're actively iterating on the API for this package. Please provide feedback via our [issue tracker](https://github.com/dart-lang/i18n/issues).
-| | Number format | List format | Date format | Collation | Display names | Plural rules | Case mapping |
-|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
-| **ECMA402 (web)** | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
-| **ICU4X (web/native)** | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
+## Backends
-## Implementation and Goals
+This library uses different backends on different platforms:
-* Wraps around [ICU4X](https://github.com/unicode-org/icu4x) on native or web
- platforms.
-* Wraps around the built-in browser functionalities on the web.
- * Select which locales you want to use the browser for through an ``.
+* **ICU4X**: Wraps [ICU4X](https://github.com/unicode-org/icu4x) to provide i18n functionality on both native platforms.
+* **ECMA / Browser**: Wraps the browser's built-in [`Intl`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) functionalities for web-only applications, reducing bundle size.
-## Example
+## Installation
-The functionalities are called through getters on an `Intl` instance, i.e.
+Add `intl4x` to your `pubspec.yaml`:
+
+```shell
+dart pub add intl4x
+```
+
+
+## Limitations
+
+There are still some features missing:
+
+ * Compact, percent, unit, and currency formatting.
+ * Display names for calendar, currency, date time fields, and scripts.
+
+## Features
+
+### Date & Time Formatting
+
+Format `DateTime` objects into locale-sensitive strings for dates, times, and time zones.
+
+```dart
+import 'package:intl4x/datetime_format.dart';
+
+void main() {
+ final dateTime = DateTime(2024, 7, 1, 8, 50, 07);
+ final germanLocale = Locale.parse('de-DE');
+
+ final formatter = DateTimeFormat.yearMonthDayTime(
+ locale: germanLocale,
+ length: DateTimeLength.long,
+ ).withTimeZoneLong();
+
+ // Format with a specific timezone
+ print(formatter.format(dateTime, 'Europe/Berlin'));
+ // prints "1. Juli 2024 um 10:50:07 Mitteleuropäische Sommerzeit"
+}
+```
+
+### Number Formatting
+
+Format numbers as decimals, percentages, or in compact form with locale-specific rules.
```dart
import 'package:intl4x/number_format.dart';
void main() {
- final numberFormat = NumberFormat.percent(locale: Locale.parse('en-US'));
+ final locale = Locale.parse('en-US');
- print(numberFormat.format(0.5)); // prints 50%
+ final compactFormat = NumberFormat.compact(locale: locale);
+ print(compactFormat.format(12345)); // "12K"
+
+ final percentFormat = NumberFormat.percent(locale: locale);
+ print(percentFormat.format(0.987)); // "99%"
}
```
-## Installation
+### Collation (String Sorting)
-The easiest setup is
+Sort lists of strings with locale-aware collation.
+
+```dart
+import 'package:intl4x/collation.dart';
+
+void main() {
+ final list = ['Z', 'a', 'z', 'ä'];
+ final german = Collation(locale: Locale.parse('de-DE'));
+
+ list.sort(german.compare);
+
+ print(list); // prints "[a, ä, z, Z]"
+}
```
-dart pub add intl4x
-dart run ...
+
+### Display Names
+
+Get localized display names for locales, regions, scripts, and currencies.
+
+```dart
+import 'package:intl4x/display_names.dart';
+
+void main() {
+ final displayNames = DisplayNames(locale: Locale.parse('en'));
+
+ print(displayNames.ofLocale(Locale.parse('fr-CA'))); // "Canadian French"
+ print(displayNames.ofRegion('419')); // "Latin America"
+}
```
-This will download the binaries from Github
+
+### List Formatting
+
+Join lists of items into a grammatically correct, locale-sensitive string.
+
+```dart
+import 'package:intl4x/list_format.dart';
+
+void main() {
+ final list = ['apples', 'bananas', 'oranges'];
+ final english = Locale.parse('en');
+
+ print(list.joinAnd(locale: english)); // "apples, bananas, and oranges"
+ print(list.joinOr(locale: english)); // "apples, bananas, or oranges"
+}
+```
+
+### Plural Rules
+
+Select the correct plural category for a given number based on locale rules (e.g., `one`, `few`, `many`).
+
+```dart
+import 'package:intl4x/plural_rules.dart';
+
+void main() {
+ final rules = PluralRules(
+ locale: Locale.parse('en-US'),
+ type: PluralType.ordinal,
+ );
+
+ print(rules.select(1)); // PluralCategory.one (st)
+ print(rules.select(2)); // PluralCategory.two (nd)
+ print(rules.select(3)); // PluralCategory.few (rd)
+ print(rules.select(4)); // PluralCategory.other (th)
+}
+```
+
+### Case Mapping
+
+Change the case of strings according to locale-specific rules.
+
+```dart
+import 'package:intl4x/case_mapping.dart';
+
+void main() {
+ final tr = Locale.parse('tr');
+ final en = Locale.parse('en');
+
+ final upper = 'TICKET';
+ print(upper.toLocaleLowerCase(en)); // ticket
+ print(upper.toLocaleLowerCase(tr)); // tıcket
+
+ final lower = 'i';
+ print(lower.toLocaleUpperCase(en)); // I
+ print(lower.toLocaleUpperCase(tr)); // İ
+}
+```
\ No newline at end of file
diff --git a/pkgs/intl4x/example/.gitignore b/pkgs/intl4x/example/.gitignore
deleted file mode 100644
index 4dda46f..0000000
--- a/pkgs/intl4x/example/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-# https://dart.dev/guides/libraries/private-files
-# Created by `dart pub`
-.dart_tool/
-build/
diff --git a/pkgs/intl4x/example/analysis_options.yaml b/pkgs/intl4x/example/analysis_options.yaml
deleted file mode 100644
index 81aa71c..0000000
--- a/pkgs/intl4x/example/analysis_options.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-include: package:dart_flutter_team_lints/analysis_options.yaml
-
-linter:
- rules:
- - prefer_relative_imports
diff --git a/pkgs/intl4x/example/bin/example.dart b/pkgs/intl4x/example/example.dart
similarity index 100%
rename from pkgs/intl4x/example/bin/example.dart
rename to pkgs/intl4x/example/example.dart
diff --git a/pkgs/intl4x/example/pubspec.yaml b/pkgs/intl4x/example/pubspec.yaml
deleted file mode 100644
index 9708bd4..0000000
--- a/pkgs/intl4x/example/pubspec.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-name: example
-description: A sample application using intl4x.
-
-environment:
- sdk: ^3.9.3
-
-publish_to: none
-
-dependencies:
- intl4x:
- path: ../
-
-dev_dependencies:
- dart_flutter_team_lints: ^3.0.0
diff --git a/pkgs/intl4x/lib/case_mapping.dart b/pkgs/intl4x/lib/case_mapping.dart
index 8f5d6fa..60e6746 100644
--- a/pkgs/intl4x/lib/case_mapping.dart
+++ b/pkgs/intl4x/lib/case_mapping.dart
@@ -8,14 +8,20 @@
/// based on the current locale.
///
/// ```dart
-/// import 'package:intl4x/case_mapping.dart';
+///import 'package:intl4x/case_mapping.dart';
///
-/// void main() {
-/// print('i'.toLocaleUpperCase()); // Prints 'İ'
+///void main() {
+/// final tr = Locale.parse('tr');
+/// final en = Locale.parse('en');
///
-/// final caseMapping = CaseMapping(locale: Locale('tr'));
-/// print(caseMapping.toUpperCase('i')); // Prints 'İ'
-/// }
+/// final upper = 'TICKET';
+/// print(upper.toLocaleLowerCase(en)); // ticket
+/// print(upper.toLocaleLowerCase(tr)); // tıcket
+///
+/// final lower = 'i';
+/// print(lower.toLocaleUpperCase(en)); // I
+/// print(lower.toLocaleUpperCase(tr)); // İ
+///}
/// ```
/// Available either as an extension on [String], or through the
/// [CaseMapping] class.
diff --git a/pkgs/intl4x/lib/collation.dart b/pkgs/intl4x/lib/collation.dart
index 878dbb2..01162cf 100644
--- a/pkgs/intl4x/lib/collation.dart
+++ b/pkgs/intl4x/lib/collation.dart
@@ -4,9 +4,6 @@
/// Provides locale-sensitive string comparison.
///
-/// Available either as an extension on [String], or through the
-/// [Collation] class.
-///
/// ```dart
/// import 'package:intl4x/collation.dart';
///
@@ -21,6 +18,9 @@
/// print(list); // Prints [a, b, ä]
/// }
/// ```
+///
+/// Available either as an extension on [String], or through the
+/// [Collation] class.
library;
import 'src/collation/collation.dart' show Collation;
diff --git a/pkgs/intl4x/lib/datetime_format.dart b/pkgs/intl4x/lib/datetime_format.dart
index a683866..ef3e473 100644
--- a/pkgs/intl4x/lib/datetime_format.dart
+++ b/pkgs/intl4x/lib/datetime_format.dart
@@ -2,6 +2,52 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+/// Locale-sensitive date and time formatting.
+///
+/// Use the [DateTimeFormat] class to format dates and times in a
+/// locale-sensitive manner.
+///
+/// ```dart
+/// import 'package:intl4x/datetime_format.dart';
+///
+/// void main() {
+/// final timeZone = 'Europe/Paris';
+/// final dateTime = DateTime.parse('2024-07-01T08:50:07');
+///
+/// final formatter = DateTimeFormat.yearMonthDayTime(
+/// locale: Locale.parse('en'),
+/// length: DateTimeLength.long,
+/// ).withTimeZoneShort();
+/// print(
+/// formatter.format(dateTime, timeZone),
+/// ); // prints 'July 1, 2024 at 8:50:07 AM GMT+2'
+/// }
+/// ```
+///
+/// The formatters are
+/// * [DateTimeFormat.day]
+/// * [DateTimeFormat.month]
+/// * [DateTimeFormat.monthDay]
+/// * [DateTimeFormat.monthDayTime]
+/// * [DateTimeFormat.year]
+/// * [DateTimeFormat.yearMonthDay]
+/// * [DateTimeFormat.yearMonthDayTime]
+/// * [DateTimeFormat.yearMonthDayWeekday]
+/// * [DateTimeFormat.yearMonthDayWeekdayTime]
+/// * [DateTimeFormat.time]
+///
+/// and the zoned variants through
+/// * [DateTimeFormatter.withTimeZoneShort]
+/// * [DateTimeFormatter.withTimeZoneLong]
+/// * [DateTimeFormatter.withTimeZoneShortOffset]
+/// * [DateTimeFormatter.withTimeZoneLongOffset]
+/// * [DateTimeFormatter.withTimeZoneShortGeneric]
+/// * [DateTimeFormatter.withTimeZoneLongGeneric]
+library;
+
+import 'src/datetime_format/datetime_format.dart' show DateTimeFormat;
+import 'src/datetime_format/datetime_format_impl.dart' show DateTimeFormatter;
+
export 'src/datetime_format/datetime_format.dart' show DateTimeFormat;
export 'src/datetime_format/datetime_format_impl.dart'
show DateTimeFormatter, ZonedDateTimeFormatter;
diff --git a/pkgs/intl4x/lib/number_format.dart b/pkgs/intl4x/lib/number_format.dart
index ce75f16..40a5706 100644
--- a/pkgs/intl4x/lib/number_format.dart
+++ b/pkgs/intl4x/lib/number_format.dart
@@ -2,6 +2,29 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+/// Provides locale-sensitive number formatting.
+///
+/// Use the [NumberFormat] class to format numbers in a locale-sensitive
+/// manner.
+///
+/// ```dart
+/// import 'package:intl4x/number_format.dart';
+///
+/// void main() {
+/// print(
+/// NumberFormat(
+/// locale: Locale.parse('en'),
+/// roundingMode: RoundingMode.ceil,
+/// digits: const Digits.withFractionDigits(maximum: 1),
+/// ).format(3.14),
+/// ); // prints '3.2'
+/// }
+///
+/// ```
+library;
+
+import 'src/number_format/number_format.dart' show NumberFormat;
+
export 'src/locale/locale.dart' show Locale;
export 'src/number_format/number_format.dart' show NumberFormat;
export 'src/number_format/number_format_options.dart'
diff --git a/pkgs/intl4x/lib/plural_rules.dart b/pkgs/intl4x/lib/plural_rules.dart
index 809ce27..e50f71c 100644
--- a/pkgs/intl4x/lib/plural_rules.dart
+++ b/pkgs/intl4x/lib/plural_rules.dart
@@ -2,6 +2,26 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+/// The appropriate locale-dependent plural form.
+///
+/// The [PluralRules] object returns the [PluralCategory] of the input [num]
+/// to [PluralRules.select]. While English only uses 'one' and 'other', other
+/// languages have more plural forms. For example, Arabic uses 'zero', 'one',
+/// 'two', 'few', 'many', and 'other'.
+///
+/// Example:
+/// ```dart
+/// import 'package:intl4x/plural_rules.dart';
+///
+/// void main() {
+/// final rules = PluralRules(locale: Locale.parse('en-US'));
+/// print(rules.select(3)); // prints 'PluralCategory.other'
+/// }
+/// ```
+library;
+
+import 'src/plural_rules/plural_rules.dart' show PluralCategory, PluralRules;
+
export 'src/locale/locale.dart' show Locale;
export 'src/plural_rules/plural_rules.dart' show PluralCategory, PluralRules;
export 'src/plural_rules/plural_rules_options.dart'
diff --git a/pkgs/intl4x/lib/src/datetime_format/datetime_format.dart b/pkgs/intl4x/lib/src/datetime_format/datetime_format.dart
index adbc80d..e74d2ac 100644
--- a/pkgs/intl4x/lib/src/datetime_format/datetime_format.dart
+++ b/pkgs/intl4x/lib/src/datetime_format/datetime_format.dart
@@ -18,7 +18,7 @@
/// import 'package:intl4x/datetime_format.dart';
///
/// void main() {
-/// final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
+/// final date = DateTime(2021, 12, 17, 4, 0, 42);
/// print(DateTimeFormat.time(locale: Locale.parse('fr')).format(date));
/// // Output: '04:00'
/// }
@@ -31,7 +31,7 @@
/// import 'package:intl4x/datetime_format.dart';
///
/// void main() {
- /// final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
+ /// final date = DateTime(2021, 12, 17, 4, 0, 42);
/// print(DateTimeFormat.day().format(date)); // Output: '17'
/// }
/// ```
@@ -50,7 +50,7 @@
/// import 'package:intl4x/datetime_format.dart';
///
/// void main() {
- /// final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
+ /// final date = DateTime(2021, 12, 17, 4, 0, 42);
/// print(DateTimeFormat.month().format(date)); // Output: 'Dec'
/// }
/// ```
@@ -69,7 +69,7 @@
/// import 'package:intl4x/datetime_format.dart';
///
/// void main() {
- /// final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
+ /// final date = DateTime(2021, 12, 17, 4, 0, 42);
/// print(DateTimeFormat.monthDay().format(date)); // Output: 'Dec 17'
/// }
/// ```
@@ -88,7 +88,7 @@
/// import 'package:intl4x/datetime_format.dart';
///
/// void main() {
- /// final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
+ /// final date = DateTime(2021, 12, 17, 4, 0, 42);
/// print(DateTimeFormat.year().format(date)); // Output: '2021'
/// }
/// ```
@@ -108,7 +108,7 @@
/// import 'package:intl4x/datetime_format.dart';
///
/// void main() {
- /// final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
+ /// final date = DateTime(2021, 12, 17, 4, 0, 42);
/// print(DateTimeFormat.yearMonthDay().format(date)); // Output: 'Dec 17, 2021'
/// }
/// ```
@@ -128,7 +128,7 @@
/// import 'package:intl4x/datetime_format.dart';
///
/// void main() {
- /// final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
+ /// final date = DateTime(2021, 12, 17, 4, 0, 42);
/// print(DateTimeFormat.yearMonthDayWeekday().format(date)); // Output: 'Fri, Dec 17, 2021'
/// }
/// ```
@@ -148,7 +148,7 @@
/// import 'package:intl4x/datetime_format.dart';
///
/// void main() {
- /// final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
+ /// final date = DateTime(2021, 12, 17, 4, 0, 42);
/// print(DateTimeFormat.monthDayTime().format(date)); // Output: 'Dec 17, 4:00 AM'
/// }
/// ```
@@ -168,7 +168,7 @@
/// import 'package:intl4x/datetime_format.dart';
///
/// void main() {
- /// final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
+ /// final date = DateTime(2021, 12, 17, 4, 0, 42);
/// print(DateTimeFormat.yearMonthDayTime().format(date)); // Output: 'Dec 17, 2021, 4:00 AM'
/// }
/// ```
@@ -192,7 +192,7 @@
/// import 'package:intl4x/datetime_format.dart';
///
/// void main() {
- /// final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
+ /// final date = DateTime(2021, 12, 17, 4, 0, 42);
/// print(DateTimeFormat.yearMonthDayWeekdayTime().format(date)); // Output: 'Fri, Dec 17, 2021, 4:00 AM'
/// }
/// ```
@@ -216,7 +216,7 @@
/// import 'package:intl4x/datetime_format.dart';
///
/// void main() {
- /// final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
+ /// final date = DateTime(2021, 12, 17, 4, 0, 42);
/// print(DateTimeFormat.time().format(date)); // Output: '4:00 AM'
/// }
/// ```
diff --git a/pkgs/intl4x/lib/src/number_format/number_format.dart b/pkgs/intl4x/lib/src/number_format/number_format.dart
index 74b4e0e..7ea073a 100644
--- a/pkgs/intl4x/lib/src/number_format/number_format.dart
+++ b/pkgs/intl4x/lib/src/number_format/number_format.dart
@@ -86,6 +86,8 @@
/// Creates a [NumberFormat] instance for compact number formatting.
///
+ /// WARNING: Not implemented on native yet.
+ ///
/// Compact notation is a way to format numbers that are very large or very
/// small in a more human-readable way, e.g., "1.2M" instead of "1,200,000".
///
@@ -116,6 +118,7 @@
/// print(NumberFormat.compact().format(1234567)); // Prints '1.2M'
/// }
/// ```
+ //TODO: implement in ICU4X
NumberFormat.compact({
Locale? locale,
CompactDisplay compactDisplay = CompactDisplay.short,
@@ -145,6 +148,8 @@
/// Creates a [NumberFormat] instance for percent formatting.
///
+ /// WARNING: Not implemented on native yet.
+ ///
/// * [locale]: The locale to use for formatting. Defaults to the system
/// locale.
/// * [signDisplay]: When to display the sign for the number. Defaults to
@@ -170,6 +175,7 @@
/// print(NumberFormat.percent().format(0.5)); // Prints '50%'
/// }
/// ```
+ //TODO: Implement in ICU4X
NumberFormat.percent({
Locale? locale,
SignDisplay signDisplay = SignDisplay.auto,
@@ -196,6 +202,8 @@
/// Creates a [NumberFormat] instance for currency formatting.
///
+ /// WARNING: Not implemented on native yet.
+ ///
/// * [locale]: The locale to use for formatting. Defaults to the system
/// locale.
/// * [currency]: The 3-letter ISO 4217 currency code (e.g., 'USD') to use.
diff --git a/pkgs/intl4x/pubspec.yaml b/pkgs/intl4x/pubspec.yaml
index 0353ee7..a1e00b5 100644
--- a/pkgs/intl4x/pubspec.yaml
+++ b/pkgs/intl4x/pubspec.yaml
@@ -30,5 +30,5 @@
dev_dependencies:
args: ^2.7.0
dart_flutter_team_lints: ^3.5.2
- dart_style: ^3.1.2
- test: ^1.26.3
+ dart_style: ^3.1.3
+ test: ^1.28.0
diff --git a/pkgs/intl4x/test/plural_rules_test.dart b/pkgs/intl4x/test/plural_rules_test.dart
index 436ba46..f79774c 100644
--- a/pkgs/intl4x/test/plural_rules_test.dart
+++ b/pkgs/intl4x/test/plural_rules_test.dart
@@ -8,35 +8,35 @@
void main() {
testWithFormatting('en-US simple', () {
- final numberFormatOptions = PluralRules(locale: Locale.parse('en-US'));
+ final rules = PluralRules(locale: Locale.parse('en-US'));
- expect(numberFormatOptions.select(0), PluralCategory.other);
- expect(numberFormatOptions.select(1), PluralCategory.one);
- expect(numberFormatOptions.select(2), PluralCategory.other);
- expect(numberFormatOptions.select(3), PluralCategory.other);
+ expect(rules.select(0), PluralCategory.other);
+ expect(rules.select(1), PluralCategory.one);
+ expect(rules.select(2), PluralCategory.other);
+ expect(rules.select(3), PluralCategory.other);
});
testWithFormatting('ar-EG simple', () {
- final numberFormatOptions = PluralRules(locale: Locale.parse('ar-EG'));
+ final rules = PluralRules(locale: Locale.parse('ar-EG'));
- expect(numberFormatOptions.select(0), PluralCategory.zero);
- expect(numberFormatOptions.select(1), PluralCategory.one);
- expect(numberFormatOptions.select(2), PluralCategory.two);
- expect(numberFormatOptions.select(6), PluralCategory.few);
- expect(numberFormatOptions.select(18), PluralCategory.many);
+ expect(rules.select(0), PluralCategory.zero);
+ expect(rules.select(1), PluralCategory.one);
+ expect(rules.select(2), PluralCategory.two);
+ expect(rules.select(6), PluralCategory.few);
+ expect(rules.select(18), PluralCategory.many);
});
testWithFormatting('en-US ordinal', () {
- final numberFormatOptions = PluralRules(
+ final rules = PluralRules(
locale: Locale.parse('en-US'),
type: PluralType.ordinal,
);
- expect(numberFormatOptions.select(0), PluralCategory.other);
- expect(numberFormatOptions.select(1), PluralCategory.one);
- expect(numberFormatOptions.select(2), PluralCategory.two);
- expect(numberFormatOptions.select(3), PluralCategory.few);
- expect(numberFormatOptions.select(4), PluralCategory.other);
- expect(numberFormatOptions.select(21), PluralCategory.one);
+ expect(rules.select(0), PluralCategory.other);
+ expect(rules.select(1), PluralCategory.one);
+ expect(rules.select(2), PluralCategory.two);
+ expect(rules.select(3), PluralCategory.few);
+ expect(rules.select(4), PluralCategory.other);
+ expect(rules.select(21), PluralCategory.one);
});
}