#localization #bcp47 #ietf #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

#229 in Internationalization (i18n)

Download history 626/week @ 2024-12-13 410/week @ 2024-12-20 367/week @ 2024-12-27 412/week @ 2025-01-03 611/week @ 2025-01-10 509/week @ 2025-01-17 321/week @ 2025-01-24 282/week @ 2025-01-31 357/week @ 2025-02-07 472/week @ 2025-02-14 558/week @ 2025-02-21 530/week @ 2025-02-28 545/week @ 2025-03-07 561/week @ 2025-03-14 477/week @ 2025-03-21 468/week @ 2025-03-28

2,131 downloads per month
Used in 3 crates

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