Skip to content

[proposal] gen_l10n should support select #81981

@mreichelt

Description

@mreichelt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: internationalizationSupporting other languages or locales. (aka i18n)c: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.toolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions