Skip to content

Flutter-pi is not picking Locale from the system #284

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

Closed
eximius313 opened this issue Sep 3, 2022 · 8 comments
Closed

Flutter-pi is not picking Locale from the system #284

eximius313 opened this issue Sep 3, 2022 · 8 comments

Comments

@eximius313
Copy link

eximius313 commented Sep 3, 2022

Although I have /etc/default/locale configured as:

LANG=en_GB.UTF-8

flutter-pi is not picking this locale and displays warning instead:

[locales] Warning: The system has no configured locale. The default "C" locale may or may not be supported by the app.
==============Locale==============
Flutter locale:
  default: C
  locales: C
===================================
@ardera
Copy link
Owner

ardera commented Sep 4, 2022

flutter-pi gets its locale info from environment variables:
https://github.com/ardera/flutter-pi/blob/master/src/locales.c#L32-L56

First it checks LANGUAGE, then LC_ALL, then LC_MESSAGES and then LANG. If none of those are set it defaults to C.

Just putting it into /etc/default/locale might not be enough to make the system pickup the language. If you're on a pi, you can use raspi-config to configure the locale or otherwise you can use localectl and then update-locale.

@eximius313
Copy link
Author

eximius313 commented Sep 4, 2022

Both raspi-config and localectl are already set:

# localectl
System Locale: LANG=en_GB.UTF-8
VC Keymap: n/a
X11 Layout: us
X11 Model: pc105

so is LANG:

# echo $LANG
en_GB.UTF-8

@DoumanAsh
Copy link
Contributor

DoumanAsh commented Sep 5, 2022

@eximius313 is it the same if you just run env LANG=en_GB.UTF-8 ./flutter-pi?

@ardera
Copy link
Owner

ardera commented Sep 5, 2022

Can you send me your cmdline output when you run export? Maybe something else mistakenly sets LANGUAGE=C.UTF-8 and that overrides the LANG environment variable.

@eximius313
Copy link
Author

Ok, this is weird..
with reqular user, I get:

$ localectl
   System Locale: LANG=en_GB.UTF-8
       VC Keymap: n/a
      X11 Layout: us
       X11 Model: pc105

but:

$ echo "<$LANG>"
<>

with sudo, I get:

$ sudo echo "<$LANG>"
<>

but as a root I get:

# echo "<$LANG>"
<en_GB.UTF-8>

@DoumanAsh, when I run app like this:

$ LANGUAGE=LANG=en_GB.UTF-8 flutter-pi project
==============Locale==============
Flutter locale:
  default: en_GB
  locales: en_GB en.UTF-8 en.UTF-8 en.UTF-8 en_GB en en.UTF-8
===================================

Also

$ LANG=en_GB.UTF-8 flutter-pi project
==============Locale==============
Flutter locale:
  default: en_GB
  locales: en_GB en.UTF-8 en.UTF-8 en.UTF-8 en_GB en en.UTF-8

@ardera,
export output for root is indeed different than for my user (it has LANG set, while my user does not)
I have tried sudo locale-gen "en_GB.UTF-8" but without success...

It seems it's not the problem of flutter-pi but setting proper locale in user's shell.
Thanks for helping with pinpointing the issue

@eximius313
Copy link
Author

Ok, the problem is solved by enabling PAM....
https://askubuntu.com/a/749442

@eximius313
Copy link
Author

Damn... it is a bug in PAM that has over 10 years: https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/920749

@ardera
Copy link
Owner

ardera commented Sep 8, 2022

Oh lol
glad you could fix it though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants