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

Mixed locale support? #114

Open
VorpalBlade opened this issue Feb 4, 2024 · 6 comments
Open

Mixed locale support? #114

VorpalBlade opened this issue Feb 4, 2024 · 6 comments

Comments

@VorpalBlade
Copy link

Sorry if this is documented somewhere but I couldn't find it. How does mixed locale support work in this library? E.g. If I set LC_MESSAGES and LC_NUMERIC to different values?

I'm considering using this for a command line program of mine and proper mixed locale support is something I consider absolutely critical. I use it myself (I prefer English text due to poor translations, and poor searchability of translated errors. But I want Monday as first day of week, comma as the decimal separator, Swedish weekday names, 24h time, sane date format etc).

But before I invest time in using this I want to know that this fundamental feature is actually supported.

@kellpossible
Copy link
Owner

Hi @VorpalBlade , which localization system are you planning to use? Currently this library only supports gettext and fluent

@VorpalBlade
Copy link
Author

I'm not sure yet! I have tried to figure out to what extent fluent and gettext support mixed locales, without a great deal of success.

I'm actually leaning towards trying to use icu4x, but there message handling isn't implemented yet. It does however properly handle data formatting. Gettext seems to only do messages if I understand things correctly. And with fluent I haven't figured it out, and havent gotten any replies to my questions either.

@kellpossible
Copy link
Owner

I haven't tested yet, to be sure but I think maybe locale number formatting functionality is not yet available in the Rust implementation of fluent? Anyway I think you could probably combine icu4x with fluent using https://docs.rs/fluent/latest/fluent/bundle/struct.FluentBundle.html#method.add_function to implement this yourself, and https://docs.rs/i18n-embed/latest/i18n_embed/fluent/struct.FluentLanguageLoader.html#method.with_bundles_mut to modify the fluent bundle with this system. You could implement it in a way that places priority to the LC_NUMERIC environment variable if present.

@kellpossible
Copy link
Owner

As for gettext, I'm not sure, I haven't given any thought to the question yet. We currently use https://github.com/rust-locale/locale_config/ for https://docs.rs/i18n-embed/latest/i18n_embed/struct.DesktopLanguageRequester.html implementation, so if that library supports LC_NUMERIC then we can hopefully add support to it for gettext if it's not already working.

@VorpalBlade
Copy link
Author

Do note it is not just LC_NUMERIC, POSIX defines a bunch of these for date formatting, measurements, sorting order, etc. But whatever solution is applied for one of them will likely be similar for all of them.

@alerque
Copy link

alerque commented May 6, 2024

Number formatting based on locales is indeed not implemented at the moment in the Fluent crate(s). There is work in progress to use icu4x (fluent-rs#269 and fluent-rs#269) as well as provide the NUMBER() built in (fluent-rs#353). A DATETIME() implementation was also pointed out although not contributed yet (fluent-rs#181). Contributions are welcome and now that there are a couple more community maintainers we should actually be able to facilitate contributions getting merged and released.

Are there other pieces needed from the Fluent end of things related to this issue?

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

No branches or pull requests

3 participants