Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f8d73be8
Unverified
Commit
f8d73be8
authored
Jun 16, 2021
by
greymag
Committed by
GitHub
Jun 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove stripping scriptCodes for localization. (#83903)
parent
430bfac4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
20 deletions
+17
-20
date_localizations.dart
...utter_localizations/lib/src/utils/date_localizations.dart
+0
-20
date_time_test.dart
...s/flutter_localizations/test/material/date_time_test.dart
+17
-0
No files found.
packages/flutter_localizations/lib/src/utils/date_localizations.dart
View file @
f8d73be8
...
...
@@ -16,29 +16,9 @@ bool _dateIntlDataInitialized = false;
/// invocations have no effect.
void
loadDateIntlDataIfNotLoaded
(
)
{
if
(!
_dateIntlDataInitialized
)
{
// TODO(garyq): Add support for scriptCodes. Do not strip scriptCode from string.
// Keeps track of initialized locales. This can only happen if a locale
// with a stripped scriptCode has already been initialized. The set of
// initialized locales should be removed when scriptCode stripping is
// removed.
final
Set
<
String
>
initializedLocales
=
<
String
>{};
date_localizations
.
dateSymbols
.
cast
<
String
,
Map
<
String
,
dynamic
>>()
.
forEach
((
String
locale
,
Map
<
String
,
dynamic
>
data
)
{
// Strip scriptCode from the locale, as we do not distinguish between scripts
// for dates.
final
List
<
String
>
codes
=
locale
.
split
(
'_'
);
String
?
countryCode
;
if
(
codes
.
length
==
2
)
{
countryCode
=
codes
[
1
].
length
<
4
?
codes
[
1
]
:
null
;
}
else
if
(
codes
.
length
==
3
)
{
countryCode
=
codes
[
1
].
length
<
codes
[
2
].
length
?
codes
[
1
]
:
codes
[
2
];
}
locale
=
codes
[
0
]
+
(
countryCode
!=
null
?
'_
$countryCode
'
:
''
);
if
(
initializedLocales
.
contains
(
locale
))
return
;
initializedLocales
.
add
(
locale
);
// Perform initialization.
assert
(
date_localizations
.
datePatterns
.
containsKey
(
locale
));
final
intl
.
DateSymbols
symbols
=
intl
.
DateSymbols
.
deserializeFromMap
(
data
);
...
...
packages/flutter_localizations/test/material/date_time_test.dart
View file @
f8d73be8
...
...
@@ -158,6 +158,23 @@ void main() {
expect
(
formatted
[
DateType
.
full
],
'Mittwoch, 1. August 2018'
);
expect
(
formatted
[
DateType
.
monthYear
],
'August 2018'
);
});
testWidgets
(
'formats dates in Serbian'
,
(
WidgetTester
tester
)
async
{
final
Map
<
DateType
,
String
>
formatted
=
await
formatDate
(
tester
,
const
Locale
(
'sr'
),
DateTime
(
2018
,
8
,
1
));
expect
(
formatted
[
DateType
.
year
],
'2018.'
);
expect
(
formatted
[
DateType
.
medium
],
'сре 1. авг'
);
expect
(
formatted
[
DateType
.
full
],
'среда, 1. август 2018.'
);
expect
(
formatted
[
DateType
.
monthYear
],
'август 2018.'
);
});
testWidgets
(
'formats dates in Serbian (Latin)'
,
(
WidgetTester
tester
)
async
{
final
Map
<
DateType
,
String
>
formatted
=
await
formatDate
(
tester
,
const
Locale
.
fromSubtags
(
languageCode:
'sr'
,
scriptCode:
'Latn'
),
DateTime
(
2018
,
8
,
1
));
expect
(
formatted
[
DateType
.
year
],
'2018.'
);
expect
(
formatted
[
DateType
.
medium
],
'sre 1. avg'
);
expect
(
formatted
[
DateType
.
full
],
'sreda, 1. avgust 2018.'
);
expect
(
formatted
[
DateType
.
monthYear
],
'avgust 2018.'
);
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment