English (UK) as a language: a plain catalogue of the 25 messages UK English spells differently (#2501) (#2502)
* claim: #2501 * English (UK) as a language: a plain catalogue of the 25 messages UK English spells differently (#2501) assets/locales/en-GB.json holds only the English messages whose spelling differs in UK English (Centre, Customise, Organisation, Licence, colours, towards, ...), in UK spelling; every other message falls back to English. One registration in i18n.rs (English first, then by id), a test that shows UK spelling and English for the rest, a row in ATTRIBUTION.md, and the docs/localization.md note. The translation-coverage checks skip a regional English catalogue, which has no gaps to report. Fixes #2501 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -119,6 +119,7 @@ Editable drawing code, native projects and shipped exports are collected under `
|
||||
| assets/locales/cs.json | potuzai | Czech translation of the English catalog, contributed upstream | MIT OR Apache-2.0 |
|
||||
| assets/locales/da.json | SolidCraft contributors | Original Danish translation of SolidCraft's English catalog; no commercial CAD text used | MIT OR Apache-2.0 |
|
||||
| assets/locales/de.json | SolidCraft contributors | Original SolidCraft resource data or drawing code, collected without redesign | MIT OR Apache-2.0 |
|
||||
| assets/locales/en-GB.json | SolidCraft contributors | English (UK): the English catalog's messages whose spelling differs, in UK spelling | MIT OR Apache-2.0 |
|
||||
| assets/locales/en.json | SolidCraft contributors | Original SolidCraft resource data or drawing code, collected without redesign | MIT OR Apache-2.0 |
|
||||
| assets/locales/es.json | jawler | Spanish (Spain) translation of the English catalog, contributed upstream | MIT OR Apache-2.0 |
|
||||
| assets/locales/fr.json | rlartot | French translation of the English catalog, contributed upstream | MIT OR Apache-2.0 |
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"Center X": "Centre X",
|
||||
"Center Y": "Centre Y",
|
||||
"Center of mass": "Centre of mass",
|
||||
"Customize Toolbar": "Customise Toolbar",
|
||||
"Mass Center": "Mass Centre",
|
||||
"Modeled": "Modelled",
|
||||
"cmd.construct_point_center": "Point At Centre Of Circle/Sphere/Torus",
|
||||
"cmd.inspect_center_of_mass": "Centre of Mass",
|
||||
"cmd.sketch_arc_center_point": "Centre Point Arc",
|
||||
"cmd.sketch_circle_center": "Centre Diameter Circle",
|
||||
"cmd.sketch_rectangle_center": "Centre Rectangle",
|
||||
"cmd.sketch_slot_arc_center": "Centre Point Arc Slot",
|
||||
"cmd.sketch_slot_center_point": "Centre Point Slot",
|
||||
"cmd.sketch_slot_center_to_center": "Centre to Centre Slot",
|
||||
"pattern.alignment_hint": "Counts include the original. Centre balances copies; Flip chooses the extra side for even totals.",
|
||||
"render.opaque_preview_help": "Opaque PBR and simple colours; blended transparency. Refraction, HDRI and final rendering are not available yet.",
|
||||
"sketch_text.align_center": "Centre",
|
||||
"ui.center": "Centre",
|
||||
"ui.centerline": "Centreline",
|
||||
"ui.customizeToolbar": "Customise Toolbar…",
|
||||
"ui.design_properties.license": "Licence",
|
||||
"ui.design_properties.organization": "Organisation",
|
||||
"ui.space_mouse_step_pull": "Pull the cap towards you, hold it, then let go.",
|
||||
"ui.zoom_to_cursor_tip": "The wheel zooms towards the point under the cursor (off: towards the view's centre)",
|
||||
"update.prefs_flatpak": "Flatpak updates this copy ({version}): run {command} or use your software centre. SolidCraft doesn't check."
|
||||
}
|
||||
@@ -35,6 +35,9 @@ static ENGLISH: Catalog = Catalog::new("en", "English", include_str!(concat!(env
|
||||
static CZECH: Catalog = Catalog::new("cs", "Čeština", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/locales/cs.json")));
|
||||
static DANISH: Catalog = Catalog::new("da", "Dansk", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/locales/da.json")));
|
||||
static GERMAN: Catalog = Catalog::new("de", "Deutsch", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/locales/de.json")));
|
||||
/// English in UK spelling: only the messages whose spelling differs; the rest are English's.
|
||||
static ENGLISH_UK: Catalog =
|
||||
Catalog::new("en-GB", "English (UK)", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/locales/en-GB.json")));
|
||||
static SPANISH: Catalog = Catalog::new("es", "Español (España)", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/locales/es.json")));
|
||||
static FRENCH: Catalog = Catalog::new("fr", "Français", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/locales/fr.json")));
|
||||
static GALICIAN: Catalog = Catalog::new("gl", "Galego", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/locales/gl.json")));
|
||||
@@ -66,6 +69,7 @@ pub const LOCALES: &[&Catalog] = &[
|
||||
&CZECH,
|
||||
&DANISH,
|
||||
&GERMAN,
|
||||
&ENGLISH_UK,
|
||||
&SPANISH,
|
||||
&FRENCH,
|
||||
&GALICIAN,
|
||||
@@ -252,6 +256,18 @@ mod tests {
|
||||
assert!(ids[1..].is_sorted(), "{ids:?}");
|
||||
}
|
||||
|
||||
/// English (UK) holds only the messages it spells differently; the rest are English's.
|
||||
#[test]
|
||||
fn english_uk_shows_uk_spelling_and_english_for_the_rest() {
|
||||
let (uk, english) = (Locale::for_language("en-GB"), Locale::for_language("en"));
|
||||
assert_eq!(uk.name(), "English (UK)");
|
||||
assert_eq!(uk.label("Center X"), "Centre X");
|
||||
assert_eq!(uk.label("Customize Toolbar"), "Customise Toolbar");
|
||||
assert_eq!(uk.text("ui.design_properties.organization"), "Organisation");
|
||||
assert_eq!(uk.text("ui.preferences"), english.text("ui.preferences"));
|
||||
assert_eq!(english.label("Center X"), "Center X");
|
||||
}
|
||||
|
||||
/// A new design's name, `Untitled`, is a default name like `Sketch1`: it shows translated
|
||||
/// wherever the design's name is shown (the tab, the browser's top row, the save prompt).
|
||||
#[test]
|
||||
|
||||
@@ -346,7 +346,7 @@ mod tests {
|
||||
"claims",
|
||||
"moisture_unit",
|
||||
];
|
||||
for catalog in crate::i18n::LOCALES {
|
||||
for catalog in crate::i18n::LOCALES.iter().filter(|c| c.id != "en-GB") {
|
||||
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../assets/locales").join(format!("{}.json", catalog.id));
|
||||
let messages: Value = serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap();
|
||||
for key in keys.into_iter().chain(KINDS) {
|
||||
|
||||
@@ -2381,7 +2381,7 @@ mod home_tests {
|
||||
fn needs_design_tooltip_is_translated() {
|
||||
let english = crate::i18n::Locale::for_language("en").text("ui.needs_design");
|
||||
assert!(english.contains("{command}"));
|
||||
for catalog in crate::i18n::LOCALES.iter().filter(|c| c.id != "en") {
|
||||
for catalog in crate::i18n::LOCALES.iter().filter(|c| !matches!(c.id, "en" | "en-GB")) {
|
||||
let text = crate::i18n::Locale::for_language(catalog.id).text("ui.needs_design");
|
||||
assert!(text != english && text.contains("{command}"), "{} must translate ui.needs_design", catalog.id);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# UI localization
|
||||
|
||||
SolidCraft embeds its translations and works offline. English, Czech, Danish, German, Spanish, French, Galician, Italian,
|
||||
SolidCraft embeds its translations and works offline. English, Czech, Danish, German, English (UK), Spanish, French, Galician, Italian,
|
||||
Japanese, Korean, Malay, Polish, Brazilian Portuguese, Russian, Turkish, Ukrainian and Chinese are currently registered in `crates/ui-egui/src/i18n.rs`. Adding a language requires an
|
||||
embedded catalog and one registration there; the preferences selector and validation use the same
|
||||
registry.
|
||||
@@ -31,6 +31,12 @@ entry has a note for translators: what the term must not be confused with. Its "
|
||||
than one meaning" table lists the English words that need a separate catalogue entry for each
|
||||
meaning (Construction, Flat, Round, Normal, Gap, Clearance).
|
||||
|
||||
## English (UK)
|
||||
|
||||
`en-GB.json` holds only the English messages whose spelling differs in UK English (Centre,
|
||||
Customise, Organisation, Licence, colours, …); every other message falls back to English. When an
|
||||
English message with a US spelling is added, add its UK spelling there too.
|
||||
|
||||
## Coverage
|
||||
|
||||
A message a locale never received falls back to English silently, so a gap shows up only as a row
|
||||
|
||||
+3
-2
@@ -103,7 +103,8 @@ pub fn run(root: &Path, args: &[&str]) -> Result<(), String> {
|
||||
}
|
||||
|
||||
/// Locale ids other than English: every catalog file that sits beside `en.json`, so a newly
|
||||
/// added locale is picked up without editing this command.
|
||||
/// added locale is picked up without editing this command. A regional English (`en-GB.json`)
|
||||
/// holds only the messages it spells differently, so it has no gaps to report.
|
||||
fn locales(root: &Path) -> Result<Vec<String>, String> {
|
||||
let dir = root.join(DIR);
|
||||
let entries = std::fs::read_dir(&dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
@@ -112,7 +113,7 @@ fn locales(root: &Path) -> Result<Vec<String>, String> {
|
||||
.map(|e| e.path())
|
||||
.filter(|p| p.extension().and_then(|x| x.to_str()) == Some("json"))
|
||||
.filter_map(|p| p.file_stem().map(|s| s.to_string_lossy().into_owned()))
|
||||
.filter(|id| id != "en")
|
||||
.filter(|id| id != "en" && !id.starts_with("en-"))
|
||||
.collect();
|
||||
ids.sort();
|
||||
Ok(ids)
|
||||
|
||||
Reference in New Issue
Block a user