Skip to content

ICU Message Refactoring #112709

Description

@thkim1011

See #112390 for more context. Essentially, we need to refactor the Message class in gen_l10n_types.dart if we want to support proper placeholder type inference. The high level idea is that we need to

  1. Parse each translation for a given message.
  2. Figure out how each placeholder is being used.
  3. If there is a conflict (i.e. placeholder is used for both plural (which must be type 'num') and select (which must be type 'String'), then throw an error.
  4. Otherwise if type is not explicitly defined, then set it to 'num' if only used in plurals and placeholders or set it to 'String' if only used in selects and placeholders.

To do step 1, we need the Message class to own all of the translations for the message. We should be able to do this by changing LocalizationsGenerator.loadResources. Then we can also deprecate the old behavior for inferring placeholder types which doesn't work properly.

Activity

  1. added
    in triagePresently being triaged by the triage team
    toolAffects the "flutter" command-line tool. See also t: labels.
    a: internationalizationSupporting other languages or locales. (aka i18n)
    and removed
    in triagePresently being triaged by the triage team
    on Oct 3, 2022
  2. christopherfujino commented on Oct 3, 2022

    @christopherfujino
    Contributor

    Drive by comment (haven't given it much thought), have you considered a parser migration where the new parser is introduced alongside the legacy one, controlled by some boolean value? This way if there is a serious bug in it in a stable release, we can easily revert back to the legacy version.

  3. self-assigned this
    on Nov 16, 2022
  4. github-actions commented on Mar 5, 2023

    @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.

  5. locked as resolved and limited conversation to collaborators on Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: internationalizationSupporting other languages or locales. (aka i18n)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