Skip to content

[proposal] gen_l10n should support nested plurals #75094

@Albert221

Description

@Albert221

My ARB file (fragment):

    "remove_all_done_dialog_body": "Are you sure you want to remove {count, plural, =1 {1 item} other {all {count} items}}? This operation cannot be undone.",
    "@remove_all_done_dialog_body": {
        "placeholders": {
            "count": {
                "type": "int",
                "format": "compactLong"
            }
        }
    }

And this is the output (fragment of app_localizations_en.dart):

  @override
  String remove_all_done_dialog_body(int count) {
    final intl.NumberFormat countNumberFormat = intl.NumberFormat.compactLong(
      locale: localeName,
      
    );
    final String countString = countNumberFormat.format(count);

    return intl.Intl.pluralLogic(
      count,
      locale: localeName,
      one: '1 item',
      other: 'all ${count} items',
    );
  }

What should be outputted (more or less):

  @override
  String remove_all_done_dialog_body(int count) {
    final intl.NumberFormat countNumberFormat = intl.NumberFormat.compactLong(
      locale: localeName,
      
    );
    final String countString = countNumberFormat.format(count);

    final String pluralString = intl.Intl.pluralLogic(
      count,
      locale: localeName,
      one: '1 item',
      other: 'all ${countString} items',
    );

    return 'Are you sure you want to remove ${pluralString}? This operation cannot be undone.';
  }

gen_l10n tool completely ignores the text outside of the {count, plural...}.

Flutter 1.22.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 9b2d32b605 (9 days ago) • 2021-01-22 14:36:39 -0800
Engine • revision 2f0af37152
Tools • Dart 2.10.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: internationalizationSupporting other languages or locales. (aka i18n)c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions