File tree Expand file tree Collapse file tree 4 files changed +28
-34
lines changed Expand file tree Collapse file tree 4 files changed +28
-34
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.10.2-wip
2
+
3
+ - Remove Dart parser of locale strings.
4
+
1
5
## 0.10.1
2
6
3
7
- Upgrade to new artifacts.
Original file line number Diff line number Diff line change 5
5
import '../bindings/lib.g.dart' as icu;
6
6
7
7
import 'locale.dart' ;
8
+ import 'locale_native.dart' ;
8
9
9
- extension Locale4X on Locale {
10
+ extension Locale4XTransformer on Locale {
10
11
icu.Locale to4X () {
11
- final icu4xLocale = icu.Locale .und ()..language = language;
12
- if (region != null ) icu4xLocale.region = region! ;
13
- if (script != null ) icu4xLocale.script = script! ;
14
- return icu4xLocale;
12
+ if (this is IcuLocale ) {
13
+ return (this as IcuLocale ).locale;
14
+ } else {
15
+ final icu4xLocale = icu.Locale .und ()..language = language;
16
+ if (region != null ) icu4xLocale.region = region! ;
17
+ if (script != null ) icu4xLocale.script = script! ;
18
+ return icu4xLocale;
19
+ }
15
20
}
16
21
}
Original file line number Diff line number Diff line change 2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
+ import '../bindings/lib.g.dart' as icu;
5
6
import 'locale.dart' ;
6
7
7
8
/// This file should be replaced by references to ICU4X when ready.
8
9
9
- Locale parseLocaleWithSeparatorPlaceholder (String s, [String separator = '-' ]) {
10
- final parsed = s.split (separator);
11
- // ignore: unused_local_variable
12
- final subtags = parsed.skipWhile ((value) => value != 'u' ).toList ();
13
- final tags = parsed.takeWhile ((value) => value != 'u' ).toList ();
14
- final language = tags.first;
15
- final String ? script;
16
- final String ? region;
17
- if (tags.length == 2 ) {
18
- if (tags[1 ].length == 2 && tags[1 ] == tags[1 ].toUpperCase ()) {
19
- region = tags[1 ];
20
- script = null ;
21
- } else {
22
- region = null ;
23
- script = tags[1 ];
24
- }
25
- } else if (tags.length == 3 ) {
26
- script = tags[1 ];
27
- region = tags[2 ];
28
- } else {
29
- script = null ;
30
- region = null ;
31
- }
10
+ class IcuLocale extends Locale {
11
+ final icu.Locale locale;
32
12
33
- return Locale (
34
- language: language,
35
- region: region,
36
- script: script,
37
- );
13
+ IcuLocale (this .locale)
14
+ : super (
15
+ language: locale.language,
16
+ region: locale.region,
17
+ script: locale.script,
18
+ );
38
19
}
39
20
21
+ Locale parseLocaleWithSeparatorPlaceholder (String s,
22
+ [String separator = '-' ]) =>
23
+ IcuLocale (icu.Locale .fromString (s));
24
+
40
25
//TODO: Switch to ICU4X!
41
26
Locale parseLocale (String s, [String separator = '-' ]) {
42
27
if (s.contains ('_' )) {
Original file line number Diff line number Diff line change 1
1
name : intl4x
2
2
description : >-
3
3
A lightweight modular library for internationalization (i18n) functionality.
4
- version : 0.10.1
4
+ version : 0.10.2-wip
5
5
repository : https://github.com/dart-lang/i18n/tree/main/pkgs/intl4x
6
6
platforms :
7
7
web :
You can’t perform that action at this time.
0 commit comments