uucore: embed system locale on cargo install #8604
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes issue #8594 .
Previously, binaries installed via
cargo install
would only embed the English (en-US) locale. This change modifies theuucore/build.rs
script to detect the system's locale via theLANG
environment variable at compile time. It embeds the corresponding locale file if it exists, in addition to the mandatory English (en-US) fallback.Verification
I verified this fix by setting my system locale to French (
export LANG=fr_FR.UTF-8
), for which theyes
utility has an existing translation.cargo build --package uu_yes
../target/debug/yes --help
.The command correctly displayed the help text in French, confirming that the build script now successfully embeds the user's system locale.
Testing with a Chinese locale (
zh_CN
) correctly resulted in a fallback to English, as no Chinese translation file currently exists for theyes
utility. This demonstrates the fallback mechanism is working as expected.