#locale #localization #no-std

no-std sys-locale

Small and lightweight library to obtain the active system locale

8 releases

0.3.2 Nov 1, 2024
0.3.1 Aug 27, 2023
0.3.0 Apr 4, 2023
0.2.4 Mar 7, 2023
0.1.0 May 13, 2021

#3 in Internationalization (i18n)

Download history 63463/week @ 2024-08-20 66412/week @ 2024-08-27 71035/week @ 2024-09-03 58116/week @ 2024-09-10 63005/week @ 2024-09-17 67348/week @ 2024-09-24 72328/week @ 2024-10-01 68526/week @ 2024-10-08 69489/week @ 2024-10-15 66751/week @ 2024-10-22 70564/week @ 2024-10-29 78107/week @ 2024-11-05 82095/week @ 2024-11-12 75034/week @ 2024-11-19 66255/week @ 2024-11-26 72225/week @ 2024-12-03

307,968 downloads per month
Used in 282 crates (57 directly)

MIT/Apache

29KB
508 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 (and derivatives such as watchOS, tvOS, and visionOS)
  • 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.56.0. This will be bumped to a newer 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–2.4MB
~43K SLoC