feat(i18n): Dutch locale — 8th bundled language
Ports PR #561 by @pbaart into the live gettext system (the PR translated the retired Svelte catalog): full nl.po (1481 msgids, 13 plurals, msgfmt-clean, zero untranslated), 262 strings taken directly from the contribution via the legacy-English bridge and the rest translated using the contributor's terminology as the style guide (nummer/afspeellijst/wachtrij/bibliotheek, informal je). qbz-i18n registration (2-form plural, resolve_auto nl_NL->nl, 21/21 tests) and the language dropdown at index 8 (Nederlands) across ui_prefs, reseed_i18n_labels and state.slint — same shape as the ru/ja commits. Dutch translation credit: pbaart (PR #561). cc
This commit is contained in:
6 files changed
+4498
-11
No files matched your search
@@ -14,7 +14,7 @@ use std::sync::atomic::{AtomicU8, Ordering};
|
||||
use std::sync::OnceLock;
|
||||
|
||||
/// Supported language codes, indexed by the value stored in [`CURRENT`].
|
||||
const LANGS: [&str; 7] = ["en", "es", "de", "fr", "pt", "ru", "ja"];
|
||||
const LANGS: [&str; 8] = ["en", "es", "de", "fr", "pt", "ru", "ja", "nl"];
|
||||
|
||||
/// Embedded `.po` sources. Path is relative to this file
|
||||
/// (`crates/qbz-i18n/src/lib.rs`): `../` = `qbz-i18n/`, `../../` = `crates/`.
|
||||
@@ -25,12 +25,14 @@ const PO_FR: &str = include_str!("../../qbz-ui/translations/fr/LC_MESSAGES/qbz-u
|
||||
const PO_PT: &str = include_str!("../../qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po");
|
||||
const PO_RU: &str = include_str!("../../qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po");
|
||||
const PO_JA: &str = include_str!("../../qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po");
|
||||
const PO_NL: &str = include_str!("../../qbz-ui/translations/nl/LC_MESSAGES/qbz-ui.po");
|
||||
|
||||
/// Current language index (0=en, 1=es, 2=de, 3=fr, 4=pt, 5=ru, 6=ja). Defaults to en.
|
||||
/// Current language index (0=en, 1=es, 2=de, 3=fr, 4=pt, 5=ru, 6=ja, 7=nl). Defaults to en.
|
||||
static CURRENT: AtomicU8 = AtomicU8::new(0);
|
||||
|
||||
/// Lazily-parsed catalogs, one slot per language.
|
||||
static CATALOGS: [OnceLock<Catalog>; 7] = [
|
||||
static CATALOGS: [OnceLock<Catalog>; 8] = [
|
||||
OnceLock::new(),
|
||||
OnceLock::new(),
|
||||
OnceLock::new(),
|
||||
OnceLock::new(),
|
||||
@@ -57,6 +59,7 @@ fn catalog(idx: u8) -> &'static Catalog {
|
||||
4 => PO_PT,
|
||||
5 => PO_RU,
|
||||
6 => PO_JA,
|
||||
7 => PO_NL,
|
||||
_ => PO_EN,
|
||||
};
|
||||
Catalog::parse(LANGS[idx], src)
|
||||
@@ -68,7 +71,7 @@ fn current_catalog() -> &'static Catalog {
|
||||
catalog(CURRENT.load(Ordering::Relaxed))
|
||||
}
|
||||
|
||||
/// Set the active language. Accepts `"en"|"es"|"de"|"fr"|"pt"`.
|
||||
/// Set the active language. Accepts `"en"|"es"|"de"|"fr"|"pt"|"ru"|"ja"|"nl"`.
|
||||
/// Unknown codes leave the current language unchanged.
|
||||
pub fn set_language(lang: &str) {
|
||||
if let Some(idx) = lang_index(lang) {
|
||||
@@ -256,6 +259,8 @@ mod tests {
|
||||
assert_eq!(resolve_auto(), "fr");
|
||||
std::env::set_var("LANG", "xx_XX");
|
||||
assert_eq!(resolve_auto(), "en");
|
||||
std::env::set_var("LANG", "nl_NL.UTF-8");
|
||||
assert_eq!(resolve_auto(), "nl");
|
||||
std::env::set_var("LC_MESSAGES", "de_DE.UTF-8");
|
||||
assert_eq!(resolve_auto(), "de");
|
||||
std::env::remove_var("LC_MESSAGES");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Minimal gettext `Plural-Forms` evaluator.
|
||||
//!
|
||||
//! We support the expressions our locales actually use:
|
||||
//! - `nplurals=2; plural=(n != 1);` (en, es, de, pt)
|
||||
//! - `nplurals=2; plural=(n != 1);` (en, es, de, pt, nl)
|
||||
//! - `nplurals=2; plural=(n > 1);` (fr)
|
||||
//! - `nplurals=1; plural=0;` (ja — no plural distinction)
|
||||
//! - `nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 &&
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -2950,7 +2950,7 @@ export global AppearanceState {
|
||||
// that lived here were superseded by the working interface-size presets
|
||||
// (`ui-scale-options` / `ui-scale-index` in the INTERFACE SIZE block
|
||||
// further down, wired to SLINT_SCALE_FACTOR in main.rs).
|
||||
in-out property <[string]> languages: [@tr("Auto"), "English", "Español", "Français", "Deutsch", "Português", "Русский", "日本語"];
|
||||
in-out property <[string]> languages: [@tr("Auto"), "English", "Español", "Français", "Deutsch", "Português", "Русский", "日本語", "Nederlands"];
|
||||
in-out property <int> language-index: 0;
|
||||
in-out property <[string]> fonts: ["LINE Seed JP", "Montserrat", "Noto Sans", "Source Sans 3", "System"];
|
||||
in-out property <int> font-index: 0;
|
||||
|
||||
@@ -3495,6 +3495,7 @@ fn reseed_i18n_labels(window: &AppWindow) {
|
||||
"Português".into(),
|
||||
"Русский".into(),
|
||||
"日本語".into(),
|
||||
"Nederlands".into(),
|
||||
])));
|
||||
state.set_immersive_search_actions(ModelRc::new(VecModel::from(vec![
|
||||
t("Disabled"),
|
||||
@@ -8986,9 +8987,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
"language" => {
|
||||
// 0 = Auto, 1 = English, 2 = Español, 3 = Français, 4 = Deutsch,
|
||||
// 5 = Português, 6 = Русский, 7 = 日本語. Persist the RAW user
|
||||
// choice ("auto" stays "auto"), but resolve "auto" to a concrete
|
||||
// language before switching the live translations.
|
||||
// 5 = Português, 6 = Русский, 7 = 日本語, 8 = Nederlands.
|
||||
// Persist the RAW user choice ("auto" stays "auto"), but resolve
|
||||
// "auto" to a concrete language before switching the live
|
||||
// translations.
|
||||
let chosen = crate::ui_prefs::language_for_index(index);
|
||||
let mut prefs = crate::ui_prefs::load();
|
||||
prefs.language = chosen.to_string();
|
||||
|
||||
@@ -45,8 +45,8 @@ pub const DEFAULT_LANGUAGE: &str = "auto";
|
||||
|
||||
/// Map a language select index to its persisted key. The on-screen order in
|
||||
/// `AppearanceState.languages` is Auto / English / Español / Français / Deutsch
|
||||
/// / Português / Русский / 日本語 (0-7); any unknown index falls back to the
|
||||
/// default (`"auto"`).
|
||||
/// / Português / Русский / 日本語 / Nederlands (0-8); any unknown index falls
|
||||
/// back to the default (`"auto"`).
|
||||
pub fn language_for_index(index: i32) -> &'static str {
|
||||
match index {
|
||||
1 => "en",
|
||||
@@ -56,6 +56,7 @@ pub fn language_for_index(index: i32) -> &'static str {
|
||||
5 => "pt",
|
||||
6 => "ru",
|
||||
7 => "ja",
|
||||
8 => "nl",
|
||||
_ => DEFAULT_LANGUAGE,
|
||||
}
|
||||
}
|
||||
@@ -71,6 +72,7 @@ pub fn language_index(key: &str) -> i32 {
|
||||
"pt" => 5,
|
||||
"ru" => 6,
|
||||
"ja" => 7,
|
||||
"nl" => 8,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user