Skip to content

feat(uucore): Add locale detection from LC_ALL and LC_MESSAGES#10570

Open
lordeji wants to merge 2 commits intouutils:mainfrom
lordeji:support-all-locale-env-var
Open

feat(uucore): Add locale detection from LC_ALL and LC_MESSAGES#10570
lordeji wants to merge 2 commits intouutils:mainfrom
lordeji:support-all-locale-env-var

Conversation

@lordeji
Copy link

@lordeji lordeji commented Jan 29, 2026

TL;DR

Fix #8922.


Implementation :

When creating the locale string, check in this order :
LC_ALL -> LC_MESSAGES -> LANG
According to the documentation on the precedence of each variable.

Important note : I did not include the LANGUAGE variable as it seems more specific to gettext and does not follow the the same pattern as the other variables (specify multiple languages).


Testing :

I'm using the devcontainer.
For completeness, here is the result of the locale command inside the container:

LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

Built successfully with

cargo build

Ran tests with no error

cargo nextest run -p uucore -p coreutils --no-fail-fast

Tried all these combinations which output the correct language

[FRENCH OUTPUT]
$ LANG=fr_FR.UTF-8 ./target/debug/coreutils split --help
$ LC_MESSAGES=fr_FR.UTF-8 ./target/debug/coreutils split --help
$ LC_ALL=fr_FR.UTF-8 ./target/debug/coreutils split --help

$ LC_MESSAGES=fr_FR.UTF-8 LANG=en_US.UTF-8 ./target/debug/coreutils split --help
$ LC_ALL=fr_FR.UTF-8 LC_MESSAGES=en_US.UTF-8 ./target/debug/coreutils split --help
$ LC_ALL=fr_FR.UTF-8 LANG=en_US.UTF-8 ./target/debug/coreutils split --help


[ENGLISH OUTPUT]
$ LC_MESSAGES=en_US.UTF-8 LANG=fr_FR.UTF-8 ./target/debug/coreutils split --help
$ LC_ALL=en_US.UTF-8 LC_MESSAGES=fr_FR.UTF-8 ./target/debug/coreutils split --help
$ LC_ALL=en_US.UTF-8 LANG=fr_FR.UTF-8 ./target/debug/coreutils split --help

Testing :

  • I had to update test_env_french() test function because LANG was overidden by LC_ALL or LC_MESSAGES

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/cut/cut. tests/cut/cut is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/expr/expr. tests/expr/expr is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/join/join. tests/join/join is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/uniq/uniq. tests/uniq/uniq is passing on 'main'. Maybe you have to rebase?

@sylvestre
Copy link
Contributor

It regressed a bunch of tests

@lordeji
Copy link
Author

lordeji commented Jan 30, 2026

@sylvestre Indeed, gonna install the github actions extensions and update the PR when the test are ok (so I won't waste actions and times).

By the way, do you think a workflow should be added ?

@sylvestre sylvestre force-pushed the support-all-locale-env-var branch from 5306c6d to 1316b7e Compare February 4, 2026 20:46
@lordeji lordeji marked this pull request as draft February 7, 2026 13:24
The order for checking is :
LC_ALL -> LC_MESSAGES -> LANG -> DEFAULT_LOCALE (fallback).
LANG was overidden by LC_ALL or LC_MESSAGES which was failing test
by not setting the language to french.
@lordeji lordeji force-pushed the support-all-locale-env-var branch from f1fe0bb to 9cebacf Compare February 17, 2026 21:05
@lordeji lordeji marked this pull request as ready for review February 17, 2026 21:05
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

Successfully merging this pull request may close these issues.

l10n: LC_ALL is ignored

2 participants