Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions i18n-embed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion i18n-embed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion i18n-embed/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 4 additions & 9 deletions i18n-embed/src/requester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.*
Expand Down Expand Up @@ -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<unic_langid::LanguageIdentifier> {
use locale_config::{LanguageRange, Locale};

let current_locale = Locale::current();

let ids: Vec<unic_langid::LanguageIdentifier> = current_locale
.tags_for("messages")
.filter_map(|tag: LanguageRange<'_>| match tag.to_string().parse() {
let ids: Vec<unic_langid::LanguageIdentifier> = sys_locale::get_locales()
.filter_map(|tag| match tag.parse() {
Ok(tag) => Some(tag),
Err(err) => {
log::error!("Unable to parse your locale: {:?}", err);
Expand Down
6 changes: 3 additions & 3 deletions i18n/po/de/cargo_i18n.po
Original file line number Diff line number Diff line change
Expand Up @@ -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\"."
Expand Down
12 changes: 6 additions & 6 deletions i18n/po/fr/cargo_i18n.po
Original file line number Diff line number Diff line change
Expand Up @@ -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\"."
Expand All @@ -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 "
Expand Down
12 changes: 6 additions & 6 deletions i18n/po/ru/cargo_i18n.po
Original file line number Diff line number Diff line change
Expand Up @@ -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\"."
Expand All @@ -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\". Вы можете включить протоколирование отладки, используя "
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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. \
Expand Down
Loading