[gen_l10n] Escape quote characters in ARB files (#51952)
This commit is contained in:
committed by
GitHub
parent
cccbf1f200
commit
9c5009b251
@@ -17,7 +17,7 @@ for more info.
|
||||
|
||||
```dart
|
||||
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
|
||||
```
|
||||
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
{
|
||||
"title": "Stocks",
|
||||
"@title": {
|
||||
"description": "Title for the Stocks application"
|
||||
},
|
||||
|
||||
"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": {
|
||||
"description": "Title for the Stocks application"
|
||||
},
|
||||
|
||||
"market": "MARKET",
|
||||
"@market": {
|
||||
"description": "Label for the Market tab"
|
||||
},
|
||||
|
||||
"portfolio": "PORTFOLIO",
|
||||
"@portfolio": {
|
||||
"description": "Label for the Portfolio tab"
|
||||
}
|
||||
"portfolio": "PORTFOLIO"
|
||||
}
|
||||
|
||||
@@ -163,6 +163,11 @@ String generateMethod(Message message, AppResourceBundle bundle) {
|
||||
messageValue = messageValue.replaceAll('{${placeholder.name}}', '\${${placeholder.name}}');
|
||||
}
|
||||
}
|
||||
|
||||
// Escape single and double quotes.
|
||||
messageValue = messageValue.replaceAll("'", '\\\'');
|
||||
messageValue = messageValue.replaceAll('"', '\\\"');
|
||||
|
||||
return "'$messageValue'";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user