Unverified Commit 159a47da authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

l10n tool improvements, stocks app i18n refresh (#44473)

* Add check for placeholders being an empty map

* Remove unnecessary properties from en_ES.arb in the stocks example

* Use getter instead of methods in the stocks example

* Fixed "annotating types for function expression parameters" lint issue from generated localizations delegate code
parent 9307a83f
......@@ -79,7 +79,7 @@ class @className {
static Future<@className> load(Locale locale) {
return initializeMessages(locale.toString())
.then<@className>((void _) => @className(locale));
.then<@className>((_) => @className(locale));
}
static @className of(BuildContext context) {
......@@ -168,8 +168,10 @@ List<String> genIntlMethodArgs(Map<String, dynamic> bundle, String key) {
}
if (attributesMap.containsKey('placeholders')) {
final Map<String, dynamic> placeholders = attributesMap['placeholders'];
final String args = placeholders.keys.join(', ');
attributes.add('args: <Object>[$args]');
if (placeholders.isNotEmpty) {
final String args = placeholders.keys.join(', ');
attributes.add('args: <Object>[$args]');
}
}
}
return attributes;
......
......@@ -16,8 +16,8 @@ for more info.
```dart
dart ${FLUTTER_PATH}/dev/tools/localization/gen_l10n.dart --arb-dir=lib/i18n \
--template-arb-file=stocks_en_US.arb --output-localization-file=stock_strings.dart \
--output-class=StockStrings
--template-arb-file=stocks_en_US.arb --output-localization-file=stock_strings.dart \
--output-class=StockStrings
```
The `StockStrings` class uses the generated `initializeMessages()`function
......
......@@ -93,33 +93,30 @@ class StockStrings {
Locale('en', 'US'),
];
String title() {
String get title {
return Intl.message(
r'Stocks',
locale: _localeName,
name: 'title',
desc: r'Title for the Stocks application',
args: <Object>[]
desc: r'Title for the Stocks application'
);
}
String market() {
String get market {
return Intl.message(
r'MARKET',
locale: _localeName,
name: 'market',
desc: r'Label for the Market tab',
args: <Object>[]
desc: r'Label for the Market tab'
);
}
String portfolio() {
String get portfolio {
return Intl.message(
r'PORTFOLIO',
locale: _localeName,
name: 'portfolio',
desc: r'Label for the Portfolio tab',
args: <Object>[]
desc: r'Label for the Portfolio tab'
);
}
......
{
"title": "Stocks",
"@title": {
"description": "Title for the Stocks application",
"type": "text",
"placeholders": {}
"description": "Title for the Stocks application"
},
"market": "MARKET",
"@market": {
"description": "Label for the Market tab",
"type": "text",
"placeholders": {}
"description": "Label for the Market tab"
},
"portfolio": "PORTFOLIO",
"@portfolio": {
"description": "Label for the Portfolio tab",
"type": "text",
"placeholders": {}
"description": "Label for the Portfolio tab"
}
}
{
"title": "Acciones",
"@title": {
"description": "Title for the Stocks application",
"type": "text",
"placeholders": {}
},
"market": "MERCADO",
"@market": {
"description": "Label for the Market tab",
"type": "text",
"placeholders": {}
},
"portfolio": "CARTERA",
"@portfolio": {
"description": "Label for the Portfolio tab",
"type": "text",
"placeholders": {}
}
"portfolio": "CARTERA"
}
......@@ -191,7 +191,7 @@ class StockHomeState extends State<StockHome> {
Widget buildAppBar() {
return AppBar(
elevation: 0.0,
title: Text(StockStrings.of(context).title()),
title: Text(StockStrings.of(context).title),
actions: <Widget>[
IconButton(
icon: const Icon(Icons.search),
......@@ -223,8 +223,8 @@ class StockHomeState extends State<StockHome> {
],
bottom: TabBar(
tabs: <Widget>[
Tab(text: StockStrings.of(context).market()),
Tab(text: StockStrings.of(context).portfolio()),
Tab(text: StockStrings.of(context).market),
Tab(text: StockStrings.of(context).portfolio),
],
),
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment