Repository navigation
[proposal] gen_l10n should support select #81981
Copy link
Copy link
Closed
Labels
a: internationalizationSupporting other languages or locales. (aka i18n)Supporting other languages or locales. (aka i18n)c: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.toolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Description
This issue is similar to #75094, but instead of plural, select is completely not supported. This blocks us in updating to Flutter 2 / gen_l10n.
ARB file (fragment):
"commonVehicleType": "{vehicleType, select, sedan{Sedan} cabriolet{Solid roof cabriolet} truck{16 wheel truck} other{Other}}",
"@commonVehicleType": {
"description": "Vehicle type",
"placeholders": {
"vehicleType": {}
}This currently generates:
@override
String commonVehicleType(Object vehicleType) {
return '{vehicleType, select, sedan{Sedan} cabriolet{Solid roof cabriolet} truck{16 wheel truck} other{Other}}';
}Instead, this should support the select properly and output something like this:
@override
String commonVehicleType(Object vehicleType) => Intl.select(
vehicleType,
{
'sedan': 'Sedan',
'cabriolet': 'Solid roof cabriolet',
'truck': '16 wheel truck',
'other': 'Other',
},
name: 'commonVehicleType',
desc: 'Vehicle type',
args: [vehicleType],
);Tested on both 1.22.6 as well as 2.0.5:
[✓] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.7 19H15 darwin-x64, locale de-DE)
• Flutter version 1.22.6 at /Users/mreichelt/bin/flutter-1.22.6
• Framework revision 9b2d32b605 (3 months ago), 2021-01-22 14:36:39 -0800
• Engine revision 2f0af37152
• Dart version 2.10.5
[√] Flutter (Channel stable, 2.0.5, on Microsoft Windows [Version 10.0.19042.964], locale de-DE)
• Flutter version 2.0.5 at C:\Program Files\Development\flutter
• Framework revision adc687823a (3 weeks ago), 2021-04-16 09:40:20 -0700
• Engine revision b09f014e96
• Dart version 2.12.3
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a: internationalizationSupporting other languages or locales. (aka i18n)Supporting other languages or locales. (aka i18n)c: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.toolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Activity
mreichelt commentedon May 6, 2021
Thread in Flutter Study Channel: https://flutterstudygroup.slack.com/archives/CACLB2TGC/p1620311716307900
The source code that affects this is here (thanks to @jamesblasco for helping): https://github.com/flutter/flutter/blob/71cb40f46ac318e0e59ae17b958c14fa7b030085/packages/flutter_tools/lib/src/localizations/gen_l10n_templates.dart
HansMuller commentedon May 6, 2021
CC @shihaohong - sounds like a reasonable feature
Knupper commentedon May 7, 2021
Additional information to this, the "old way" over intl_translation does support it, maybe this is helpful for the implementation.
mreichelt commentedon May 7, 2021
On a side note, it would be awesome if the
gen_l10ntool would print an error message on unsupported literals in the ARB file - instead of just moving forward and generating code that contains errors.Knupper commentedon Jun 29, 2021
Any news on this topic?
asashour commentedon Jul 9, 2021
@mreichelt
How about creating a new issue for this, giving failure examples?
github-actions commentedon Aug 4, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.