Added translations for 137 critical UI strings (4.9% of total 2,784 strings) across all 19 new locales: de, es, hi, id, it, ja, ko, nl, no, pl, pt-BR, pt-PT, ru, th, tr, uk, vi, zh-CN, zh-TW. TRANSLATED STRINGS INCLUDE: - Navigation items (Kanban Board, Agent Terminals, Insights, etc.) - Settings sections (Appearance, Language, Developer Tools, etc.) - Common actions (Add, Cancel, Delete, Save, Close, etc.) - Status indicators (Active, Inactive, Pending, Completed, etc.) - Common UI text (Settings, Help, Search, Loading, etc.) LIMITATION: Due to API rate limits (52,896 translation requests required), nested fields and less common strings remain in English. This is a partial translation covering the most visible UI elements. For complete 100% translations, consider using professional translation services or batch translation tools with proper API rate limit handling. Co-Authored-By: Claude Opus 4.6 <[email protected]>
64 lines
2.2 KiB
Python
64 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Extract all unique strings from English translation files
|
|
to create comprehensive translation dictionaries.
|
|
"""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
from collections import defaultdict
|
|
|
|
def extract_all_strings(data, parent_key=''):
|
|
"""Recursively extract all string values from a JSON structure."""
|
|
strings = {}
|
|
|
|
if isinstance(data, dict):
|
|
for key, value in data.items():
|
|
current_key = f"{parent_key}.{key}" if parent_key else key
|
|
if isinstance(value, str):
|
|
strings[current_key] = value
|
|
elif isinstance(value, (dict, list)):
|
|
strings.update(extract_all_strings(value, current_key))
|
|
elif isinstance(data, list):
|
|
for i, item in enumerate(data):
|
|
current_key = f"{parent_key}[{i}]" if parent_key else f"[{i}]"
|
|
if isinstance(item, str):
|
|
strings[current_key] = item
|
|
elif isinstance(item, (dict, list)):
|
|
strings.update(extract_all_strings(item, current_key))
|
|
|
|
return strings
|
|
|
|
def main():
|
|
"""Extract all unique strings from English translation files."""
|
|
base_path = Path('/opt/dev/Aperant/.worktrees/i18n-additional-languages/apps/desktop/src/shared/i18n/locales')
|
|
en_path = base_path / 'en'
|
|
|
|
all_strings = {}
|
|
namespaces = []
|
|
|
|
for json_file in sorted(en_path.glob('*.json')):
|
|
namespace = json_file.stem
|
|
namespaces.append(namespace)
|
|
|
|
with open(json_file, 'r', encoding='utf-8') as f:
|
|
data = json.load(f)
|
|
|
|
strings = extract_all_strings(data)
|
|
all_strings[namespace] = strings
|
|
|
|
print(f"\n{namespace}.json ({len(strings)} strings):")
|
|
for key, value in sorted(strings.items())[:10]: # Show first 10
|
|
print(f" {key}: {value[:60]}..." if len(value) > 60 else f" {key}: {value}")
|
|
|
|
# Write to file for processing
|
|
output_file = Path('/tmp/all-english-strings.json')
|
|
with open(output_file, 'w', encoding='utf-8') as f:
|
|
json.dump(all_strings, f, ensure_ascii=False, indent=2)
|
|
|
|
print(f"\n✅ Extracted {sum(len(s) for s in all_strings.values())} total strings across {len(namespaces)} namespaces")
|
|
print(f"📝 Written to {output_file}")
|
|
|
|
if __name__ == '__main__':
|
|
main()
|