mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Tests: i18n tests check lookup machinery, not catalog contents (#15642)
A missing translation shows in English, so no test may fail because a catalog lacks a row (docs/contributing.md). Removed the tests that required rows to exist (RAW Develop labels in every catalog, Hindi rows, French/German rasterize prompts, the German Actions summary) and the asserts that pinned the wording of real translations in the tag-resolution tests. Tag and locale resolution, English fallback, and the plural, context, id and placeholder checks on the fixture catalog stay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
7efcc7b4d1
commit
fe905c8ac3
4 files changed
+4
-124
No files matched your search
@@ -1,15 +1,11 @@
|
||||
//! #12538: a Paint Bucket click on a fill layer asks the reference application's question and OK
|
||||
//! only rasterizes the fill; the catalogs that translated the old text translate the new one.
|
||||
//! only rasterizes the fill.
|
||||
|
||||
use egui::Modifiers;
|
||||
use serde_json::json;
|
||||
|
||||
use super::*;
|
||||
use crate::canvas::testing::{ToolEvent, tool_event};
|
||||
use crate::i18n::{Lang, tr};
|
||||
|
||||
const FILL: &str = "The fill for this layer must be rasterized before proceeding. It will no longer be editable as a fill. Rasterize the fill?";
|
||||
const OLD: &str = "This fill layer must be rasterized before proceeding. Its fill content will no longer be editable. Rasterize the layer?";
|
||||
|
||||
/// A Solid Color fill layer over a white Background, its content (not its mask) targeted, with
|
||||
/// the Paint Bucket.
|
||||
@@ -49,19 +45,3 @@ fn the_paint_bucket_on_a_fill_layer_shows_the_reference_question() {
|
||||
assert_eq!(active_content(&app), "Pixel");
|
||||
assert_eq!(past(&app), before + 1, "one state: the rasterize, no fill");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalogs_that_had_a_translation_keep_one() {
|
||||
if !crate::i18n::needs_catalogs() {
|
||||
return;
|
||||
}
|
||||
let fr = Lang::from_code("fr").expect("French");
|
||||
assert_ne!(tr(fr, FILL), FILL, "French still translates the prompt");
|
||||
let de = Lang::from_code("de").expect("German");
|
||||
assert_eq!(tr(de, FILL), FILL, "a language without an entry falls back to English");
|
||||
for (code, _, catalog) in crate::i18n::CRAFT_I18N {
|
||||
// Check source columns, not comments or translations, in the embedded app catalogs.
|
||||
let mut keys = catalog.lines().filter(|l| !l.starts_with('#')).filter_map(|l| l.split('\t').nth(1));
|
||||
assert!(keys.all(|k| k != OLD), "{code} still has the old key");
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,6 @@ fn lang(code: &str) -> Lang {
|
||||
Lang::from_code(code).unwrap_or_else(|| panic!("{code} registered and embedded"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hindi_has_the_reveal_and_camera_raw_rows() {
|
||||
if !needs_catalogs() {
|
||||
return;
|
||||
}
|
||||
let hi = lang("hi");
|
||||
assert_eq!(tr(hi, "Reveal in Explorer"), "Explorer में दिखाएँ");
|
||||
assert_eq!(tr(hi, "Reveal in Finder"), "Finder में दिखाएँ");
|
||||
assert_eq!(tr(hi, "RAW Defaults…"), "RAW डिफ़ॉल्ट…");
|
||||
assert!(has(hi, "RAW Defaults…"), "RAW Defaults… is a catalog row, not a fallback");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hindi_tags_resolve() {
|
||||
if !needs_catalogs() {
|
||||
@@ -43,10 +31,6 @@ fn georgian_tags_resolve() {
|
||||
assert_eq!(ka.name(), "ქართული");
|
||||
assert_eq!(Lang::from_pref("ka"), ka);
|
||||
assert_eq!(Lang::from_pref("KA"), ka);
|
||||
assert_eq!(tr(ka, "Layer"), "შრე");
|
||||
assert_eq!(tr(ka, "File"), "ფაილი");
|
||||
assert_eq!(trn(ka, 1, "{n} layer", "{n} layers"), "შრე: 1");
|
||||
assert_eq!(trn(ka, 3, "{n} layer", "{n} layers"), "შრე: 3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -69,13 +53,11 @@ fn indonesian_vietnamese_and_thai_tags_resolve() {
|
||||
assert_eq!(Lang::from_pref(tag), th, "{tag}");
|
||||
}
|
||||
assert_eq!(th.name(), "ไทย");
|
||||
assert_eq!(tr(th, "File"), "ไฟล์");
|
||||
assert_eq!(tr(th, "Layer"), "เลเยอร์");
|
||||
}
|
||||
|
||||
/// Tamil: regional tags resolve, counts take one|other, and placeholders stay untranslated.
|
||||
/// Tamil: regional tags resolve, and placeholders survive the lookup.
|
||||
#[test]
|
||||
fn tamil_tags_plurals_and_placeholders() {
|
||||
fn tamil_tags_and_placeholders() {
|
||||
if !needs_catalogs() {
|
||||
return;
|
||||
}
|
||||
@@ -83,10 +65,7 @@ fn tamil_tags_plurals_and_placeholders() {
|
||||
for tag in ["ta", "ta-IN", "ta_LK", "ta_IN.UTF-8"] {
|
||||
assert_eq!(Lang::from_pref(tag), ta, "{tag}");
|
||||
}
|
||||
assert_eq!(trn(ta, 1, "{n} layer", "{n} layers"), "1 அடுக்கு");
|
||||
assert_eq!(trn(ta, 3, "{n} layer", "{n} layers"), "3 அடுக்குகள்");
|
||||
assert!(tr(ta, "Scratch: {size}").contains("{size}"));
|
||||
assert_ne!(tr(ta, "Zoom In (hold, drag to scrub)"), "Zoom In (hold, drag to scrub)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -225,9 +204,6 @@ fn spanish_swedish_finnish_danish_and_norwegian_resolve() {
|
||||
for tag in ["sv", "SV", "sv-SE", "sv_SE.UTF-8", "sv-FI", "sv_FI.UTF-8", "sv-AX"] {
|
||||
assert_eq!(Lang::from_pref(tag), sv, "{tag}");
|
||||
}
|
||||
assert_eq!(tr(sv, "File"), "Arkiv");
|
||||
assert_eq!(trn(sv, 1, "{n} layer", "{n} layers"), "1 lager");
|
||||
assert_eq!(trn(sv, 3, "{n} layer", "{n} layers"), "3 lager");
|
||||
let fi = lang("fi");
|
||||
assert_eq!(fi.name(), "Suomi");
|
||||
for tag in ["fi", "FI", "fi-FI", "fi_FI.UTF-8"] {
|
||||
@@ -236,24 +212,16 @@ fn spanish_swedish_finnish_danish_and_norwegian_resolve() {
|
||||
// Filipino and Swedish in Finland don't pick Finnish.
|
||||
assert_ne!(lang_from_tag("fil"), Some(fi));
|
||||
assert_ne!(lang_from_tag("sv-FI"), Some(fi));
|
||||
assert_eq!(tr(fi, "File"), "Tiedosto");
|
||||
// The partitive singular follows any number but 1.
|
||||
for (n, layer) in [(0, "tasoa"), (1, "taso"), (2, "tasoa"), (21, "tasoa")] {
|
||||
assert_eq!(trn(fi, n, "{n} layer", "{n} layers"), format!("{n} {layer}"));
|
||||
}
|
||||
let da = lang("da");
|
||||
assert_eq!(da.name(), "Dansk");
|
||||
for tag in ["da", "DA", "da-DK", "da_DK.UTF-8", "da-GL"] {
|
||||
assert_eq!(Lang::from_pref(tag), da, "{tag}");
|
||||
}
|
||||
assert_eq!(trn(da, 1, "{n} document", "{n} documents"), "1 dokument");
|
||||
assert_eq!(trn(da, 3, "{n} document", "{n} documents"), "3 dokumenter");
|
||||
let nb = lang("nb");
|
||||
assert_eq!(nb.name(), "Norsk bokmål");
|
||||
for tag in ["nb", "NB", "nb-NO", "nb_NO.UTF-8", "no", "no-NO", "no_NO.UTF-8", "nn", "nn-NO", "nn_NO.UTF-8"] {
|
||||
assert_eq!(Lang::from_pref(tag), nb, "{tag}");
|
||||
}
|
||||
assert_eq!(trn(nb, 3, "{n} item", "{n} items"), "3 elementer");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -335,25 +303,6 @@ fn azerbaijani_resolves_locales_and_preferences() {
|
||||
assert_eq!(Lang::from_pref(tag), az, "{tag}");
|
||||
}
|
||||
assert_eq!(tr(az, "unknown translation"), "unknown translation");
|
||||
for n in [0, 1, 2, 11, 19, 20, 21, 99, 100, 101, 102, 119, 120, 1000, 1001, u64::MAX] {
|
||||
assert_eq!(trn(az, n, "{n} layer", "{n} layers"), format!("{n} qat"));
|
||||
}
|
||||
}
|
||||
|
||||
/// Exact lookups retain contextual meanings, dotted/dotless letters and product placeholders.
|
||||
#[test]
|
||||
fn azerbaijani_keeps_context_placeholders_and_command_names() {
|
||||
if !needs_catalogs() {
|
||||
return;
|
||||
}
|
||||
let az = lang("az");
|
||||
for (source, translated) in [("File", "Fayl"), ("Layer", "Qat"), ("Kind", "Növ"), ("Type Layer", "Mətn qatı"), ("Light Theme", "Açıq mövzu")] {
|
||||
assert_eq!(tr(az, source), translated);
|
||||
}
|
||||
assert_eq!(tr_ctx(az, "cameraRaw", "Light"), "İşıq");
|
||||
assert_eq!(tr_ctx(az, "fontWeight", "Light"), "İncə");
|
||||
assert_ne!(tr_id(az, "edit.clear", "Clear"), "Clear");
|
||||
assert!(fmt(tr(az, "About {app}"), &[("app", "PhotoCraft")]).contains("PhotoCraft"));
|
||||
}
|
||||
|
||||
/// Bosnian locales, with or without region, script or encoding, select the Latin catalog.
|
||||
@@ -369,8 +318,6 @@ fn bosnian_resolves_locales_and_preferences() {
|
||||
assert_eq!(Lang::from_pref(tag), bs, "{tag}");
|
||||
}
|
||||
assert_ne!(lang_from_tag("hr-HR"), Some(bs), "Croatian is not Bosnian");
|
||||
assert_eq!(trn(bs, 3, "{n} pixel", "{n} pixels"), "3 piksela");
|
||||
assert_eq!(trn(bs, 5, "{n} document", "{n} documents"), "5 dokumenata");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -509,16 +456,3 @@ fn bundled_catalogs_are_consistent() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn raw_develop_labels_are_translated_in_every_shipped_catalog() {
|
||||
if !needs_catalogs() {
|
||||
return;
|
||||
}
|
||||
for language in LANGUAGES.iter().skip(1) {
|
||||
let l = lang(language.code);
|
||||
for source in ["RAW Develop", "RAW Develop Filter", "RAW Develop Filter…", "RAW Defaults", "RAW Defaults…"] {
|
||||
assert!(has(l, source) && !tr(l, source).is_empty(), "{}: {source}", language.code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,17 +133,6 @@ fn bulk_load_summary_counts_distinct_sets_and_pluralises_files() {
|
||||
assert!(status.starts_with("1 action file loaded (1 action; 1 file could not be loaded: bad.atn: "), "{status}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// The multi-file summary is translated like the rest of the Actions panel.
|
||||
fn bulk_load_summary_is_translated() {
|
||||
if !crate::i18n::needs_catalogs() {
|
||||
return;
|
||||
}
|
||||
let chosen = vec![("a.atn".into(), action_set_bytes("Set 1", "A")), ("b.atn".into(), action_set_bytes("Set 1", "B"))];
|
||||
let status = crate::i18n::with_language(crate::i18n::Lang::from_code("de").unwrap(), || bulk_load_status(chosen).1);
|
||||
assert_eq!(status, "2 Aktionsdateien geladen (1 Aktion; Satz Set 1 aus b.atn hat den aus a.atn ersetzt)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// Dismissing the picker is inert; one selected file keeps its existing status message.
|
||||
fn bulk_load_keeps_cancel_empty_and_single_file_behavior() {
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
//! #11899: the rasterize prompt for a smart object uses the reference application's wording;
|
||||
//! the type, shape and fill prompts are unchanged, and the catalogs that translated the old text
|
||||
//! translate the new one.
|
||||
//! the type, shape and fill prompts are unchanged.
|
||||
|
||||
use super::*;
|
||||
use crate::i18n::{Lang, tr};
|
||||
|
||||
const OLD: &str = "This Smart Object must be rasterized before proceeding. Its contents will no longer be editable. Rasterize the Smart Object?";
|
||||
|
||||
#[test]
|
||||
fn the_four_prompts_read_as_measured() {
|
||||
@@ -21,22 +17,3 @@ fn the_four_prompts_read_as_measured() {
|
||||
);
|
||||
assert!(!Kind::SmartObject.message().contains(" "), "single spaces between sentences");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalogs_that_had_a_translation_keep_one() {
|
||||
if !crate::i18n::needs_catalogs() {
|
||||
return;
|
||||
}
|
||||
let new = Kind::SmartObject.message();
|
||||
let fr = Lang::from_code("fr").expect("French");
|
||||
assert_ne!(tr(fr, new), new, "French still translates the prompt");
|
||||
// A language without an entry falls back to English.
|
||||
let de = Lang::from_code("de").expect("German");
|
||||
assert_eq!(tr(de, new), new);
|
||||
// No catalog keeps the old key.
|
||||
for (code, _, catalog) in crate::i18n::CRAFT_I18N {
|
||||
// Rows are `context <TAB> English <TAB> translation`; `#` starts a comment.
|
||||
let mut keys = catalog.lines().filter(|l| !l.starts_with('#')).filter_map(|l| l.split('\t').nth(1));
|
||||
assert!(keys.all(|k| k != OLD), "{code} still has the old key");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user