#localization #locale

current_locale

A library to get the user's current locale

2 releases

0.1.1 Aug 26, 2021
0.1.0 Aug 26, 2021

#217 in Internationalization (i18n)

Download history 213/week @ 2023-05-16 215/week @ 2023-05-23 306/week @ 2023-05-30 400/week @ 2023-06-06 423/week @ 2023-06-13 374/week @ 2023-06-20 259/week @ 2023-06-27 252/week @ 2023-07-04 412/week @ 2023-07-11 316/week @ 2023-07-18 395/week @ 2023-07-25 327/week @ 2023-08-01 473/week @ 2023-08-08 353/week @ 2023-08-15 325/week @ 2023-08-22 325/week @ 2023-08-29

1,513 downloads per month
Used in 4 crates (via mcvm_shared)

MIT/Apache

13KB
178 lines

current_locale

A rust library for getting the current locale as a language code. The language code returned is in a BCP47 (IETF) format.

Platform support

Platform Implemented
Windows Yes
Unix Yes
macOS Yes
Android No
iOS Not fully tested

The library exposes a single function to get the user's locale from the OS

pub fn current_locale() -> Result<String, LocaleError> {
    // Method Implementation...
}

The method either returns a string containing the user's locale as a language code or an error when retrieving the locale from the OS.

Dependencies

os-locale tries to use a few dependencies as possible. However we do necessarily require dependencies on some platforms:

Platform Dependencies
Windows winapi, libc
Unix None
macOS & iOS objc, objc-foundation

License

os-locale is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See the LICENSE-APACHE and LICENSE-MIT files in this repository for more information.

Dependencies

~220KB