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 use this in a command line program and properly parse POSIX locales? #339

Open
VorpalBlade opened this issue Feb 4, 2024 · 1 comment

Comments

@VorpalBlade
Copy link

Hi,

I'm evaluating options for localising one of my Rust command line programs. But I'm having some trouble wrapping my head around some of the features (or lack thereof in fluent). I would have opened a discussion instead, but it doesn't seem to be enabled for this repository.

How to I actually get from a (possibly mixed language) POSIX locale to the proper fluent configuration. E.g. consider my personal setting:

$ 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=

Here I want English messages but dates etc formatted in Swedish (this is a fairly common configuration among programmers in Sweden, since translated messages tend to be low quality and ungooglable, English proficiency is high, but we still prefer 24h time and sane date formatting).

  • Does fluent event support such mixed locales? Or is using a fluent a non-starter (since mixed locales is a hard requirement for me)?
  • How do you convert from POSIX locales to the "Unicode Language Identifiers" that fluent apparently uses (are they perhaps the same thing?).
  • I'm also having issues finding things like date formatting etc at all in https://docs.rs/fluent/latest/fluent/. Is that out of scope (e.g. fluent only handles LC_MESSAGES)? If so, is there a recommended combined approach to handling all of this properly (with mixed locale support of course)?
@alerque
Copy link
Collaborator

alerque commented May 6, 2024

These Fluent crates certainly provide the building blocks to handle most of this including mixed locales, but the fallback logic for exactly how you want to handle them would at least partially be on you. Honestly it sounds like you might be looking for something a little higher level like cargo-i18n for example, but mixed-locales are still a problem there too see cargo-i18n#114). That being said the date formatting in relation to locales is a bit different problem space than just setting up locale handling for your messages with some sort of fallback to choose the closest messages for your locale based on what you have to work with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants