Skip to content

[proposal] gen_l10n should support select #81981

Closed

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

Activity

  1. added
    a: internationalizationSupporting other languages or locales. (aka i18n)
    toolAffects the "flutter" command-line tool. See also t: labels.
    on May 6, 2021
  2. HansMuller commented on May 6, 2021

    @HansMuller
    Contributor

    CC @shihaohong - sounds like a reasonable feature

  3. Knupper commented on May 7, 2021

    @Knupper

    Additional information to this, the "old way" over intl_translation does support it, maybe this is helpful for the implementation.

  4. mreichelt commented on May 7, 2021

    @mreichelt
    Author

    On a side note, it would be awesome if the gen_l10n tool would print an error message on unsupported literals in the ARB file - instead of just moving forward and generating code that contains errors.

  5. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    on May 17, 2021
  6. Knupper commented on Jun 29, 2021

    @Knupper

    Any news on this topic?

  7. asashour commented on Jul 9, 2021

    @asashour
    Contributor

    On a side note, it would be awesome if the gen_l10n tool would print an error message on unsupported literals in the ARB file - instead of just moving forward and generating code that contains errors.

    @mreichelt
    How about creating a new issue for this, giving failure examples?

  8. github-actions commented on Aug 4, 2021

    @github-actions

    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 -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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