Change default language to en-US and add US language (#6621)

This commit is contained in:
Anthony Stirling
2026-06-11 20:36:23 +01:00
committed by GitHub
parent 88adb7adad
commit 946c032fb5
41 changed files with 8578 additions and 188 deletions
+16 -16
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Validate that translation files have the same placeholders as en-GB (source of truth).
Validate that translation files have the same placeholders as en-US (source of truth).
Usage:
python scripts/translations/validate_placeholders.py [--language LANG] [--fix]
@@ -38,16 +38,16 @@ def flatten_dict(d: dict, parent_key: str = "", sep: str = ".") -> Dict[str, str
def validate_language(
en_gb_flat: Dict[str, str], lang_flat: Dict[str, str], lang_code: str
en_us_flat: Dict[str, str], lang_flat: Dict[str, str], lang_code: str
) -> List[Dict]:
"""Validate placeholders for a language against en-GB."""
"""Validate placeholders for a language against en-US."""
issues = []
for key in en_gb_flat:
for key in en_us_flat:
if key not in lang_flat:
continue
en_placeholders = find_placeholders(en_gb_flat[key])
en_placeholders = find_placeholders(en_us_flat[key])
lang_placeholders = find_placeholders(lang_flat[key])
if en_placeholders != lang_placeholders:
@@ -59,7 +59,7 @@ def validate_language(
"key": key,
"missing": missing,
"extra": extra,
"en_text": en_gb_flat[key],
"en_text": en_us_flat[key],
"lang_text": lang_flat[key],
}
issues.append(issue)
@@ -113,26 +113,26 @@ def main():
# Define paths
locales_dir = Path("frontend/editor/public/locales")
en_gb_path = locales_dir / "en-GB" / "translation.toml"
en_us_path = locales_dir / "en-US" / "translation.toml"
if not en_gb_path.exists():
print(f"❌ Error: en-GB translation file not found at {en_gb_path}")
if not en_us_path.exists():
print(f"❌ Error: en-US translation file not found at {en_us_path}")
sys.exit(1)
# Load en-GB (source of truth)
with open(en_gb_path, "rb") as f:
en_gb = tomllib.load(f)
# Load en-US (source of truth)
with open(en_us_path, "rb") as f:
en_us = tomllib.load(f)
en_gb_flat = flatten_dict(en_gb)
en_us_flat = flatten_dict(en_us)
# Get list of languages to validate
if args.language:
languages = [args.language]
else:
# Validate all languages except en-GB
# Validate all languages except en-US
languages = []
for d in locales_dir.iterdir():
if d.is_dir() and d.name != "en-GB":
if d.is_dir() and d.name != "en-US":
if (d / "translation.toml").exists():
languages.append(d.name)
@@ -151,7 +151,7 @@ def main():
lang_data = tomllib.load(f)
lang_flat = flatten_dict(lang_data)
issues = validate_language(en_gb_flat, lang_flat, lang_code)
issues = validate_language(en_us_flat, lang_flat, lang_code)
all_issues.extend(issues)
# Output results