#locale #i18n #localization #nostd

no-std sys-locale

Small and lightweight library to obtain the active system locale

7 releases

0.3.1 Aug 27, 2023
0.3.0 Apr 4, 2023
0.2.4 Mar 7, 2023
0.2.3 Nov 6, 2022
0.1.0 May 13, 2021

#7 in Internationalization (i18n)

Download history 49012/week @ 2023-11-07 55817/week @ 2023-11-14 43809/week @ 2023-11-21 44570/week @ 2023-11-28 44816/week @ 2023-12-05 41590/week @ 2023-12-12 32113/week @ 2023-12-19 26529/week @ 2023-12-26 41466/week @ 2024-01-02 42590/week @ 2024-01-09 53796/week @ 2024-01-16 44812/week @ 2024-01-23 51324/week @ 2024-01-30 46972/week @ 2024-02-06 48860/week @ 2024-02-13 45129/week @ 2024-02-20

200,284 downloads per month
Used in 107 crates (28 directly)

MIT/Apache

23KB
409 lines

sys-locale

crates.io version crate documentation MSRV crates.io downloads CI

A small and lightweight Rust library to get the current active locale on the system.

sys-locale is small library to get the current locale set for the system or application with the relevant platform APIs. The library is also no_std compatible, relying only on alloc, except on Linux and BSD.

Platform support currently includes:

  • Android
  • iOS
  • macOS
  • Linux, BSD, and other UNIX variations
  • WebAssembly, for the following platforms:
    • Inside of a web browser (via the js feature)
    • Emscripten (via the UNIX backend) Further support for other WASM targets is dependent on upstream support in those target's runtimes and specifications.
  • Windows
use sys_locale::get_locale;

let locale = get_locale().unwrap_or_else(|| String::from("en-US"));

println!("The current locale is {}", locale);

MSRV

The Minimum Supported Rust Version is currently 1.48.0. This will be bumped to the latest stable version of Rust when needed.

Credits

Made with ❤️ by the 1Password team.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0–2MB
~40K SLoC