Skip to content

How to use this in a command line program and properly parse POSIX locales? #339

@VorpalBlade

Description

@VorpalBlade

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)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions