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
b883624c
Unverified
Commit
b883624c
authored
Nov 07, 2019
by
Shi-Hao Hong
Committed by
GitHub
Nov 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l10n tool improvements, stocks app refresh (#44313)
* Add pubspec.yaml comment * Add --help flag
parent
798e4272
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
10 deletions
+74
-10
gen_l10n.dart
dev/tools/localization/gen_l10n.dart
+55
-7
regenerate.md
examples/stocks/lib/i18n/regenerate.md
+2
-2
stock_strings.dart
examples/stocks/lib/i18n/stock_strings.dart
+17
-1
No files found.
dev/tools/localization/gen_l10n.dart
View file @
b883624c
...
@@ -37,6 +37,22 @@ import 'messages_all.dart';
...
@@ -37,6 +37,22 @@ import 'messages_all.dart';
/// );
/// );
/// ```
/// ```
///
///
/// ## Update pubspec.yaml
///
/// Please make sure to update your pubspec.yaml to include the following
/// packages:
///
/// ```
/// dependencies:
/// # Internationalization support.
/// flutter_localizations:
/// sdk: flutter
/// intl: 0.16.0
/// intl_translation: 0.17.7
///
/// # rest of dependencies
/// ```
///
/// ## iOS Applications
/// ## iOS Applications
///
///
/// iOS applications define key application metadata, including supported
/// iOS applications define key application metadata, including supported
...
@@ -56,7 +72,6 @@ import 'messages_all.dart';
...
@@ -56,7 +72,6 @@ import 'messages_all.dart';
/// you wish to add from the pop-up menu in the Value field. This list should
/// you wish to add from the pop-up menu in the Value field. This list should
/// be consistent with the languages listed in the @className.supportedLocales
/// be consistent with the languages listed in the @className.supportedLocales
/// property.
/// property.
class @className {
class @className {
@className(Locale locale) : _localeName = locale.toString();
@className(Locale locale) : _localeName = locale.toString();
...
@@ -292,13 +307,46 @@ String _importFilePath(String path, String fileName) {
...
@@ -292,13 +307,46 @@ String _importFilePath(String path, String fileName) {
return
'
$replaceLib
/
$fileName
'
;
return
'
$replaceLib
/
$fileName
'
;
}
}
Future
<
void
>
main
(
List
<
String
>
args
)
async
{
Future
<
void
>
main
(
List
<
String
>
arg
ument
s
)
async
{
final
argslib
.
ArgParser
parser
=
argslib
.
ArgParser
();
final
argslib
.
ArgParser
parser
=
argslib
.
ArgParser
();
parser
.
addOption
(
'arb-dir'
,
defaultsTo:
path
.
join
(
'lib'
,
'l10n'
));
parser
.
addFlag
(
parser
.
addOption
(
'template-arb-file'
,
defaultsTo:
'app_en.arb'
);
'help'
,
parser
.
addOption
(
'output-localization-file'
,
defaultsTo:
'app_localizations.dart'
);
defaultsTo:
false
,
parser
.
addOption
(
'output-class'
,
defaultsTo:
'AppLocalizations'
);
negatable:
false
,
final
argslib
.
ArgResults
results
=
parser
.
parse
(
args
);
help:
'Print this help message.'
,
);
parser
.
addOption
(
'arb-dir'
,
defaultsTo:
path
.
join
(
'lib'
,
'l10n'
),
help:
'The directory where all localization files should reside. For '
'example, the template and translated arb files should be located here. '
'Also, the generated output messages Dart files for each locale and the '
'generated localizations classes will be created here.'
,
);
parser
.
addOption
(
'template-arb-file'
,
defaultsTo:
'app_en.arb'
,
help:
'The template arb file that will be used as the basis for '
'generating the Dart localization and messages files.'
,
);
parser
.
addOption
(
'output-localization-file'
,
defaultsTo:
'app_localizations.dart'
,
help:
'The filename for the output localization and localizations '
'delegate classes.'
,
);
parser
.
addOption
(
'output-class'
,
defaultsTo:
'AppLocalizations'
,
help:
'The Dart class name to use for the output localization and '
'localizations delegate classes.'
,
);
final
argslib
.
ArgResults
results
=
parser
.
parse
(
arguments
);
if
(
results
[
'help'
]
==
true
)
{
print
(
parser
.
usage
);
exit
(
0
);
}
final
String
arbPathString
=
results
[
'arb-dir'
];
final
String
arbPathString
=
results
[
'arb-dir'
];
final
String
outputFileString
=
results
[
'output-localization-file'
];
final
String
outputFileString
=
results
[
'output-localization-file'
];
...
...
examples/stocks/lib/i18n/regenerate.md
View file @
b883624c
...
@@ -15,8 +15,8 @@ for more info.
...
@@ -15,8 +15,8 @@ for more info.
`messages_all.dart`
, and
`stock_strings.dart`
with the following command:
`messages_all.dart`
, and
`stock_strings.dart`
with the following command:
```
dart
```
dart
dart
$
{
FLUTTER_PATH
}/
dev
/
tools
/
localization
/
gen_l10n
.
dart
--
arb
-
dir
=
lib
/
i18n
dart
$
{
FLUTTER_PATH
}/
dev
/
tools
/
localization
/
gen_l10n
.
dart
--
arb
-
dir
=
lib
/
i18n
\
--
template
-
arb
-
file
=
stocks_en_
EN
.
arb
--
output
-
localization
-
file
=
stock_strings
.
dart
--
template
-
arb
-
file
=
stocks_en_
US
.
arb
--
output
-
localization
-
file
=
stock_strings
.
dart
\
--
output
-
class
=
StockStrings
--
output
-
class
=
StockStrings
```
```
...
...
examples/stocks/lib/i18n/stock_strings.dart
View file @
b883624c
...
@@ -23,6 +23,23 @@ import 'messages_all.dart';
...
@@ -23,6 +23,23 @@ import 'messages_all.dart';
/// );
/// );
/// ```
/// ```
///
///
/// ## Update pubspec.yaml
///
/// Please make sure to update your pubspec.yaml to include the following
/// packages:
///
/// ```
/// dependencies:
/// # rest of dependencies
///
/// flutter_localizations:
/// sdk: flutter
/// intl: 0.16.0
/// intl_translation: 0.17.7
///
/// # rest of dependencies
/// ```
///
/// ## iOS Applications
/// ## iOS Applications
///
///
/// iOS applications define key application metadata, including supported
/// iOS applications define key application metadata, including supported
...
@@ -42,7 +59,6 @@ import 'messages_all.dart';
...
@@ -42,7 +59,6 @@ import 'messages_all.dart';
/// you wish to add from the pop-up menu in the Value field. This list should
/// you wish to add from the pop-up menu in the Value field. This list should
/// be consistent with the languages listed in the StockStrings.supportedLocales
/// be consistent with the languages listed in the StockStrings.supportedLocales
/// property.
/// property.
class
StockStrings
{
class
StockStrings
{
StockStrings
(
Locale
locale
)
:
_localeName
=
locale
.
toString
();
StockStrings
(
Locale
locale
)
:
_localeName
=
locale
.
toString
();
...
...
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