-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Handle dollar signs properly when generating localizations #125514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for the quick fix!
@@ -294,7 +294,14 @@ String generateString(String value) { | |||
/// Given a list of strings, placeholders, or helper function calls, concatenate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can expressions
really include "helper function calls"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you're right, I think that was an outdated comment from when I used to directly embed helper functions to generate some expressions.
packages/flutter_tools/lib/src/localizations/localizations_utils.dart
Outdated
Show resolved
Hide resolved
/// | ||
/// The following rules describe all the cases which needs to be handled: | ||
/// 1. String with only a single interpolated variable is converted to the variable itself e.g. ["'$expr'"] -> "expr". | ||
/// 2. If one string ends in an interpolation and the next begins with an alphanumeric character, then the former should |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the rules mention an empty string and the reverse of #2
:
["'another string'", "'$expr1'"] -> "'another string'${expr1}".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is acceptable to not put braces in the reverse case since "'another string$expr1'"
is a valid Dart string. But I'll add a mention of what happens when expressions
is empty.
…ls.dart Co-authored-by: Hans Muller <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Roll Flutter from c9004ff to 66fa4c5 (68 revisions) flutter/flutter@c9004ff...66fa4c5 2023-04-26 [email protected] Remove web compile benchmarks that specify an attached device (flutter/flutter#125559) 2023-04-26 [email protected] Roll Flutter Engine from f75908135e10 to f125a54f5a57 (1 revision) (flutter/flutter#125560) 2023-04-26 [email protected] Roll Flutter Engine from c9db1587f207 to f75908135e10 (1 revision) (flutter/flutter#125558) 2023-04-26 [email protected] Roll Flutter Engine from 58a5a1e3f2c1 to c9db1587f207 (1 revision) (flutter/flutter#125555) 2023-04-26 [email protected] Roll Flutter Engine from 321f8015b9c2 to 58a5a1e3f2c1 (1 revision) (flutter/flutter#125552) 2023-04-26 [email protected] Roll Flutter Engine from 87f5f4e939cf to 321f8015b9c2 (1 revision) (flutter/flutter#125549) 2023-04-26 [email protected] Update prefer_final_parameters comment (flutter/flutter#125465) 2023-04-26 [email protected] Roll Flutter Engine from 706c023df44b to 87f5f4e939cf (1 revision) (flutter/flutter#125539) 2023-04-26 [email protected] Roll Flutter Engine from 7b385abd18a2 to 706c023df44b (1 revision) (flutter/flutter#125536) 2023-04-26 [email protected] Roll Flutter Engine from 610c57781b47 to 7b385abd18a2 (1 revision) (flutter/flutter#125533) 2023-04-26 [email protected] Roll Flutter Engine from b3cbf0678487 to 610c57781b47 (1 revision) (flutter/flutter#125531) 2023-04-26 [email protected] Add hostonly web compile size benchmarks (flutter/flutter#125518) 2023-04-26 [email protected] Roll Flutter Engine from 34ece7a4abac to b3cbf0678487 (6 revisions) (flutter/flutter#125529) 2023-04-25 [email protected] Handle dollar signs properly when generating localizations (flutter/flutter#125514) 2023-04-25 [email protected] Roll Flutter Engine from 6d798393a15a to 34ece7a4abac (1 revision) (flutter/flutter#125516) 2023-04-25 [email protected] Roll Flutter Engine from 469e5b409686 to 6d798393a15a (2 revisions) (flutter/flutter#125513) 2023-04-25 [email protected] Adds selected semantics flag to radio button for Apple devices (flutter/flutter#125499) 2023-04-25 [email protected] Roll Flutter Engine from 0e236982086b to 469e5b409686 (1 revision) (flutter/flutter#125510) 2023-04-25 [email protected] Relabel JSFunction as JSExportedDartFunction (flutter/flutter#125453) 2023-04-25 [email protected] Roll Flutter Engine from 60c4e61416cd to 0e236982086b (2 revisions) (flutter/flutter#125504) 2023-04-25 [email protected] iOS TextField spell check style (flutter/flutter#125432) 2023-04-25 [email protected] Roll Flutter Engine from 308bce499087 to 60c4e61416cd (1 revision) (flutter/flutter#125490) 2023-04-25 [email protected] Roll Flutter Engine from 54ddef68b124 to 308bce499087 (1 revision) (flutter/flutter#125485) 2023-04-25 [email protected] Roll Flutter Engine from 307416f43b5a to 54ddef68b124 (1 revision) (flutter/flutter#125481) 2023-04-25 [email protected] Roll Flutter Engine from 232810b36671 to 307416f43b5a (1 revision) (flutter/flutter#125475) 2023-04-25 [email protected] Roll Flutter Engine from 1c4b6c0cb862 to 232810b36671 (2 revisions) (flutter/flutter#125472) 2023-04-25 [email protected] Roll Flutter Engine from a26a479e86b3 to 1c4b6c0cb862 (1 revision) (flutter/flutter#125463) 2023-04-25 [email protected] Fix `SliverAppBar.medium` & `SliverAppBar.large` text scale (flutter/flutter#125038) 2023-04-25 [email protected] Roll Flutter Engine from 3f4116c225e8 to a26a479e86b3 (1 revision) (flutter/flutter#125459) 2023-04-25 [email protected] Roll Flutter Engine from 64882f4b7371 to 3f4116c225e8 (2 revisions) (flutter/flutter#125458) 2023-04-25 [email protected] Roll Flutter Engine from 8fe8e94c02fc to 64882f4b7371 (1 revision) (flutter/flutter#125454) 2023-04-25 [email protected] Roll Flutter Engine from 5fbde6c0fc57 to 8fe8e94c02fc (10 revisions) (flutter/flutter#125452) 2023-04-24 [email protected] Add Sliders to `macrobenchmarks` (flutter/flutter#125296) 2023-04-24 [email protected] [date_picker] [date_range_picker] add properties to change switch-to icons (flutter/flutter#124881) 2023-04-24 [email protected] Sliver Constrained Cross Axis (flutter/flutter#125239) 2023-04-24 [email protected] tool: Move cdKey to CustomDimensionsEnum (flutter/flutter#125335) 2023-04-24 [email protected] Add `borderRadius` to LinearProgressIndicator (flutter/flutter#123517) 2023-04-24 [email protected] Fix JS types in _test_http_request.dart (flutter/flutter#125220) 2023-04-24 [email protected] Fix `OutlinedButton`, `TextButton`, and `IconButton` throw exception when passing only one cursor to `styleFrom` (flutter/flutter#125204) 2023-04-24 [email protected] Swap some iOS TESTOWNERS (flutter/flutter#125340) 2023-04-24 [email protected] Fix iOS touch drag behavior (flutter/flutter#125169) 2023-04-24 [email protected] Mark module_test_ios flaky (flutter/flutter#125426) 2023-04-24 [email protected] Implement url support for RouteInformation and didPushRouteInformation (flutter/flutter#119968) 2023-04-24 [email protected] [tool,web] Include more info URI on Wasm init failure (flutter/flutter#125312) 2023-04-24 [email protected] Do not run `windows_home_scroll_perf__timeline_summary` benchmark in presubmit (flutter/flutter#125343) 2023-04-24 [email protected] Tiny fix doc pointing to incorrect widget confusing the readers (flutter/flutter#125394) ...
Roll Flutter from c9004ff to 66fa4c5 (68 revisions) flutter/flutter@c9004ff...66fa4c5 2023-04-26 [email protected] Remove web compile benchmarks that specify an attached device (flutter/flutter#125559) 2023-04-26 [email protected] Roll Flutter Engine from f75908135e10 to f125a54f5a57 (1 revision) (flutter/flutter#125560) 2023-04-26 [email protected] Roll Flutter Engine from c9db1587f207 to f75908135e10 (1 revision) (flutter/flutter#125558) 2023-04-26 [email protected] Roll Flutter Engine from 58a5a1e3f2c1 to c9db1587f207 (1 revision) (flutter/flutter#125555) 2023-04-26 [email protected] Roll Flutter Engine from 321f8015b9c2 to 58a5a1e3f2c1 (1 revision) (flutter/flutter#125552) 2023-04-26 [email protected] Roll Flutter Engine from 87f5f4e939cf to 321f8015b9c2 (1 revision) (flutter/flutter#125549) 2023-04-26 [email protected] Update prefer_final_parameters comment (flutter/flutter#125465) 2023-04-26 [email protected] Roll Flutter Engine from 706c023df44b to 87f5f4e939cf (1 revision) (flutter/flutter#125539) 2023-04-26 [email protected] Roll Flutter Engine from 7b385abd18a2 to 706c023df44b (1 revision) (flutter/flutter#125536) 2023-04-26 [email protected] Roll Flutter Engine from 610c57781b47 to 7b385abd18a2 (1 revision) (flutter/flutter#125533) 2023-04-26 [email protected] Roll Flutter Engine from b3cbf0678487 to 610c57781b47 (1 revision) (flutter/flutter#125531) 2023-04-26 [email protected] Add hostonly web compile size benchmarks (flutter/flutter#125518) 2023-04-26 [email protected] Roll Flutter Engine from 34ece7a4abac to b3cbf0678487 (6 revisions) (flutter/flutter#125529) 2023-04-25 [email protected] Handle dollar signs properly when generating localizations (flutter/flutter#125514) 2023-04-25 [email protected] Roll Flutter Engine from 6d798393a15a to 34ece7a4abac (1 revision) (flutter/flutter#125516) 2023-04-25 [email protected] Roll Flutter Engine from 469e5b409686 to 6d798393a15a (2 revisions) (flutter/flutter#125513) 2023-04-25 [email protected] Adds selected semantics flag to radio button for Apple devices (flutter/flutter#125499) 2023-04-25 [email protected] Roll Flutter Engine from 0e236982086b to 469e5b409686 (1 revision) (flutter/flutter#125510) 2023-04-25 [email protected] Relabel JSFunction as JSExportedDartFunction (flutter/flutter#125453) 2023-04-25 [email protected] Roll Flutter Engine from 60c4e61416cd to 0e236982086b (2 revisions) (flutter/flutter#125504) 2023-04-25 [email protected] iOS TextField spell check style (flutter/flutter#125432) 2023-04-25 [email protected] Roll Flutter Engine from 308bce499087 to 60c4e61416cd (1 revision) (flutter/flutter#125490) 2023-04-25 [email protected] Roll Flutter Engine from 54ddef68b124 to 308bce499087 (1 revision) (flutter/flutter#125485) 2023-04-25 [email protected] Roll Flutter Engine from 307416f43b5a to 54ddef68b124 (1 revision) (flutter/flutter#125481) 2023-04-25 [email protected] Roll Flutter Engine from 232810b36671 to 307416f43b5a (1 revision) (flutter/flutter#125475) 2023-04-25 [email protected] Roll Flutter Engine from 1c4b6c0cb862 to 232810b36671 (2 revisions) (flutter/flutter#125472) 2023-04-25 [email protected] Roll Flutter Engine from a26a479e86b3 to 1c4b6c0cb862 (1 revision) (flutter/flutter#125463) 2023-04-25 [email protected] Fix `SliverAppBar.medium` & `SliverAppBar.large` text scale (flutter/flutter#125038) 2023-04-25 [email protected] Roll Flutter Engine from 3f4116c225e8 to a26a479e86b3 (1 revision) (flutter/flutter#125459) 2023-04-25 [email protected] Roll Flutter Engine from 64882f4b7371 to 3f4116c225e8 (2 revisions) (flutter/flutter#125458) 2023-04-25 [email protected] Roll Flutter Engine from 8fe8e94c02fc to 64882f4b7371 (1 revision) (flutter/flutter#125454) 2023-04-25 [email protected] Roll Flutter Engine from 5fbde6c0fc57 to 8fe8e94c02fc (10 revisions) (flutter/flutter#125452) 2023-04-24 [email protected] Add Sliders to `macrobenchmarks` (flutter/flutter#125296) 2023-04-24 [email protected] [date_picker] [date_range_picker] add properties to change switch-to icons (flutter/flutter#124881) 2023-04-24 [email protected] Sliver Constrained Cross Axis (flutter/flutter#125239) 2023-04-24 [email protected] tool: Move cdKey to CustomDimensionsEnum (flutter/flutter#125335) 2023-04-24 [email protected] Add `borderRadius` to LinearProgressIndicator (flutter/flutter#123517) 2023-04-24 [email protected] Fix JS types in _test_http_request.dart (flutter/flutter#125220) 2023-04-24 [email protected] Fix `OutlinedButton`, `TextButton`, and `IconButton` throw exception when passing only one cursor to `styleFrom` (flutter/flutter#125204) 2023-04-24 [email protected] Swap some iOS TESTOWNERS (flutter/flutter#125340) 2023-04-24 [email protected] Fix iOS touch drag behavior (flutter/flutter#125169) 2023-04-24 [email protected] Mark module_test_ios flaky (flutter/flutter#125426) 2023-04-24 [email protected] Implement url support for RouteInformation and didPushRouteInformation (flutter/flutter#119968) 2023-04-24 [email protected] [tool,web] Include more info URI on Wasm init failure (flutter/flutter#125312) 2023-04-24 [email protected] Do not run `windows_home_scroll_perf__timeline_summary` benchmark in presubmit (flutter/flutter#125343) 2023-04-24 [email protected] Tiny fix doc pointing to incorrect widget confusing the readers (flutter/flutter#125394) ...
This broke our use case:
Used to generate: @override
String onboardingDescription(int count) {
String _temp0 = intl.Intl.pluralLogic(
count,
locale: localeName,
other: 'ERROR: onboardingDescription for this index not found',
two: '$onboardingThirdDescription',
one: '$onboardingSecondDescription',
zero: '$onboardingFirstDescription',
);
return '$_temp0';
} And now generates: @override
String onboardingDescription(int count) {
String _temp0 = intl.Intl.pluralLogic(
count,
locale: localeName,
other: 'ERROR: onboardingDescription for this index not found',
two: '\$onboardingThirdDescription',
one: '\$onboardingSecondDescription',
zero: '\$onboardingFirstDescription',
);
return '$_temp0';
} |
Currently, the code doesn't properly handle strings which contain dollar signs. The return expression for the generated localization function is computed by
generateReturnExpr
which concatenates several strings, which are either interpolated placeholders, interpolated function calls, or normal strings, but we didn't properly escape dollar signs before sending normal strings togenerateReturnExpr
.Fixes #125461.