From 225ff5721eae5cca77f04afdf765c2bf8f85d7f2 Mon Sep 17 00:00:00 2001 From: Ruslan Zaitsev Date: Fri, 13 Nov 2026 09:23:31 +0300 Subject: [PATCH] fix(lang): keep the {} placeholder in three translations (#17000) * fix(lang): keep the {} placeholder in three translations fa and nl dropped the {} in shortcut-must-include-modifiers and shortcut-key-not-supported, so the recording dialog lost the modifier list and the rejected key name. sc had a {} and an unrelated meaning in printer-os-requirement-tip, which is shown as plain text. * test(lang): check fa, nl and sc against the placeholders of their English text The existing placeholder test only looks at keys that contain {}. These three tables had mismatches against the en.rs text instead (strings whose {} is filled by Dart replaceAll). The test fails on master and passes with the translation fixes. --------- Co-authored-by: Ruslan Zaitsev <293677063+Dofam1nch1k@users.noreply.github.com> --- src/lang.rs | 21 +++++++++++++++++++++ src/lang/fa.rs | 4 ++-- src/lang/nl.rs | 4 ++-- src/lang/sc.rs | 2 +- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/lang.rs b/src/lang.rs index de54b9af7..a983b875e 100644 --- a/src/lang.rs +++ b/src/lang.rs @@ -426,4 +426,25 @@ mod test { } } } + + #[test] + fn test_translations_keep_the_placeholders_of_their_english_text() { + use super::*; + + // Some callers fill `{}` themselves (Dart `.replaceAll('{}', ...)`), so the English text, + // not only the key, decides how many `{}` a translation needs. + for table in [&*fa::T, &*nl::T, &*sc::T] { + for (key, value) in table.iter() { + if value.is_empty() { + continue; + } + let english = en::T.get(key).filter(|v| !v.is_empty()).unwrap_or(key); + assert_eq!( + english.matches("{}").count(), + value.matches("{}").count(), + "{key:?} => {value:?}" + ); + } + } + } } diff --git a/src/lang/fa.rs b/src/lang/fa.rs index aab8a92ed..10e43059f 100644 --- a/src/lang/fa.rs +++ b/src/lang/fa.rs @@ -805,12 +805,12 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Set shortcut", "تنظیم میانبر"), ("shortcut-recording-instruction", "کلیدهای میانبر مورد نظر را فشار دهید."), ("shortcut-recording-press-keys-tip", "کلیدها را فشار دهید..."), - ("shortcut-must-include-modifiers", "میانبر باید شامل حداقل یک کلید تغییردهنده (Ctrl، Alt، Shift یا Meta) باشد."), + ("shortcut-must-include-modifiers", "میانبر باید شامل حداقل یک کلید تغییردهنده باشد: {}"), ("shortcut-already-bound-to", "این میانبر قبلاً به عملکرد دیگری اختصاص داده شده است."), ("Replace", "جایگزینی"), ("Valid", "معتبر"), ("shortcut-mobile-physical-keyboard-tip", "این میانبرها فقط با صفحه کلید فیزیکی متصل کار می‌کنند."), - ("shortcut-key-not-supported", "این کلید برای میانبر پشتیبانی نمی‌شود."), + ("shortcut-key-not-supported", "\"{}\" را نمی‌توان به‌عنوان میانبر استفاده کرد."), ("On", "روشن"), ("Off", "خاموش"), ("api_server_connection_tip", "سرور سفارشی شما از HTTP رمزنگاری‌نشده استفاده می‌کند. برای فعال‌سازی HTTPS با مدیر سیستم خود تماس بگیرید."), diff --git a/src/lang/nl.rs b/src/lang/nl.rs index 41a02152d..99dd5b05f 100644 --- a/src/lang/nl.rs +++ b/src/lang/nl.rs @@ -805,12 +805,12 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Set shortcut", "Sneltoets toewijzen"), ("shortcut-recording-instruction", "Druk op de toetsencombinatie die je wilt gebruiken."), ("shortcut-recording-press-keys-tip", "Druk op de toetsencombinatie..."), - ("shortcut-must-include-modifiers", "Sneltoets moet een combinatietoets bevatten"), + ("shortcut-must-include-modifiers", "Sneltoets moet minstens één combinatietoets bevatten: {}"), ("shortcut-already-bound-to", "Sneltoets is al toegewezen aan"), ("Replace", "Vervangen"), ("Valid", "Geldig"), ("shortcut-mobile-physical-keyboard-tip", "Voor het opnemen is een fysiek toetsenbord vereist. Schermtoetsenborden worden niet ondersteund."), - ("shortcut-key-not-supported", "Sneltoets wordt niet ondersteund"), + ("shortcut-key-not-supported", "\"{}\" kan niet als sneltoets worden gebruikt."), ("On", "Aan"), ("Off", "Uit"), ("api_server_connection_tip", "De door jou gebruikte aangepaste server maakt gebruik van onversleuteld HTTP. Neem contact op met de beheerder om HTTPS in te schakelen."), diff --git a/src/lang/sc.rs b/src/lang/sc.rs index 135a84cd9..89a78eda4 100644 --- a/src/lang/sc.rs +++ b/src/lang/sc.rs @@ -638,7 +638,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("d3d_render_tip", "Cando sa renderizatzione D3D est abilitada, s'ischermu de controllu remotu diat pòdere èssere nieddu in unas cantas màchinas"), ("Use D3D rendering", "Imprea sa renderizatzione D3D"), ("Printer", "Imprentadora"), - ("printer-os-requirement-tip", "Pro pòdere impreare s'imprentadora in seddida bisòngiat a installare {} in custu dispositivu."), + ("printer-os-requirement-tip", "Pro pòdere impreare s'imprentadora in seddida bisòngiat Windows 10 o una versione prus noa."), ("printer-requires-installed-{}-client-tip", "Pro impreare s'imprenta remota, bisòngiat a installare {} in custu dispositivu."), ("printer-{}-not-installed-tip", "S'imprentadora {} no est installada"), ("printer-{}-ready-tip", "S'imprentadora {} est installada e pronta pro s'impreu."),