Skip to content
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

How to actually convert system locale to ICU locale(s)? #4580

Closed
VorpalBlade opened this issue Feb 4, 2024 · 2 comments
Closed

How to actually convert system locale to ICU locale(s)? #4580

VorpalBlade opened this issue Feb 4, 2024 · 2 comments
Labels
C-locale Component: Locale identifiers, BCP47 duplicate This issue or pull request already exists

Comments

@VorpalBlade
Copy link

VorpalBlade commented Feb 4, 2024

Hi,

I'm looking into options for localising one of my Rust command line program, and I'm a bit confused about icu4x: How do you actually get from a system locale to the proper ICU4X settings? E.g. consider something like this mixed POSIX locale (what I actually use):

$ locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC=sv_SE.UTF-8
LC_TIME=sv_SE.UTF-8
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY=sv_SE.UTF-8
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER=sv_SE.UTF-8
LC_NAME=sv_SE.UTF-8
LC_ADDRESS=sv_SE.UTF-8
LC_TELEPHONE=sv_SE.UTF-8
LC_MEASUREMENT=sv_SE.UTF-8
LC_IDENTIFICATION=sv_SE.UTF-8
LC_ALL=

In which ICU crate is the logic to resolve this (and whatever Windows and Mac OS uses, I'm not familiar with programming on those platforms) to the proper locale to use in ICU4X for each feature?

(The reason I use a mixed locale like this, and also many other people I know do, is that message translations tend to be poor and translated error messages ungooglable. But I still want Swedish dates, 24 hour dates, decimal comma, etc)

In addition, what part of ICU4X handles message translation? Looking at the module list in https://docs.rs/icu/latest/icu/ I don't see anything for that. E.g. something like gettext would provide traditionally. Or is that out of scope of this project?

@zbraniecki
Copy link
Member

ICU4X does not provide any runtime bindings and does not introspect runtime environment for information such as selected locale.

It leaves it to the customer of the system to read host environment settings (such as POSIX locale, Windows Regional Preferences etc.) and provide that to constructors.

As for localization, we intend to bring ICU MessageFormat 2.0 API once it is completed.

@sffc sffc added C-locale Component: Locale identifiers, BCP47 duplicate This issue or pull request already exists labels Feb 5, 2024
@sffc
Copy link
Member

sffc commented Feb 5, 2024

Issue to track adding OS locale bindings to ICU4X: #3990

Closing as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-locale Component: Locale identifiers, BCP47 duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants