Open tomassasovsky opened 1 year ago
Thanks for the report @tomassasovsky
I tried to recreate the replication using the details you provided, but getting below error while trying to run flutter gen-l10n
:
The arb file /Users/dhs/Documents/NCFlutter/new_project/lib/l10n/app_en.arb has the following formatting issue:
FormatException: Unexpected character (at character 24)
"onboardingDescription": "{count, plural, =0{$onboardingFirstDescription} =...
Can you provide complete details or replication details so that we can try to debug it further ?
@darshankawar Fixed the code sample.
Thanks for the update. I was able to replicate it using latest stable and master versions and see below:
import 'package:intl/intl.dart' as intl;
import 'app_localizations.dart';
/// The translations for English (`en`).
class AppLocalizationsEn extends AppLocalizations {
AppLocalizationsEn([String locale = 'en']) : super(locale);
@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';
}
@override
String get onboardingFirstDescription => 'View your upcoming and past games. Select a game and record it by pressing the red button.';
@override
String get onboardingSecondDescription => 'To record a game follow the set-up instructions. Once finished recording, save and upload later to get it analyzed.';
@override
String get onboardingThirdDescription => 'Upload your game\'s videos in My Recordings.';
}
This looks like more of a feature request to allow referencing other arb strings from a given arb string via string interpolation. The previous implementation allowed this unintentionally because it would not escape the dollar signs in the generated code.
It should be possible to work around this by turning the "interpolated strings" into placeholders, and then pass those referenced arb strings in as parameters.
We could implement this feature, it would by check if the symbol after the dollar sign is a valid arb string getter. That's not syntax defined by ICU so it would be custom behavior supported by Flutter i18n.
CC @thkim1011
We also had a breakdown due to the fix carried out. It would be a good feature to write less and reuse patterns.
Is there an existing issue for this?
Steps to reproduce
This "fix" broke our use case:
Expected results
Actual results
Code sample
Code sample
```json { "onboardingDescription": "{count, plural, =0{$onboardingFirstDescription} =1{$onboardingSecondDescription} =2{$onboardingThirdDescription} other{ERROR: onboardingDescription for this index not found}}", "@onboardingDescription": { "placeholders": { "count": { "type": "int" } } }, "onboardingFirstDescription": "View your upcoming and past games. Select a game and record it by pressing the red button.", "onboardingSecondDescription": "To record a game follow the set-up instructions. Once finished recording, save and upload later to get it analyzed.", "onboardingThirdDescription": "Upload your game's videos in My Recordings." } ```Screenshots or Video
Screenshots / Video demonstration
[Upload media here]Logs
Logs
```console [Paste your logs here] ```Flutter Doctor output
Doctor output
```console [Paste your output here] ```