momo
November 3, 2024, 4:04am
1
I am having some interesting results when I cross-compile using 6.0.2 SDK to Ubuntu Linux vs running app on my local Mac. Detecting locale seems to be off when using Locale.current. My machine's locale is set to American English but when loading printing the locale it always defaults to en_001 (which I believe is world English).
Has anyone experienced the same issue?
Ubuntu Linux locale is set to en_US, here's the output from terminal.
production:~$: locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
print(Locale.current) //`Locale en_001 (fixed en_001) on Linux`
print(Locale.current) //`Locale en_US on macOS`
Cyberbeni
(Benedek Kozma)
August 1, 2025, 8:07am
2
It's hardcoded to en_001 on non-Apple platforms:
opened 03:59AM - 05 Mar 23 UTC
I'm using Swift Language on a Linux system
My OS Distro is Fedora 37 on an AR… M64 CPU
I'm using Swift version 5.7.3 (swift-5.7.3-RELEASE) from the Fedora repos
I'm using GNOME desktop and have set my user session language to spanish, and my region to Mexico
When I run the `locale` command on a terminal, I get this output:
```
LANG=es_ES.UTF-8
LC_CTYPE="es_ES.UTF-8"
LC_NUMERIC=es_MX.UTF-8
LC_TIME=es_MX.UTF-8
LC_COLLATE="es_ES.UTF-8"
LC_MONETARY=es_MX.UTF-8
LC_MESSAGES="es_ES.UTF-8"
LC_PAPER=es_MX.UTF-8
LC_NAME="es_ES.UTF-8"
LC_ADDRESS="es_ES.UTF-8"
LC_TELEPHONE="es_ES.UTF-8"
LC_MEASUREMENT=es_MX.UTF-8
LC_IDENTIFICATION="es_ES.UTF-8"
LC_ALL=
```
But when I reference Locale.current, either on a compiled program, or from the Swift REPL, I get a "en_US" Locale. For example, if I run `print (Locale.current.identifier)` on the REPL, i get:
```
en_US
```
I think the expected behavior is that Locale.current returns the same locale from my user settings. Or am I missing something?
I tried submitting a PR to handle LANG but it's been pretty much ignored.