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
83a74e11
Unverified
Commit
83a74e11
authored
Mar 26, 2020
by
gaaclarke
Committed by
GitHub
Mar 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Started caching results from iana. (#53286)
parent
8a902352
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47955 additions
and
18 deletions
+47955
-18
gen_l10n.dart
dev/tools/localization/bin/gen_l10n.dart
+2
-3
gen_localizations.dart
dev/tools/localization/bin/gen_localizations.dart
+2
-3
gen_subtag_registry.dart
dev/tools/localization/gen_subtag_registry.dart
+27
-0
language_subtag_registry.dart
dev/tools/localization/language_subtag_registry.dart
+47917
-0
localizations_utils.dart
dev/tools/localization/localizations_utils.dart
+5
-10
gen_l10n_test.dart
dev/tools/test/localization/gen_l10n_test.dart
+2
-2
No files found.
dev/tools/localization/bin/gen_l10n.dart
View file @
83a74e11
...
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:io'
;
import
'package:args/args.dart'
as
argslib
;
...
...
@@ -13,7 +12,7 @@ import '../gen_l10n.dart';
import
'../gen_l10n_types.dart'
;
import
'../localizations_utils.dart'
;
Future
<
void
>
main
(
List
<
String
>
arguments
)
async
{
void
main
(
List
<
String
>
arguments
)
{
final
argslib
.
ArgParser
parser
=
argslib
.
ArgParser
();
parser
.
addFlag
(
'help'
,
...
...
@@ -80,7 +79,7 @@ Future<void> main(List<String> arguments) async {
exit
(
0
);
}
await
precacheLanguageAndRegionTags
();
precacheLanguageAndRegionTags
();
final
String
arbPathString
=
results
[
'arb-dir'
]
as
String
;
final
String
outputFileString
=
results
[
'output-localization-file'
]
as
String
;
...
...
dev/tools/localization/bin/gen_localizations.dart
View file @
83a74e11
...
...
@@ -40,7 +40,6 @@
// dart dev/tools/localization/bin/gen_localizations.dart --overwrite
// ```
import
'dart:async'
;
import
'dart:io'
;
import
'package:path/path.dart'
as
path
;
...
...
@@ -480,7 +479,7 @@ String generateGetter(String key, String value, Map<String, dynamic> attributes,
$type
get
$key
=>
$value
;'''
;
}
Future
<
void
>
main
(
List
<
String
>
rawArgs
)
async
{
void
main
(
List
<
String
>
rawArgs
)
{
checkCwdIsRepoRoot
(
'gen_localizations'
);
final
GeneratorOptions
options
=
parseArgs
(
rawArgs
);
...
...
@@ -499,7 +498,7 @@ Future<void> main(List<String> rawArgs) async {
exitWithError
(
'
$exception
'
);
}
await
precacheLanguageAndRegionTags
();
precacheLanguageAndRegionTags
();
// Maps of locales to resource key/value pairs for Material ARBs.
final
Map
<
LocaleInfo
,
Map
<
String
,
String
>>
materialLocaleToResources
=
<
LocaleInfo
,
Map
<
String
,
String
>>{};
...
...
dev/tools/localization/gen_subtag_registry.dart
0 → 100644
View file @
83a74e11
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:io'
;
const
String
registry
=
'https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry'
;
/// A script to generate a Dart cache of https://www.iana.org. This should be
/// run occasionally. It was created since iana.org was found to be flakey.
///
/// To execute: dart gen_subtag_registry.dart > language_subtag_registry.dart
Future
<
void
>
main
()
async
{
final
HttpClient
client
=
HttpClient
();
final
HttpClientRequest
request
=
await
client
.
getUrl
(
Uri
.
parse
(
registry
));
final
HttpClientResponse
response
=
await
request
.
close
();
final
String
body
=
(
await
response
.
cast
<
List
<
int
>>().
transform
<
String
>(
utf8
.
decoder
).
toList
()).
join
(
''
);
print
(
'''// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Cache of
$registry
.
const String languageSubtagRegistry =
\'\'\'
$body
\'\'\'
;'''
);
client
.
close
(
force:
true
);
}
dev/tools/localization/language_subtag_registry.dart
0 → 100644
View file @
83a74e11
This diff is collapsed.
Click to expand it.
dev/tools/localization/localizations_utils.dart
View file @
83a74e11
...
...
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:io'
;
import
'package:args/args.dart'
as
argslib
;
import
'package:meta/meta.dart'
;
import
'language_subtag_registry.dart'
;
typedef
HeaderGenerator
=
String
Function
(
String
regenerateInstructions
);
typedef
ConstructorGenerator
=
String
Function
(
LocaleInfo
locale
);
...
...
@@ -264,8 +265,6 @@ class GeneratorOptions {
final
bool
cupertinoOnly
;
}
const
String
registry
=
'https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry'
;
// See also //master/tools/gen_locale.dart in the engine repo.
Map
<
String
,
List
<
String
>>
_parseSection
(
String
section
)
{
final
Map
<
String
,
List
<
String
>>
result
=
<
String
,
List
<
String
>>{};
...
...
@@ -297,13 +296,9 @@ const String kParentheticalPrefix = ' (';
/// Prepares the data for the [describeLocale] method below.
///
/// The data is obtained from the official IANA registry.
Future
<
void
>
precacheLanguageAndRegionTags
()
async
{
final
HttpClient
client
=
HttpClient
();
final
HttpClientRequest
request
=
await
client
.
getUrl
(
Uri
.
parse
(
registry
));
final
HttpClientResponse
response
=
await
request
.
close
();
final
String
body
=
(
await
response
.
cast
<
List
<
int
>>().
transform
<
String
>(
utf8
.
decoder
).
toList
()).
join
(
''
);
client
.
close
(
force:
true
);
final
List
<
Map
<
String
,
List
<
String
>>>
sections
=
body
.
split
(
'%%'
).
skip
(
1
).
map
<
Map
<
String
,
List
<
String
>>>(
_parseSection
).
toList
();
void
precacheLanguageAndRegionTags
(
)
{
final
List
<
Map
<
String
,
List
<
String
>>>
sections
=
languageSubtagRegistry
.
split
(
'%%'
).
skip
(
1
).
map
<
Map
<
String
,
List
<
String
>>>(
_parseSection
).
toList
();
for
(
final
Map
<
String
,
List
<
String
>>
section
in
sections
)
{
assert
(
section
.
containsKey
(
'Type'
),
section
.
toString
());
final
String
type
=
section
[
'Type'
].
single
;
...
...
dev/tools/test/localization/gen_l10n_test.dart
View file @
83a74e11
...
...
@@ -47,11 +47,11 @@ void _standardFlutterDirectoryL10nSetup(FileSystem fs) {
void
main
(
)
{
MemoryFileSystem
fs
;
setUp
(()
async
{
setUp
(()
{
fs
=
MemoryFileSystem
(
style:
Platform
.
isWindows
?
FileSystemStyle
.
windows
:
FileSystemStyle
.
posix
);
await
precacheLanguageAndRegionTags
();
precacheLanguageAndRegionTags
();
});
group
(
'Setters'
,
()
{
...
...
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