[gen_l10n] Escape quote characters in ARB files (#51952)
This commit is contained in:
parent
cccbf1f200
commit
9c5009b251
@ -17,7 +17,7 @@ for more info.
|
|||||||
|
|
||||||
```dart
|
```dart
|
||||||
dart ${FLUTTER_PATH}/dev/tools/localization/bin/gen_l10n.dart --arb-dir=lib/i18n \
|
dart ${FLUTTER_PATH}/dev/tools/localization/bin/gen_l10n.dart --arb-dir=lib/i18n \
|
||||||
--template-arb-file=stocks_en_US.arb --output-localization-file=stock_strings.dart \
|
--template-arb-file=stocks_en.arb --output-localization-file=stock_strings.dart \
|
||||||
--output-class=StockStrings
|
--output-class=StockStrings
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
{
|
{
|
||||||
"title": "Stocks",
|
"title": "Stocks",
|
||||||
|
"@title": {
|
||||||
|
"description": "Title for the Stocks application"
|
||||||
|
},
|
||||||
|
|
||||||
"market": "MARKET",
|
"market": "MARKET",
|
||||||
"portfolio": "PORTFOLIO"
|
"@market": {
|
||||||
|
"description": "Label for the Market tab"
|
||||||
|
},
|
||||||
|
|
||||||
|
"portfolio": "PORTFOLIO",
|
||||||
|
"@portfolio": {
|
||||||
|
"description": "Label for the Portfolio tab"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,5 @@
|
|||||||
{
|
{
|
||||||
"title": "Stocks",
|
"title": "Stocks",
|
||||||
"@title": {
|
|
||||||
"description": "Title for the Stocks application"
|
|
||||||
},
|
|
||||||
|
|
||||||
"market": "MARKET",
|
"market": "MARKET",
|
||||||
"@market": {
|
"portfolio": "PORTFOLIO"
|
||||||
"description": "Label for the Market tab"
|
|
||||||
},
|
|
||||||
|
|
||||||
"portfolio": "PORTFOLIO",
|
|
||||||
"@portfolio": {
|
|
||||||
"description": "Label for the Portfolio tab"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,11 @@ String generateMethod(Message message, AppResourceBundle bundle) {
|
|||||||
messageValue = messageValue.replaceAll('{${placeholder.name}}', '\${${placeholder.name}}');
|
messageValue = messageValue.replaceAll('{${placeholder.name}}', '\${${placeholder.name}}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Escape single and double quotes.
|
||||||
|
messageValue = messageValue.replaceAll("'", '\\\'');
|
||||||
|
messageValue = messageValue.replaceAll('"', '\\\"');
|
||||||
|
|
||||||
return "'$messageValue'";
|
return "'$messageValue'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,8 @@ void main() {
|
|||||||
'#l10n 22 (Hello World of 101 citizens)\n'
|
'#l10n 22 (Hello World of 101 citizens)\n'
|
||||||
'#l10n 23 (Hello two worlds with 102 total citizens)\n'
|
'#l10n 23 (Hello two worlds with 102 total citizens)\n'
|
||||||
'#l10n 24 ([Hello] -World- #123#)\n'
|
'#l10n 24 ([Hello] -World- #123#)\n'
|
||||||
|
'#l10n 25 (Flutter\'s amazing!)\n'
|
||||||
|
'#l10n 26 (Flutter is "amazing"!)\n'
|
||||||
'#l10n END\n'
|
'#l10n END\n'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -108,6 +108,8 @@ class Home extends StatelessWidget {
|
|||||||
'${localizations.helloWorldPopulation(1, 101)}',
|
'${localizations.helloWorldPopulation(1, 101)}',
|
||||||
'${localizations.helloWorldPopulation(2, 102)}',
|
'${localizations.helloWorldPopulation(2, 102)}',
|
||||||
'${localizations.helloWorldsInterpolation(123, "Hello", "World")}',
|
'${localizations.helloWorldsInterpolation(123, "Hello", "World")}',
|
||||||
|
'${localizations.singleQuote}',
|
||||||
|
'${localizations.doubleQuote}',
|
||||||
]);
|
]);
|
||||||
for (final String result in results) {
|
for (final String result in results) {
|
||||||
print('#l10n $n ($result)\n');
|
print('#l10n $n ($result)\n');
|
||||||
@ -286,6 +288,16 @@ void main() {
|
|||||||
"hello": {},
|
"hello": {},
|
||||||
"world": {}
|
"world": {}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"singleQuote": "Flutter's amazing!",
|
||||||
|
"@singleQuote": {
|
||||||
|
"description": "A message with a single quote."
|
||||||
|
},
|
||||||
|
|
||||||
|
"doubleQuote": "Flutter is \"amazing\"!",
|
||||||
|
"@doubleQuote": {
|
||||||
|
"description": "A message with double quotes."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
''';
|
''';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user