Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Merge PR #2343

Brandon Thomas83b4e36e9bea
diff --cc crates/ui-egui/src/i18n/effects.rs
index f5891d07d,1eeb90e00..12f6a015b
--- a/crates/ui-egui/src/i18n/effects.rs
+++ b/crates/ui-egui/src/i18n/effects.rs
@@@ -71,7 -78,7 +78,8 @@@ fn catalog(language: &str) -> Option<&'
static TRADITIONAL: Catalog = Catalog { rows: TRADITIONAL_CHINESE, categories: TRADITIONAL_CHINESE_CATEGORIES, index: OnceLock::new() };
static JAPANESE: Catalog = Catalog { rows: JAPANESE_EFFECTS, categories: JAPANESE_CATEGORIES, index: OnceLock::new() };
static GEORGIAN_CATALOG: Catalog = Catalog { rows: GEORGIAN, categories: GEORGIAN_CATEGORIES, index: OnceLock::new() };
+ static SWEDISH_CATALOG: Catalog = Catalog { rows: SWEDISH, categories: SWEDISH_CATEGORIES, index: OnceLock::new() };
+ static FRENCH_CATALOG: Catalog = Catalog { rows: FRENCH, categories: FRENCH_CATEGORIES, index: OnceLock::new() };
match language {
"zh-hans" => Some(&SIMPLIFIED),
"zh-hant" => Some(&TRADITIONAL),
@@@ -79,7 -86,7 +87,8 @@@
// this one catalog instead of inventing a second mechanism.
"ja" => Some(&JAPANESE),
"ka" => Some(&GEORGIAN_CATALOG),
+ "sv" => Some(&SWEDISH_CATALOG),
+ "fr" => Some(&FRENCH_CATALOG),
_ => None,
}
}
@@@ -1553,7 -1549,7 +1902,7 @@@ mod tests
const PENDING: &[(&str, &[Row])] = &[("zh-hant", TRADITIONAL_CHINESE)];
/// The languages whose tables are being filled in: guarded like [`PENDING`] row by row.
- const PARTIAL: &[(&str, &[Row])] = &[("ja", JAPANESE_EFFECTS), ("ka", GEORGIAN), ("sv", SWEDISH)];
- const PARTIAL: &[(&str, &[Row])] = &[("ja", JAPANESE_EFFECTS), ("ka", GEORGIAN), ("fr", FRENCH)];
++ const PARTIAL: &[(&str, &[Row])] = &[("ja", JAPANESE_EFFECTS), ("ka", GEORGIAN), ("sv", SWEDISH), ("fr", FRENCH)];
/// A pending language may lag Simplified Chinese but may not invent ids or disagree about
/// which effect an id names: a translator fills these tables row by row. While they are
@@@ -1587,7 -1583,7 +1936,8 @@@
("zh-hant", TRADITIONAL_CHINESE_CATEGORIES),
("ja", JAPANESE_CATEGORIES),
("ka", GEORGIAN_CATEGORIES),
+ ("sv", SWEDISH_CATEGORIES),
+ ("fr", FRENCH_CATEGORIES),
] {
for (english, translated) in rows {
assert!(categories.contains(english), "{language} lists {english}, which is not a category");
diff --cc crates/ui-egui/src/i18n/ui.rs
index 300485572,c869b896a..e2d73f893
--- a/crates/ui-egui/src/i18n/ui.rs
+++ b/crates/ui-egui/src/i18n/ui.rs
@@@ -22,7 -22,7 +22,7 @@@ use std::fmt::Display
use std::sync::OnceLock;
thread_local! {
- /// The resolved interface language ("en", "ja", "zh-hans", "zh-hant", "uk", "pt-br", "cs", "es", "pl", "ka", "sv"); "en" until the first
- /// The resolved interface language ("en", "ja", "zh-hans", "zh-hant", "uk", "pt-br", "cs", "es", "pl", "ka", "fr"); "en" until the first
++ /// The resolved interface language ("en", "ja", "zh-hans", "zh-hant", "uk", "pt-br", "cs", "es", "pl", "ka", "sv", "fr"); "en" until the first
/// frame sets it.
static CURRENT: Cell<&'static str> = const { Cell::new("en") };
}
@@@ -53,7 -53,7 +53,8 @@@ const ROWS: &[(&str, &[(&str, &str)])]
("pl", POLISH),
("ka", GEORGIAN),
("ka", GEORGIAN_PANELS),
+ ("sv", SWEDISH),
+ ("fr", FRENCH),
];
/// The catalog for `language`, indexed by English source (built on first use: panels translate
@@@ -68,7 -68,7 +69,8 @@@ fn catalog(language: &str) -> Option<&'
static ES: OnceLock<Index> = OnceLock::new();
static PL: OnceLock<Index> = OnceLock::new();
static KA: OnceLock<Index> = OnceLock::new();
+ static SV: OnceLock<Index> = OnceLock::new();
+ static FR: OnceLock<Index> = OnceLock::new();
let (index, rows) = match language {
"ja" => (&JA, JAPANESE),
"zh-hans" => (&HANS, SIMPLIFIED_CHINESE),
@@@ -78,9 -78,9 +80,10 @@@
"cs" => (&CS, CZECH),
"es" => (&ES, SPANISH),
"pl" => (&PL, POLISH),
+ "fr" => (&FR, FRENCH),
// Georgian also reads its own rows for text the other catalogs don't have yet.
"ka" => return Some(KA.get_or_init(|| GEORGIAN.iter().chain(GEORGIAN_PANELS).copied().collect())),
+ "sv" => (&SV, SWEDISH),
_ => return None,
};
Some(index.get_or_init(|| rows.iter().copied().collect()))
@@@ -8966,19 -9079,22 +10251,35 @@@ mod tests
set_current("en");
}
+ /// Swedish panels translate, fill values in order and keep project content.
+ #[test]
+ fn swedish_panels_translate_and_keep_project_content() {
+ set_current("sv");
+ assert_eq!(tr("Composition Name:"), "Kompositionsnamn:");
+ assert_eq!(tr("Cancel"), "Avbryt");
+ assert_eq!(tr("my layer.mp4"), "my layer.mp4");
+ assert_eq!(tr_args("Proxy Use: {}", &[&"Best"]), "Proxyanvändning: Best");
+ assert_eq!(tr_args("Step {} of {}: {}", &[&1, &3, &"Colour"]), "Steg 1 av 3: Colour");
+ set_current("en");
+ assert_eq!(tr("Cancel"), "Cancel");
+ }
+
+ /// French sets a no-break space before `:`, `;`, `?` and `!`, never a plain one, and keeps the
+ /// project's own text untouched.
+ #[test]
+ fn french_panels_translate_and_keep_the_punctuation_rule() {
+ for (en, fr) in FRENCH {
+ assert!(!fr.contains(" :") && !fr.contains(" ;") && !fr.contains(" ?") && !fr.contains(" !"), "{en:?}: plain space before a high punctuation mark");
+ }
+ set_current("fr");
+ assert_eq!(tr("Composition Name:"), "Nom de la composition\u{a0}:");
+ assert_eq!(tr("Cancel"), "Annuler");
+ assert_eq!(tr("my layer.mp4"), "my layer.mp4");
+ assert_eq!(tr_args("Step {} of {}: {}", &[&1, &3, &"Colour"]), "Étape 1 sur 3\u{a0}: Colour");
+ set_current("en");
+ assert_eq!(tr("Cancel"), "Cancel");
+ }
+
/// Values fill the placeholders in order, and a missing value is dropped instead of panicking.
#[test]
fn tr_args_fills_values_in_order() {