2 releases

0.1.1 Aug 26, 2021
0.1.0 Aug 26, 2021

#175 in Internationalization (i18n)

Download history 1087/week @ 2024-03-29 749/week @ 2024-04-05 590/week @ 2024-04-12 847/week @ 2024-04-19 693/week @ 2024-04-26 853/week @ 2024-05-03 829/week @ 2024-05-10 650/week @ 2024-05-17 590/week @ 2024-05-24 658/week @ 2024-05-31 474/week @ 2024-06-07 466/week @ 2024-06-14 908/week @ 2024-06-21 696/week @ 2024-06-28 697/week @ 2024-07-05 581/week @ 2024-07-12

2,946 downloads per month
Used in leptos-fluent

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