macOS: declare the UI languages so the open and save panels are translated (#4785)

This commit is contained in:
Atalantis authored and GitHub committed 2026-11-09 10:08:50 +08:00
1 parent 6e2729ae21
commit 138acb38b1
2 files changed
+52

No files matched your search

+12
View File
@@ -39,6 +39,18 @@ fn translations(code: &str) -> String {
lang.catalog_texts().flat_map(rows).flat_map(|(_, _, t)| t.split('|').map(str::to_owned).collect::<Vec<_>>()).collect()
}
#[test]
fn the_macos_bundle_declares_every_interface_language() {
// AppKit translates its own dialogs (open and save panels) only into the languages the app
// bundle declares, so `CFBundleLocalizations` must list every entry of `LANGUAGES`.
let plist = include_str!("../../../../packaging/macos/Info.plist.in");
let block = plist.split("<key>CFBundleLocalizations</key>").nth(1).expect("the template declares CFBundleLocalizations");
let block = block.split("</array>").next().expect("the declaration is an array");
let declared: Vec<String> = block.split("<string>").skip(1).filter_map(|s| s.split("</string>").next()).map(str::to_lowercase).collect();
let registered: Vec<String> = LANGUAGES.iter().map(|l| l.code.to_lowercase()).collect();
assert_eq!(declared, registered, "packaging/macos/Info.plist.in and LANGUAGES list different languages");
}
#[test]
fn keyboard_key_names_have_a_separate_context_and_english_fallback() {
let keys = fixture_lang("x-keys", "key\tDelete\tEntf\n\tDelete\tLöschen\n\tOpen\tÖffnen\n");
+40
View File
@@ -6,6 +6,46 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<!-- UI translations are embedded in Rust; declare them for AppKit's system dialogs (open and
save panels, overwrite confirmation). Keep in sync with LANGUAGES in crates/ui-egui/src/i18n.rs. -->
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>ja</string>
<string>zh-Hans</string>
<string>zh-Hant</string>
<string>cs</string>
<string>pt-BR</string>
<string>de</string>
<string>es</string>
<string>fr</string>
<string>ru</string>
<string>kk</string>
<string>bg</string>
<string>te</string>
<string>hu</string>
<string>uk</string>
<string>it</string>
<string>ar</string>
<string>ckb</string>
<string>fa</string>
<string>pl</string>
<string>sl</string>
<string>el</string>
<string>tr</string>
<string>lt</string>
<string>id</string>
<string>vi</string>
<string>fi</string>
<string>sq</string>
<string>th</string>
<string>ca</string>
<string>ro</string>
<string>lo</string>
<string>hi</string>
<string>ko</string>
<string>nb</string>
</array>
<key>CFBundleDisplayName</key>
<string>PdfCraft</string>
<key>CFBundleName</key>