| 1 |
# sys-locale |
| 2 |
|
| 3 |
[](https://crates.io/crates/sys-locale) |
| 4 |
[](https://docs.rs/sys-locale) |
| 5 |
 |
| 6 |
[](https://crates.io/crates/sys-locale) |
| 7 |
 |
| 8 |
|
| 9 |
A small and lightweight Rust library to get the current active locale on the system. |
| 10 |
|
| 11 |
`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. |
| 12 |
|
| 13 |
Platform support currently includes: |
| 14 |
- Android |
| 15 |
- iOS |
| 16 |
- macOS |
| 17 |
- Linux, BSD, and other UNIX variations |
| 18 |
- WebAssembly, for the following platforms: |
| 19 |
- Inside of a web browser (via the `js` feature) |
| 20 |
- Emscripten (via the `UNIX` backend) |
| 21 |
Further support for other WASM targets is dependent on upstream |
| 22 |
support in those target's runtimes and specifications. |
| 23 |
- Windows |
| 24 |
|
| 25 |
```rust |
| 26 |
use sys_locale::get_locale; |
| 27 |
|
| 28 |
let locale = get_locale().unwrap_or_else(|| String::from("en-US")); |
| 29 |
|
| 30 |
println!("The current locale is {}", locale); |
| 31 |
``` |
| 32 |
|
| 33 |
## MSRV |
| 34 |
|
| 35 |
The Minimum Supported Rust Version is currently 1.48.0. This will be bumped to the latest stable version of Rust when needed. |
| 36 |
|
| 37 |
## Credits |
| 38 |
|
| 39 |
Made with ❤️ by the [1Password](https://1password.com/) team. |
| 40 |
|
| 41 |
#### License |
| 42 |
|
| 43 |
<sup> |
| 44 |
Licensed under either of <a href="LICENSE-APACHE">Apache License, Version |
| 45 |
2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option. |
| 46 |
</sup> |
| 47 |
|
| 48 |
<br> |
| 49 |
|
| 50 |
<sub> |
| 51 |
Unless you explicitly state otherwise, any contribution intentionally submitted |
| 52 |
for inclusion in this crate by you, as defined in the Apache-2.0 license, shall |
| 53 |
be dual licensed as above, without any additional terms or conditions. |
| 54 |
</sub> |