diff --git a/Cargo.lock b/Cargo.lock index 317ea11..48a24bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -600,7 +600,6 @@ dependencies = [ "gettext", "i18n-embed-impl", "intl-memoizer", - "locale_config", "log", "maplit", "notify", @@ -608,6 +607,7 @@ dependencies = [ "pretty_assertions", "rust-embed", "serial_test", + "sys-locale", "thiserror 1.0.69", "tr", "unic-langid", @@ -1227,6 +1227,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sys-locale" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4" +dependencies = [ + "libc", +] + [[package]] name = "temp-dir" version = "0.1.16" diff --git a/i18n-embed/Cargo.toml b/i18n-embed/Cargo.toml index 198966e..0044b67 100644 --- a/i18n-embed/Cargo.toml +++ b/i18n-embed/Cargo.toml @@ -25,7 +25,7 @@ fluent-syntax = { workspace = true, optional = true } gettext = { workspace = true, optional = true } i18n-embed-impl = { workspace = true, optional = true } intl-memoizer = "0.5" -locale_config = { version = "0.3", optional = true } +sys-locale = { version = "0.3", optional = true } log = { workspace = true } notify = { version = "8.0.0", optional = true } parking_lot = { version = "0.12", optional = true } @@ -49,7 +49,7 @@ default = ["rust-embed"] gettext-system = ["tr", "tr/gettext", "dep:gettext", "parking_lot", "i18n-embed-impl", "i18n-embed-impl/gettext-system"] fluent-system = ["fluent", "fluent-syntax", "parking_lot", "i18n-embed-impl", "i18n-embed-impl/fluent-system", "arc-swap"] -desktop-requester = ["locale_config"] +desktop-requester = ["sys-locale"] web-sys-requester = ["web-sys"] filesystem-assets = ["walkdir"] diff --git a/i18n-embed/README.md b/i18n-embed/README.md index de3fff6..63b4700 100644 --- a/i18n-embed/README.md +++ b/i18n-embed/README.md @@ -15,7 +15,7 @@ The `i18n-embed` crate has the following optional Cargo features: + `gettext-system` + Enable support for the [gettext](https://www.gnu.org/software/gettext/) localization system using the [tr macro](https://docs.rs/tr/0.1.3/tr/) and the [gettext crate](https://docs.rs/gettext/0.4.0/gettext/) via the `GettextLanguageLoader`. + `desktop-requester` - + Enables a convenience implementation of `LanguageRequester` trait called `DesktopLanguageRequester` for the desktop platform (windows, mac, linux),which makes use of the [locale_config](https://crates.io/crates/locale_config) crate for resolving the current system locale. + + Enables a convenience implementation of `LanguageRequester` trait called `DesktopLanguageRequester` for the desktop platform (windows, mac, linux),which makes use of the [sys-locale](https://crates.io/crates/sys-locale) crate for resolving the current system locale. + `web-sys-requester` + Enables a convenience implementation of `LanguageRequester` trait called `WebLanguageRequester` which makes use of the [web-sys](https://crates.io/crates/web-sys) crate for resolving the language being requested by the user's web browser in a WASM context. diff --git a/i18n-embed/src/lib.rs b/i18n-embed/src/lib.rs index 7f8a7bb..e48cc50 100644 --- a/i18n-embed/src/lib.rs +++ b/i18n-embed/src/lib.rs @@ -38,7 +38,7 @@ //! [LanguageRequester](LanguageRequester) trait called //! `DesktopLanguageRequester for the desktop platform (windows, //! mac, linux), which makes use of the -//! [locale_config](https://crates.io/crates/locale_config) crate +//! [sys-locale](https://crates.io/crates/sys-locale) crate //! for resolving the current system locale. //! + `web-sys-requester` //! + Enables a convenience implementation of diff --git a/i18n-embed/src/requester.rs b/i18n-embed/src/requester.rs index b30d880..8e6c247 100644 --- a/i18n-embed/src/requester.rs +++ b/i18n-embed/src/requester.rs @@ -222,7 +222,7 @@ impl std::fmt::Debug for LanguageRequesterImpl<'_> { /// A [LanguageRequester](LanguageRequester) for the desktop platform, /// supporting windows, linux and mac. It uses -/// [locale_config](locale_config) to select the language based on the +/// [sys-locale](sys-locale) to select the language based on the /// system selected language. /// /// ⚠️ *This API requires the following crate features to be activated: `desktop-requester`.* @@ -283,16 +283,11 @@ impl DesktopLanguageRequester<'_> { } /// The languages being requested by the operating - /// system/environment according to the [locale_config] crate's + /// system/environment according to the [sys-locale] crate's /// implementation. pub fn requested_languages() -> Vec { - use locale_config::{LanguageRange, Locale}; - - let current_locale = Locale::current(); - - let ids: Vec = current_locale - .tags_for("messages") - .filter_map(|tag: LanguageRange<'_>| match tag.to_string().parse() { + let ids: Vec = sys_locale::get_locales() + .filter_map(|tag| match tag.parse() { Ok(tag) => Some(tag), Err(err) => { log::error!("Unable to parse your locale: {:?}", err); diff --git a/i18n/po/de/cargo_i18n.po b/i18n/po/de/cargo_i18n.po index 998b91a..0824be1 100644 --- a/i18n/po/de/cargo_i18n.po +++ b/i18n/po/de/cargo_i18n.po @@ -36,9 +36,9 @@ msgid "" "inside your application.\n" "\n" "The display language used for this command is selected automatically using " -"your system settings (as described at \n" -"https://github.com/rust-locale/locale_config#supported-systems ) however you " -"can override it using the -l, --language option.\n" +"your system settings (as returned by \n" +"https://github.com/1Password/sys-locale?tab=readme-ov-file#sys-locale ) " +"however you can override it using the -l, --language option.\n" "\n" "Logging for this command is available using the \"env_logger\" crate. You " "can enable debug logging using \"RUST_LOG=debug cargo i18n\"." diff --git a/i18n/po/fr/cargo_i18n.po b/i18n/po/fr/cargo_i18n.po index a5d539b..768aa06 100644 --- a/i18n/po/fr/cargo_i18n.po +++ b/i18n/po/fr/cargo_i18n.po @@ -42,9 +42,9 @@ msgid "" "inside your application.\n" "\n" "The display language used for this command is selected automatically using " -"your system settings (as described at \n" -"https://github.com/rust-locale/locale_config#supported-systems ) however you " -"can override it using the -l, --language option.\n" +"your system settings (as returned by \n" +"https://github.com/1Password/sys-locale?tab=readme-ov-file#sys-locale ) " +"however you can override it using the -l, --language option.\n" "\n" "Logging for this command is available using the \"env_logger\" crate. You " "can enable debug logging using \"RUST_LOG=debug cargo i18n\"." @@ -65,9 +65,9 @@ msgstr "" "les localisations dans votre application.\n" "\n" "La langue d'affichage utilisée pour cette commande est sélectionnée " -"automatiquement à l'aide des paramètres de votre système (comme décrit dans\n" -"https://github.com/rust-locale/locale_config#supported-systems ) mais vous " -"pouvez le remplacer en utilisant l'option -l, --language.\n" +"automatiquement à l'aide des paramètres de votre système (comme retourné par\n" +"https://github.com/1Password/sys-locale?tab=readme-ov-file#sys-locale )\n" +"mais vous pouvez le remplacer en utilisant l'option -l, --language.\n" "\n" "La journalisation de cette commande est disponible à l'aide de la caisse " "\"env_logger\". Vous pouvez activer la journalisation de débogage en " diff --git a/i18n/po/ru/cargo_i18n.po b/i18n/po/ru/cargo_i18n.po index 9a7963b..c6d0e58 100644 --- a/i18n/po/ru/cargo_i18n.po +++ b/i18n/po/ru/cargo_i18n.po @@ -34,9 +34,9 @@ msgid "" "inside your application.\n" "\n" "The display language used for this command is selected automatically using " -"your system settings (as described at \n" -"https://github.com/rust-locale/locale_config#supported-systems ) however you " -"can override it using the -l, --language option.\n" +"your system settings (as returned by \n" +"https://github.com/1Password/sys-locale?tab=readme-ov-file#sys-locale ) " +"however you can override it using the -l, --language option.\n" "\n" "Logging for this command is available using the \"env_logger\" crate. You " "can enable debug logging using \"RUST_LOG=debug cargo i18n\"." @@ -56,9 +56,9 @@ msgstr "" "локализаций в ваше приложение.\n" "\n" "Язык отображения, используемый для этой команды, выбирается автоматически с " -"использованием системных настроек (как описано в\n" -"https://github.com/rust-locale/locale_config#supported-systems ) однако вы " -"можете переопределить его, используя -l, --language option.\n" +"использованием системных настроек (как возвращается\n" +"https://github.com/1Password/sys-locale?tab=readme-ov-file#sys-locale ) однако " +"вы можете переопределить его, используя опцию -l, --language.\n" "\n" "Протоколирование для этой команды доступно с использованием крэйтора " "\"env_logger\". Вы можете включить протоколирование отладки, используя " diff --git a/src/main.rs b/src/main.rs index a2d3741..0cb500c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,7 +63,7 @@ localizations inside your application. The display language used for this command is selected automatically \ using your system settings (as described at -https://github.com/rust-locale/locale_config#supported-systems ) \ +https://github.com/1Password/sys-locale?tab=readme-ov-file#sys-locale ) \ however you can override it using the -l, --language option. Logging for this command is available using the \"env_logger\" crate. \