Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale null countryCode in flutter internationalization #16667

Closed
pq opened this issue Apr 17, 2018 · 4 comments · Fixed by flutter/website#4222
Closed

Locale null countryCode in flutter internationalization #16667

pq opened this issue Apr 17, 2018 · 4 comments · Fixed by flutter/website#4222
Labels
a: internationalization Supporting other languages or locales. (aka i18n) framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list

Comments

@pq
Copy link
Contributor

pq commented Apr 17, 2018

From @MarkBriggs2 on April 17, 2018 14:40

Question about #internationalization
Working through the tutorial at https://flutter.io/tutorials/internationalization/

Source at:
https://github.com/flutter/website/tree/master/_includes/code/internationalization/intl/

If supportedLocales parameter to MaterialApp constructor is as follows:

supportedLocales: [
    const Locale('en', 'US'), 
    const Locale('es', 'ES'), 
  ],

this initially works. If country codes are omitted:

supportedLocales: [
    const Locale('en'), 
    const Locale('es'), 
  ],

then the countryCode getter of the Locale object passed to DemoLocalizations.load() or GlobalMaterializations._computeLocaleName(Locale locale) (material_localizations.dart line 134) will be null so any attempt to access locale.countryCode.isEmpty will generate a NoSuchMethodError.
Is this as intended?
Thanks

Copied from original issue: flutter/flutter-intellij#2093

@MarkBriggs2
Copy link

MarkBriggs2 commented Apr 19, 2018

Locale constructor is:

const Locale(this._languageCode, [ this._countryCode ]) : assert(_languageCode != null);

If altering member _countryCode to default to empty string is not recommended, then perhaps the solution may be to alter GlobalMaterializations._computeLocaleName(Locale locale) (from material_localizations.dart) to check for null. Then modify the tutorial so that the app specific localization instance's load() does the same.
Just a suggestion...:)

@hyochan
Copy link

hyochan commented May 1, 2018

I am facing below error in real device. don't know why.

Xcode build done.
Installing and launching...
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
    import weakref
  File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref
flutter: locale: en_US
flutter: locale: ko_KR
Syncing files to device 장효찬의 iPhone...
flutter: Load en
[VERBOSE-2:dart_error.cc(16)] Unhandled exception:

@zoechi zoechi added a: internationalization Supporting other languages or locales. (aka i18n) framework flutter/packages/flutter repository. See also f: labels. labels Jul 26, 2018
@cbracken
Copy link
Member

@dooboolab do you mean the Python error? If so, I believe that should be fixed via #19281. It should make it to the next beta release. You can verify that on dev channel via flutter channel dev (flutter channel beta to switch back to beta channel).

If you mean the unhandled exception below that, it looks like the exception and any stack trace were truncated from your post. If you're still seeing this, would you mind opening a new bug with a verbose log (flutter --verbose run ...)?

@zoechi zoechi added this to the Goals milestone Jan 30, 2019
@jmagman jmagman added this to Awaiting Triage in Mobile - localization & intl Feb 25, 2020
@kf6gpe kf6gpe added the P2 Important issues not at the top of the work list label May 29, 2020
Mobile - localization & intl automation moved this from Awaiting Triage to Engineer Reviewed Jun 15, 2020
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: internationalization Supporting other languages or locales. (aka i18n) framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list
Projects
Mobile - localization & intl
  
Engineer Reviewed
Development

Successfully merging a pull request may close this issue.

6 participants