-
Notifications
You must be signed in to change notification settings - Fork 6k
Pass full locale list with script and variant codes to framework #6557
Conversation
|
Will update with working Android-side code. |
HansMuller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just looked over the dart changes, which seem fine. Just a few suggestions to prove that I read the code :-).
lib/ui/window.dart
Outdated
| /// This establishes the language and formatting conventions that application | ||
| /// should, if possible, use to render their user interface. | ||
| /// | ||
| /// This is the first locale selected by the user and should be the user's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "should be the user's primary locale" begs some questions:
- What's the primary locale exactly?
- When would it not be the primary locale?
Including a link to a public document that covered this kind of thing would be helpful.
lib/ui/window.dart
Outdated
| /// This is the first locale selected by the user and should be the user's | ||
| /// primary locale. | ||
| /// | ||
| /// This is equivalent to `locales[0]` and will provide an empty non-null locale |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
locales.first
lib/ui/window.dart
Outdated
| if (_locales != null && _locales.length != 0) { | ||
| return _locales[0]; | ||
| } | ||
| return new Locale("", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to define a Locale.none constant and use that here.
lib/ui/window.dart
Outdated
| /// This is equivalent to `locales[0]` and will provide an empty non-null locale | ||
| /// if the [locales] list has not been set or is empty. | ||
| Locale get locale { | ||
| if (_locales != null && _locales.length != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_locales.isNotEmpty
lib/ui/window.dart
Outdated
| /// should, if possible, use to render their user interface. | ||
| /// | ||
| /// The list is ordered in order of priority, with lower-indexed locales being | ||
| /// preferred over higher-indexed ones. The zeroth element is the default [locale]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zeroth - first
Earlier, locales[0] was referred to as the "primary" locale.
lib/ui/window.dart
Outdated
| /// if the [locales] list has not been set or is empty. | ||
| Locale get locale { | ||
| if (_locales != null && _locales.length != 0) { | ||
| return _locales[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_locales.first
|
This is part of the fix for flutter/flutter#22642 |
flutter/engine@04c860f...8cc49ca git log 04c860f..8cc49ca --no-merges --oneline 8cc49ca Ensure that the isolate shutdown callback occurs in an isolate scope. (flutter/engine#6572) 04a1ffa Roll src/third_party/skia cb65ce7f77c9..3a0c66da5fc2 (10 commits) (flutter/engine#6571) 35340ce Pass full locale list with script and variant codes to framework (flutter/engine#6557) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
And update goldens. git log 04c860f..8cc49ca --no-merges --oneline 8cc49ca Ensure that the isolate shutdown callback occurs in an isolate scope. (flutter/engine#6572) 04a1ffa Roll src/third_party/skia cb65ce7f77c9..3a0c66da5fc2 (10 commits) (flutter/engine#6571) 35340ce Pass full locale list with script and variant codes to framework (flutter/engine#6557)
flutter/engine@04c860f...705738f git log 04c860f..705738f --no-merges --oneline 705738f Roll src/third_party/skia 3a0c66da5fc2..928db927f7fc (5 commits) (flutter/engine#6573) 8cc49ca Ensure that the isolate shutdown callback occurs in an isolate scope. (flutter/engine#6572) 04a1ffa Roll src/third_party/skia cb65ce7f77c9..3a0c66da5fc2 (10 commits) (flutter/engine#6571) 35340ce Pass full locale list with script and variant codes to framework (flutter/engine#6557) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
flutter/engine@04c860f...979de07 git log 04c860f..979de07 --no-merges --oneline 979de07 Add a CountDownLatch to fml with tests. (flutter/engine#6574) 705738f Roll src/third_party/skia 3a0c66da5fc2..928db927f7fc (5 commits) (flutter/engine#6573) 8cc49ca Ensure that the isolate shutdown callback occurs in an isolate scope. (flutter/engine#6572) 04a1ffa Roll src/third_party/skia cb65ce7f77c9..3a0c66da5fc2 (10 commits) (flutter/engine#6571) 35340ce Pass full locale list with script and variant codes to framework (flutter/engine#6557) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
flutter/engine@04c860f...607c05c git log 04c860f..607c05c --no-merges --oneline 607c05c Run all supported host unit tests on Cirrus. (flutter/engine#6575) 979de07 Add a CountDownLatch to fml with tests. (flutter/engine#6574) 705738f Roll src/third_party/skia 3a0c66da5fc2..928db927f7fc (5 commits) (flutter/engine#6573) 8cc49ca Ensure that the isolate shutdown callback occurs in an isolate scope. (flutter/engine#6572) 04a1ffa Roll src/third_party/skia cb65ce7f77c9..3a0c66da5fc2 (10 commits) (flutter/engine#6571) 35340ce Pass full locale list with script and variant codes to framework (flutter/engine#6557) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
And update goldens. git log 04c860f..8cc49ca --no-merges --oneline 8cc49ca Ensure that the isolate shutdown callback occurs in an isolate scope. (flutter/engine#6572) 04a1ffa Roll src/third_party/skia cb65ce7f77c9..3a0c66da5fc2 (10 commits) (flutter/engine#6571) 35340ce Pass full locale list with script and variant codes to framework (flutter/engine#6557)
| const Locale(this._languageCode, [ this._countryCode ]) : assert(_languageCode != null); | ||
|
|
||
| /// Empty locale constant. This is an invalid locale. | ||
| static const Locale none = const Locale('', ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or just assert that it's never empty -- can we ever have no locale at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be a large string of calls that do not expect the returned locale to ever be null. I can look into changing it to do null checking though, since that is probably a more robust design in the long run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mostly applies to when the locale is accessed before the platform has had a chance to pass it over on startup. The empty locale would just result in the resolution to use the default (first) locale.
|
It seems as My device is API 19 and |
|
Ahh good catch, my bad, I'll fix that asap. |
|
This looks like it might have triggered flutter/flutter#23241 (see original fix in #4495) |
To properly support locale resolution, we now pass the full set of locales defined on the user's device instead of just the first one.
Full integration is pending #6481. Currently, the script and variant codes are not passed into the
Localeobject yet, which will be done once Locale supports it.