Skip to content

Improve correctness of POSIX locale conversion #6575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Finchiedev
Copy link
Contributor

Addressing #6573, this PR implements the requested changes to how env_preferences converts POSIX locales to ICU4X locales:

  • The default C/POSIX locale now maps to en-US-posix instead of und-posix
  • All other locales no longer have the -posix variant added

Thanks to @hsivonen for clarifying how it should be done! Please let me know if there's anything I can do to help in the review process :)

Only appends the `-posix` variant if the locale is "C" or "POSIX".
Should address the second half of unicode-org#6573:
unicode-org#6573
@Finchiedev Finchiedev requested a review from a team as a code owner May 10, 2025 06:19
Copy link

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

Thanks to @hsivonen for linking to the documentation!
/// );
/// # Ok(())
/// # }
/// ```
pub fn try_convert_lossy(&self) -> Result<Locale, ParseError> {
let mut extensions = Extensions::new();
let mut script = None;
let mut variants = Vec::new();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment in line 310 is obsolete

/// This is based on GNU libc's `intl/locale.alias` file, with some manual processing
/// to remove duplicates. The original file is available at:
/// to remove duplicates. The notable exception is that the default `C`/`POSIX` locales
/// map to `en-US`. The original file is available at:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// map to `en-US`. The original file is available at:
/// map to `en-US-posix`. The original file is available at:

/// This is based on GNU libc's `intl/locale.alias` file, with some manual processing
/// to remove duplicates. The original file is available at:
/// to remove duplicates. The notable exception is that the default `C`/`POSIX` locales
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// to remove duplicates. The notable exception is that the default `C`/`POSIX` locales
/// to remove duplicates. The notable addition is that the default `C`/`POSIX` locales

Copy link
Member

@hsivonen hsivonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but while at it, let's remove the obsolete aliases.

"swedish" => Some((language!("sv"), Some(region!("SE")))),
"thai" => Some((language!("th"), Some(region!("TH")))),
"turkish" => Some((language!("tr"), Some(region!("TR")))),
match posix_locale {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this whole match block to remove the language name checks and unify the "C" and "POSIX" case handling with the block below where you currently append -posix.

The X11 (see https://www.x.org/releases/X11R6.9.0/src-single/X11R6.9.0-src.tar.bz2 ) language name aliases are obsolete, so we shouldn't carry the data or spend time matching them. They resolved to legacy-encoding locales and present-day distros generate UTF-8 locales, so even on the libc-level the aliases don't resolve to an available locale and result in C.

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.

3 participants