Tkinter 中英国际化
БесплатноБез исполняемых скриптовНе проверенAdd Chinese/English (or multi-language) internationalization to a Tkinter desktop app. This skill should be used when a user wants a Tkinter GUI to…
от oracis138 установок в других каталогахОб этом скилле
Tkinter i18n (中文即 key)
A lightweight, gettext-free i18n scheme for Tkinter apps. Chinese strings are the
dictionary keys; an _EN table holds English; unknown keys fall back to the
Chinese source so the UI never shows blank/missing text.
When to use
- A user wants a Tkinter tool bilingual (中文 / English) or multi-language.
- Need auto-detect of system language + a manual dropdown + "remember my choice".
- Avoid gettext (it does not survive PyInstaller
--onefilefreezing cleanly).
Pattern
- Define
t(key, *args)— returns_EN.get(key, key), thenstr % argsif args present. Never raises on missing keys. - Keep one
_EN = {...}table. Add an entry for every user-visible string. _detect_lang()— Windows:ctypes.windll.kernel32.GetUserDefaultUILanguage()& 0xFF == 0x04→ Chinese, else English. Fallback tolocaleon non-Windows.- Persist choice to
~/.workbuddy/APP.lang(zh/en); load at startup. - Manual switch: write the file, then restart the process
(
os.execv(sys.executable, [sys.executable] + sys.argv)) so every widget rebuilds with the new language. Per-widget live redraw is fragile — restart is simpler and reliable.
See references/i18n_template.py for a complete, runnable minimal app.
Wiring checklist
- Import
tat top; wrap every user-visible string (titles, buttons, labels, messageboxes, status text, model display names, dropdown labels). - Add a language
ttk.Combobox(top-right) bound to the switch handler. -
LANG_ORDER = ["zh", "en"],LANG_NAMES = {"zh": "中文", "en": "English"}. - Restart-on-change writes config then
os.execv. - Adding a language later = add a branch in
_detect_lang+ a new translation table + extendLANG_ORDER/LANG_NAMES.
Notes
- Frozen (PyInstaller) safe: no external
.mofiles, nogettextruntime. - The language config path should live under
~/.workbuddy/so it is shared with the agent's config dir, or under the app's own dir — pick one and be consistent.
Установить Tkinter 中英国际化 в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Tkinter 中英国际化?
Add Chinese/English (or multi-language) internationalization to a Tkinter desktop app. This skill should be used when a user wants a Tkinter GUI to auto-detect the system UI language, offer a manual language switcher, persist the choice, and apply it without gettext. The approach uses a t(key) function with Chinese-as-key plus an _EN translation table, detects language via Windows GetUserDefaultUILanguage, persists to a config file, and restarts the process to apply changes cleanly.
Как установить скилл Tkinter 中英国际化?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Tkinter 中英国际化 запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic