# Locale Detection

**URL:** <https://forums.swift.org/t/locale-detection/75783>\
**Category:** Using Swift\
**Tags:** cross-compilation\
**Created:** [November 3, 2024, 4:04am UTC](https://forums.swift.org/t/locale-detection/75783 "2024-11-03T04:04:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![momo](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@momo](https://forums.swift.org/u/momo)\
**Post date:** [November 3, 2024, 4:04am UTC](https://forums.swift.org/t/locale-detection/75783/1 "2024-11-03T04:04:06Z")

</div>

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.

```swift
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=

```

```swift
print(Locale.current) //`Locale en_001 (fixed en_001) on Linux`
print(Locale.current) //`Locale en_US on macOS`

```

---

<div class="post-metadata">

**Author:** ![Cyberbeni](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/cyberbeni/32/46241_2.png) [@Cyberbeni](https://forums.swift.org/u/Cyberbeni)\
**Post date:** [August 1, 2025, 8:07am UTC](https://forums.swift.org/t/locale-detection/75783/2 "2025-08-01T08:07:29Z")

</div>

It's hardcoded to en\_001 on non-Apple platforms:

> <https://github.com/swiftlang/swift-foundation/issues/717>
>
> 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.
