gen_l10n: support string list as preferred-supported-locales, as documented#63649
Conversation
da62f72 to
c04d017
Compare
There was a problem hiding this comment.
Maybe what we really want is to represent the preferred-supported-locales option as a yaml sequence. Then, we can parse the yaml sequence into the json format desired by the gen_l10n tool.
cc/ @jonahwilliams, who might have ideas on how to best approach this.
As for the gen_l10n tool itself parsing the list of supported locales as JSON, could you further elaborate on what the allowMultiple: true flag would do? I think it'd be great to consider any ideas that would make the tool more ergonomic (if it isn't too breaking). We haven't really announced the gen_l10n tool as a stable part of the framework yet, so we might still have a window of opportunity to make it as ergonomic as possible before that happens.
|
@shihaohong this PR should be able to parse yaml sequences. the yaml parser makes no difference between flow sequences and block sequences. I meant using the parameter multiple times for the
one more suggestion for |
8cc20e2 to
844ef62
Compare
|
@shihaohong i did a rebase on the last master.. seems like the command line parameters have been removed 👍️ so the only remaining thing is correctly reading the collection/list from the yaml. let's see how the tests work out |
… option instead of a json string in the command.
|
@shihaohong I have now also changed the |
There was a problem hiding this comment.
Nice, this change looks great! Thank you for your patience, I've been working through the synthetic package work with the gen_l10n tool over the last few weeks and haven't had time to get to this PR until now.
As a quick summary, this change is breaking, but definitely improves the API for the gen_l10n tool.
For example, in l10n.yaml, this:
preferred-supported-locales: '["en", "es"]'
is now be represented like this:
preferred-supported-locales:
- en
- es
or
preferred-supported-locales: [en, es]
And when running from the command line, instead of:
flutter gen-l10n --preferred-supported-locales='["en", "es"]' <other options
it is:
flutter gen-l10n --preferred-supported-locales=en --preferred-supported-locales=es <other options>
^ The order of preferred supported locales matters using the multiOption arg parser, since that's the order that will be used in the tool.
cc/ @HansMuller
HansMuller
left a comment
There was a problem hiding this comment.
This looks OK to me; definitely best to be YAML-conventional. Presumably, developers will not specify more than one or two locales on the command line, since that would get tedious.
Description
according to https://docs.google.com/document/d/10e0saTfAv32OZLRmONy866vnaw0I2jwL8zukykpgWBc/edit
but actually the yaml expects a string at that position, and the gen_l10n tool expects a valid json. so the yaml file would have to contain something like:
Also, the help in
gen_l10ndocuments the--preferred-supported-localesalso as['en_US']but usesjson.decodewhich only works with["en_US"].fwiw: imho it is a bit weird that
--preferred-supported-localesis passed as json. I thought about changinggen_l10nto make the--preferred-supported-localesaallowMultiple: trueoption. This seems to be more natural for a command line app, but this would probably break anyone using it this way?Tests
I added the following tests:
Checklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read [Handling breaking changes].