Repository navigation
locale: honor LC_ALL and LC_MESSAGES precedence over LANG - #13331
costajohnt wants to merge 1 commit into
Conversation
|
GNU testsuite comparison: |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
181d188 to
14822ba
Compare
|
Binary size comparison: |
c557bb2 to
913aa3f
Compare
913aa3f to
12c9701
Compare
12c9701 to
508efc9
Compare
1bf0246 to
d08925e
Compare
|
Anything else needed from my side here? Checks are green and it merges cleanly. |
5dddf46 to
e4cffed
Compare
e4cffed to
dbdf3c7
Compare
dbdf3c7 to
793c2ee
Compare
| return default(); | ||
| } | ||
|
|
||
| if let Some(language) = lookup("LANGUAGE").filter(|value| !value.is_empty()) { |
There was a problem hiding this comment.
the LANGUAGE handling isn't in the description and isn't needed for #8922.
please split it into a separate PR and keep this one to LC_ALL/LC_MESSAGES
| LanguageIdentifier::from_str(&locale_str).map_err(|_| { | ||
| LocalizationError::ParseLocale(format!("Failed to parse locale: {locale_str}")) | ||
| }) | ||
| /// Resolve the message-locale candidates from an environment lookup, applying |
There was a problem hiding this comment.
nobody will read a 25-line comment :) please make it shorter
| catalogs | ||
| } | ||
|
|
||
| thread_local! { |
There was a problem hiding this comment.
do we need this cache? the locales dir has only a few files
| /// gettext's territory stripping. Only consulted when there is no exact | ||
| /// catalog. | ||
| /// | ||
| /// [`DEFAULT_LOCALE`] is never returned: `en-US.ftl` always exists, so |
There was a problem hiding this comment.
please make this comment shorter too
| let localized = locales | ||
| .iter() | ||
| .take_while(|locale| **locale != default_locale) | ||
| .find_map(|locale| create_wasi_bundle_from_embedded(locale, p).ok()); |
There was a problem hiding this comment.
why does wasi not get the same-language fallback?
Message locale detection only read LANG. Use the POSIX order LC_ALL > LC_MESSAGES > LANG, skipping empty values, and share the lookup with i18n::get_locale_from_env. Tests that selected French through LANG alone now set LC_ALL, since the test harness sets LC_ALL=C by default. The GNU cut, expr, fold, join and uniq tests select their multibyte locale through LC_ALL while expecting English diagnostics, so build-gnu.sh moves that to LANG and pins LC_MESSAGES=C. Fixes uutils#8922 Co-authored-by: soldierboy <191002121+sunsss123soldier@users.noreply.github.com>
793c2ee to
1c90fa1
Compare
|
Done, this is now just LC_ALL/LC_MESSAGES, rebased on main and squashed. Your list-walk commit and the rest of the LANGUAGE work are saved on a branch, and your comments on that code will be answered in the separate LANGUAGE PR, which explains the GNU motivation up front. Without LANGUAGE, the GNU cut/expr/fold/join/uniq perl tests print French under their LC_ALL=fr_FR runs (cut.pl had 45 failures locally), so I took the build-gnu.sh sed and the shared lookup from #14870 and credited its author on the commit. That makes the two PRs overlap a lot now. Happy to close this one if you'd rather land #14870. |
Fixes #8922.
Message locale detection only read
LANG, soLC_ALLandLC_MESSAGESwere ignored. GNU honors all three, soLC_ALL=fr_FR.UTF-8 sleep --helpprints French there and English in uutils.This applies the POSIX precedence
LC_ALL>LC_MESSAGES>LANG. The first non-empty value wins, and with none set it falls back toen-USas before.LC_ALL=Cstill resolves to English through the existing fallback, so the English fast path from #16907 is unchanged.The lookup is a small
get_locale_env_var(category)helper inlocale.rs, shared withi18n::get_locale_from_env, which already did the same thing for other categories.docs/src/l10n.mdis updated to match.Tests
LC_ALL=CwithLANG=fr_FRgiving English.test_env_lc_all_c_overrides_langend to end.LANGalone now useLC_ALL, since the test harness setsLC_ALL=C.GNU tests
The GNU cut, expr, fold, join and uniq perl tests run their multibyte cases with
LC_ALL=fr_FR.UTF-8and expect English diagnostics, relying onLANGUAGE=C. Without LANGUAGE support they would now get French, sobuild-gnu.shmoves those toLANGand pinsLC_MESSAGES=C. This sed and the shared lookup come from #14870 (its author is credited on the commit). Locallytests/cut/cut.plhad 45 French-stderr failures without it and passes with it.LANGUAGE support will come as a separate PR.