Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
7c37eb1
add js timezone parsing
mosuem Nov 5, 2025
800fa3d
Switch icu4x and ecma to use timezones
mosuem Nov 5, 2025
da4cca2
fix timezone calculation time
mosuem Nov 5, 2025
73a9c25
fixes
mosuem Nov 5, 2025
fc55e53
extract
mosuem Nov 5, 2025
ecd334e
Fixes
mosuem Nov 5, 2025
bba848b
fixes
mosuem Nov 5, 2025
44834d6
extract casemapping
mosuem Nov 6, 2025
c25c00c
extract collation
mosuem Nov 6, 2025
c2e4f1b
extract listformat
mosuem Nov 6, 2025
a6c8a06
extract pluralrules
mosuem Nov 6, 2025
cadc5c7
extract DisplayNames
mosuem Nov 6, 2025
278eb01
extract Numberformat
mosuem Nov 6, 2025
f2620ef
extract Datetimeformat
mosuem Nov 6, 2025
4f4ef6f
rename
mosuem Nov 6, 2025
7bf5e2a
export all
mosuem Nov 6, 2025
460cd23
remove intl4x entrypoint
mosuem Nov 6, 2025
a55c3d4
replace checkmarks
mosuem Nov 6, 2025
793e362
more smaller changes
mosuem Nov 6, 2025
7f1aed6
more small changes
mosuem Nov 6, 2025
26a7252
merge mess
mosuem Nov 6, 2025
40d0c76
fix import
mosuem Nov 11, 2025
e03fa61
Datetime overhaul, needs remapping of options
mosuem Nov 11, 2025
2857551
more test fixes
mosuem Nov 11, 2025
296951d
add set extension
mosuem Nov 11, 2025
fd6a16c
tests work
mosuem Nov 13, 2025
c1a0bf0
apply fix
mosuem Nov 13, 2025
8b121e9
Work on fixing
mosuem Nov 13, 2025
bffed6e
ymdet looking good
mosuem Nov 13, 2025
a7cda77
Getting better and better now
mosuem Nov 13, 2025
cd51d8b
update
mosuem Nov 13, 2025
c3af2ba
Many tests
mosuem Nov 13, 2025
67ac5cc
fixes
mosuem Nov 13, 2025
00f3cd0
works
mosuem Nov 14, 2025
a799009
Full conformance testing
mosuem Nov 14, 2025
90673cf
Fix collation
mosuem Nov 17, 2025
349356d
comment out unused
mosuem Nov 17, 2025
ae2002b
Update display names
mosuem Nov 18, 2025
cb7e904
fix listformat
mosuem Nov 18, 2025
7289c83
fix plural rules
mosuem Nov 18, 2025
a612fb7
fixes and formats
mosuem Nov 18, 2025
3bcdcfa
rename
mosuem Nov 18, 2025
681a585
fix example
mosuem Nov 18, 2025
94eafc2
fix numberformatter
mosuem Nov 18, 2025
472eba6
export fixes
mosuem Nov 18, 2025
a5ff0d2
start adding docs
mosuem Nov 18, 2025
dcee5f6
add some docs
mosuem Nov 18, 2025
f632e8f
more docs
mosuem Nov 18, 2025
686d86a
more docs
mosuem Nov 18, 2025
d76db90
imports
mosuem Nov 18, 2025
660445c
fix imports
mosuem Nov 19, 2025
747d5f1
Renamings and more small fixes
mosuem Nov 19, 2025
afd7f0e
Renamings and more small fixes
mosuem Nov 19, 2025
fab9287
docs
mosuem Nov 19, 2025
d425a63
renaming
mosuem Nov 19, 2025
6038a47
add changelog
mosuem Nov 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ pkgs/intl/test/number_format_compact_google3_icu_test.dart
pkgs/intl/update_from_cldr_data.sh

.vscode

doc/
10 changes: 10 additions & 0 deletions pkgs/intl4x/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 0.15.0

- API overhaul:
- Getting rid of the Intl object, as it only served as a wrapper of Locale. So the ...Format objects are now the top-level things.
- 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!)
- Remove some methods which are not implemented in ICU4X

## 0.14.0

- Change timezone API, adding a dependency on package:timezone.
Expand Down
7 changes: 4 additions & 3 deletions pkgs/intl4x/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ A lightweight modular library for internationalization (i18n) functionality.
* Formatting for dates, numbers, and lists.
* Collation.
* Display names.
* Plural rules.

## 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)).

| | Number format | List format | Date format | Collation | Display names | Plural Rules | Case mapping |
| | Number format | List format | Date format | Collation | Display names | Plural rules | Case mapping |
|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| **ECMA402 (web)** | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| **ICU4X (web/native)** | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| **ECMA402 (web)** | | | | | | | |
| **ICU4X (web/native)** | | | | | | | |

## Implementation and Goals

Expand Down
6 changes: 3 additions & 3 deletions pkgs/intl4x/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ include: package:dart_flutter_team_lints/analysis_options.yaml

linter:
rules:
- conditional_uri_does_not_exist
- prefer_const_constructors
- prefer_final_locals
- prefer_relative_imports
- unnecessary_parenthesis
- prefer_expression_function_bodies
- document_ignores
- parameter_assignments
5 changes: 5 additions & 0 deletions pkgs/intl4x/dart_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ tags:
vm:
skip: "Not implemented in ICU4X yet. Use -P force to force tests."
presets: { force: { skip: false } }
ecmaUnsupported:
on_platform:
browser:
skip: "Either unimplemented or buggy on the browser."
presets: { force: { skip: false } }
16 changes: 8 additions & 8 deletions pkgs/intl4x/example/bin/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:intl4x/datetime_format.dart';
import 'package:intl4x/intl4x.dart';
import 'package:intl4x/number_format.dart';

void main(List<String> arguments) {
final timeZone = 'Europe/Paris';
final dateTime = DateTime.parse('2024-07-01T08:50:07');

print(Intl().locale.toString());
print(Locale.system);

print(Intl().dateTimeFormat().d().format(DateTime.now()));
print(NumberFormat.compact().format(3.14));

final withTimeZoneLong = Intl(locale: Locale.parse('en'))
.dateTimeFormat()
.ymdt(dateStyle: DateFormatStyle.full, timeStyle: TimeFormatStyle.short)
.withTimeZoneLong();
print(withTimeZoneLong.format(dateTime, timeZone));
final formatter = DateTimeFormat.yearMonthDayTime(
locale: Locale.parse('en'),
length: DateTimeLength.long,
).withTimeZoneLong();
print(formatter.format(dateTime, timeZone));
}
9 changes: 5 additions & 4 deletions pkgs/intl4x/lib/case_mapping.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// 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.

import 'intl4x.dart';
import 'src/case_mapping/case_mapping.dart';
import 'src/locale/locale.dart' show Locale;

export 'src/case_mapping/case_mapping.dart' show CaseMapping;
export 'src/locale/locale.dart';
export 'src/locale/locale.dart' show Locale;

extension CaseMappingWithIntl4X on String {
String toLocaleLowerCase(Locale locale) =>
Intl(locale: locale).caseMapping.toLowerCase(this);
CaseMapping(locale: locale).toLowerCase(this);
String toLocaleUpperCase(Locale locale) =>
Intl(locale: locale).caseMapping.toUpperCase(this);
CaseMapping(locale: locale).toUpperCase(this);
}
12 changes: 7 additions & 5 deletions pkgs/intl4x/lib/collation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
// 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.

import 'intl4x.dart';
import 'src/collation/collation.dart' show Collation;
import 'src/locale/locale.dart' show Locale;

export 'src/collation/collation.dart' show Collation;
export 'src/collation/collation_options.dart';
export 'src/options.dart';
export 'src/collation/collation_options.dart'
show CaseFirst, Sensitivity, Usage;
export 'src/locale/locale.dart' show Locale;

extension CollationExt on String {
/// Compare two strings in a locale-dependent manner.
///
/// For more options, use [Intl.collation] directly.
/// For more options, use [Collation] directly.
int compareLocale(String other, {Locale? locale}) =>
Intl(locale: locale).collation().compare(this, other);
Collation(locale: locale).compare(this, other);
}
16 changes: 13 additions & 3 deletions pkgs/intl4x/lib/datetime_format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@
// 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.

export 'src/datetime_format/datetime_format.dart' show DateTimeFormatBuilder;
export 'src/datetime_format/datetime_format.dart' show DateTimeFormat;
export 'src/datetime_format/datetime_format_impl.dart'
show DateTimeFormatter, ZonedDateTimeFormatter;
export 'src/datetime_format/datetime_format_options.dart';
export 'src/options.dart';
export 'src/datetime_format/datetime_format_options.dart'
show
Calendar,
ClockStyle,
DateTimeAlignment,
DateTimeLength,
EnumComparisonOperators,
NumberingSystem,
TimePrecision,
TimeZoneType,
YearStyle;
export 'src/locale/locale.dart' show Locale;
38 changes: 36 additions & 2 deletions pkgs/intl4x/lib/display_names.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@
// 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.

/// Formatting names in different locales.
///
/// For a given [Locale], show the name of some information in that locale.
/// Provides several options as part of the [DisplayNames] constructor, such as
/// [Style], [LanguageDisplay], or [Fallback].
///
/// Languages:
/// ```dart
/// // Display the name of the language German in English
/// DisplayNames(locale: Locale.parse('en-US'))
/// .ofLanguage(Locale.parse('de-DE')); // German (Germany)
///
/// // Display the name of the language French in Chinese
/// DisplayNames(locale: Locale.parse('zh-Hant'))
/// .ofLanguage(Locale.parse('fr')); // 法文
/// ```
///
/// Regions:
/// ```dart
/// // Display the name of the region es-419, Latin America, in English
/// DisplayNames(locale: Locale.parse('en'))
/// .ofRegion('419'); // Latin America
///
/// // Display the name of the region Germany in Spanish
/// DisplayNames(locale: Locale.parse('es-419'))
/// .ofLanguage(Locale.parse('de')); // Alemania
Comment on lines +29 to +30

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This example seems to have a copy-paste error. To get the name of the region 'Germany' in Spanish, you should use ofRegion('DE'). The current code ofLanguage(Locale.parse('de')) would return the name of the German language ('alemán'), not the region name ('Alemania').

/// DisplayNames(locale: Locale.parse('es-419'))
///   .ofRegion('DE'); // Alemania

/// ```
///
///
library;

import 'display_names.dart';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This self-import is unnecessary and can be removed.


export 'src/display_names/display_names.dart' show DisplayNames;
export 'src/display_names/display_names_options.dart';
export 'src/options.dart';
export 'src/display_names/display_names_options.dart'
show DisplayType, Fallback, LanguageDisplay, Style;
export 'src/locale/locale.dart' show Locale;
76 changes: 0 additions & 76 deletions pkgs/intl4x/lib/intl4x.dart

This file was deleted.

36 changes: 17 additions & 19 deletions pkgs/intl4x/lib/list_format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,36 @@
// 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.

import 'intl4x.dart';
import 'list_format.dart';
import 'src/list_format/list_format.dart';
import 'src/list_format/list_format_options.dart';
import 'src/locale/locale.dart' show Locale;

export 'src/list_format/list_format.dart' show ListFormat;
export 'src/list_format/list_format_options.dart';
export 'src/options.dart';
export 'src/list_format/list_format_options.dart' show ListStyle, ListType;
export 'src/locale/locale.dart' show Locale;

extension ListFormatIntl4x on List<String> {
/// Join a list in a locale-dependent manner using `and`-based grouping.
///
/// Example: "A, B, and C". See also [Type.and].
/// Example: "A, B, and C". See also [ListType.and].
///
/// For more options, use [Intl.listFormat] directly.
String joinAnd({Locale? locale}) => Intl(
locale: locale,
).listFormat(const ListFormatOptions(type: Type.and)).format(this);
/// For more options, use [ListFormat] directly.
String joinAnd({Locale? locale}) =>
ListFormat(locale: locale, type: ListType.and).format(this);

/// Join a list in a locale-dependent manner using `or`-based grouping.
///
/// Example: "A, B, or C". See also [Type.or].
/// Example: "A, B, or C". See also [ListType.or].
///
/// For more options, use [Intl.listFormat] directly.
String joinOr({Locale? locale}) => Intl(
locale: locale,
).listFormat(const ListFormatOptions(type: Type.or)).format(this);
/// For more options, use [ListFormat] directly.
String joinOr({Locale? locale}) =>
ListFormat(locale: locale, type: ListType.or).format(this);

/// Join a list in a locale-dependent manner using unit-based grouping.
///
/// Example: "A, B, C". See also [Type.unit].
/// Example: "A, B, C". See also [ListType.unit].
///
/// For more options, use [Intl.listFormat] directly.
String joinUnit({Locale? locale}) => Intl(
locale: locale,
).listFormat(const ListFormatOptions(type: Type.unit)).format(this);
/// For more options, use [ListFormat] directly.
String joinUnit({Locale? locale}) =>
ListFormat(locale: locale, type: ListType.unit).format(this);
}
28 changes: 26 additions & 2 deletions pkgs/intl4x/lib/number_format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@
// 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.

export 'src/locale/locale.dart' show Locale;
export 'src/number_format/number_format.dart' show NumberFormat;
export 'src/number_format/number_format_options.dart';
export 'src/options.dart';
export 'src/number_format/number_format_options.dart'
show
CompactDisplay,
CompactNotation,
CurrencyDisplay,
CurrencySign,
CurrencyStyle,
DecimalStyle,
Digits,
EngineeringNotation,
FormatStyle,
FractionDigits,
Grouping,
Notation,
PercentStyle,
RoundingMode,
RoundingPriority,
ScientificNotation,
SignDisplay,
SignificantDigits,
StandardNotation,
TrailingZeroDisplay,
Unit,
UnitDisplay,
UnitStyle;
5 changes: 3 additions & 2 deletions pkgs/intl4x/lib/plural_rules.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// 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.

export 'src/options.dart';
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';
export 'src/plural_rules/plural_rules_options.dart'
show Digits, PluralType, RoundingMode, TrailingZeroDisplay;
Loading
Loading