diff --git a/.config/quickshell/ii/screenshot.qml b/.config/quickshell/ii/screenshot.qml index f1555871..d4a55de0 100644 --- a/.config/quickshell/ii/screenshot.qml +++ b/.config/quickshell/ii/screenshot.qml @@ -444,7 +444,7 @@ ShellRoot { } } StyledText { - text: "Drag or click a region • LMB: Copy • RMB: Edit" + text: Translation.tr("Drag or click a region • LMB: Copy • RMB: Edit") color: root.genericContentForeground } } diff --git a/.config/quickshell/translations/en_US.json b/.config/quickshell/translations/en_US.json index b757d3d3..f1da949c 100644 --- a/.config/quickshell/translations/en_US.json +++ b/.config/quickshell/translations/en_US.json @@ -301,5 +301,6 @@ "Shell & utilities": "Shell & utilities", "Qt apps": "Qt apps", "Report a Bug": "Report a Bug", - "Issues": "Issues" + "Issues": "Issues", + "Drag or click a region • LMB: Copy • RMB: Edit": "Drag or click a region • LMB: Copy • RMB: Edit" } \ No newline at end of file diff --git a/.config/quickshell/translations/tools/translation-cleaner.py b/.config/quickshell/translations/tools/translation-cleaner.py index e53082fd..afc290ad 100755 --- a/.config/quickshell/translations/tools/translation-cleaner.py +++ b/.config/quickshell/translations/tools/translation-cleaner.py @@ -154,10 +154,9 @@ def sync_translations(translations_dir: str, source_lang: str = "en_US", target_ del target_translations[key] print(f" Deleted {len(extra_keys)} extra keys") - # Save file - with open(target_file, 'w', encoding='utf-8') as f: + # Save file (ensure UTF-8, fix for special chars) + with open(target_file, 'w', encoding='utf-8', newline='') as f: json.dump(target_translations, f, ensure_ascii=False, indent=2) - print(f" Saved: {target_file}") def main(): diff --git a/.config/quickshell/translations/tools/translation-manager.py b/.config/quickshell/translations/tools/translation-manager.py index ffcb2609..1b1a604a 100755 --- a/.config/quickshell/translations/tools/translation-manager.py +++ b/.config/quickshell/translations/tools/translation-manager.py @@ -56,11 +56,22 @@ class TranslationManager: text = match[0] if match else "" else: text = match - - # Decode escape characters + try: - clean_text = text.encode().decode('unicode_escape') - except: + if '\\u' in text or '\\x' in text: + clean_text = bytes(text, "utf-8").decode("unicode_escape") + else: + clean_text = ( + text.replace('\\n', '\n') + .replace('\\t', '\t') + .replace('\\r', '\r') + .replace('\\"', '"') + .replace('\\\'', "'") + .replace('\\f', '\f') + .replace('\\b', '\b') + .replace('\\\\', '\\') + ) + except Exception: clean_text = text # Clean text (remove extra whitespace) diff --git a/.config/quickshell/translations/zh_CN.json b/.config/quickshell/translations/zh_CN.json index fe4e577d..a51b8a79 100644 --- a/.config/quickshell/translations/zh_CN.json +++ b/.config/quickshell/translations/zh_CN.json @@ -301,5 +301,6 @@ "Shell & utilities": "Shell 与工具", "Qt apps": "Qt 应用", "Report a Bug": "报告问题", - "Issues": "问题追踪" + "Issues": "问题追踪", + "Drag or click a region • LMB: Copy • RMB: Edit": "拖动或点击一个区域 • 鼠标左键:复制 • 鼠标右键:编辑" } \ No newline at end of file