TravisCI Build Status AppVeyor Build Status Crates.io Version Docs.rs

locale_config

Remembers locale configuration per-thread and per-process and initializes the values by inspecting the system for user preferences.

Installation

You can depend on this library by adding locale_config to your Cargo dependencies:

toml [dependencies] locale_config = "*"

Usually it is not recommended to depend on *, but in this case it is important that incompatible version requirements don't cause multiple versions to be pulled in the final binary, so I do recommend it here and promise I will maintain good compatibility. Just please don't add traits to the types defined here to avoid conflicts with potential future methods.

Using

Usually you want to use this indirectly via a localization crate like locale. However if you need to work with the identifier itself, or you need to override it, use

rust Locale::current()

to find what you should be using at any given point in the application,

rust Locale::set_current()

to override it for current thread and

rust Locale::set_global_default()

to override it for new threads.

In case you need to access the initial value, you'll find it under

rust Locale::user_default()

The value may contain language tags specific for various localization aspects, called categories, and fallbacks. The Locale::tags_for method will take care of selecting relevant tags for you. For preferred language of translations, use

rust Locale::current().tags_for("messages")

For formatting, use categories "numeric" for numbers, "time" for date and time and "monetary" for money amounts. And use "collate" for collation.

Note that this crate does not itself provide any translation, formatting nor collation functionality. Formatting and collation will be provided by locale crate, translation has multiple available implementations.

See full documentation on Docs.rs or github.

Supported systems

Changelog

0.2.3

0.2.2

0.2.1

0.2.0

0.1.1

0.1.0