Files
kcc/gen_translation_files.bat
T
Ryuga6 a053b3ea9f Add multi-language i18n support (Simplified Chinese, Japanese, Korean) (#1453)
* Add multi-language i18n support (English, Chinese, Japanese, Korean)

- Add i18n.py module for translation management via QTranslator
- Add Simplified Chinese (zh_CN), Japanese (ja_JP), and Korean (ko_KR) translations
- Integrate translation files into Qt resource system (KCC.qrc / KCC_rc.py)
- Add language switcher button in the top button bar of main window
- Language setting persists via QSettings
- Dynamic text updates work correctly after language switch
- Support %1, %2, %3 placeholders via tr_arg() helper function
- KCCGUI and KCCGUI_MetaEditor now inherit QObject for tr() support

* Complete Japanese/Korean/Chinese translations + fix language switch issues

- Fill 61 missing Japanese translations (tooltips, 3-state checkboxes, etc.)
- Fill 61 missing Korean translations (tooltips, 3-state checkboxes, etc.)
- Fill 6 missing Chinese translations
- Fix language menu: use QActionGroup for exclusive (single-select) checkmarks
- Fix jobList initial tips: refresh translations on language switch by
  updating label text directly (preserves message order and user-added entries)
- Add PROJECT_I18N_README.md developer documentation

* Replace emoji language icon with PNG globe icon

Fixes PR review feedback from axu2: the emoji character doesn't render on Windows 7 (no emoji font support). Replaced with a PNG globe icon from Wikimedia Commons (CC license), loaded via Qt resource system for consistent cross-platform rendering.

* Fix RuntimeError when switching language: re-fetch labels from jobList

Previously, QLabel references were saved directly, but the underlying

C++ objects could be deleted by Qt, causing RuntimeError on access.

Now we save only source strings and re-fetch labels from jobList

items when updating, with try/except as a safety net.

* Use text label for language button instead of PNG icon

Replace the globe PNG icon with a plain text button (' 文 A ')

so its color automatically follows the system light/dark theme,

per review feedback. Removes icons/language.png and its QRC entry.

* Finalize i18n: retranslate jobList messages and translate CLI output

- Add source= to 16 GUI addMessage calls so already-shown messages retranslate on language switch
- Translate comic2ebook.py conversion/CLI messages via QCoreApplication.translate('KCCGUI', ...)
- Clear 29 unfinished WorkerThread translations (context unified to KCCGUI)
- Guard apply_language when QApplication is not yet created
- Trim dead imports and redundant code

* Avoid duplicated source strings: translate inside addMessage

Replace the self.tr/translate + source= pattern (same string written twice) with
QT_TRANSLATE_NOOP('KCCGUI', ...) at call sites; addMessage now translates internally
and stores the source text for retranslation on language switch.

- Drop the source parameter from addMessage; simplify signal to 3 args
- Include comic2ebook.py in lupdate (20 CLI/conversion messages)

* Add translation maintenance workflow

Add gen_translation_files.sh/.bat, TRANSLATION.md, and a README pointer; remove the superseded PROJECT_I18N_README.md.

* chmod +x
2026-10-13 11:10:33 -07:00

30 lines
1.3 KiB
Batchfile

@echo off
rem Update translation sources (.ts) and rebuild the runtime translation
rem files (.qm), then re-bundle the .qm files into the Qt resource module
rem (KCC_rc.py). Run from the repository root.
setlocal
where pyside6-lupdate >nul 2>nul || (echo Error: pyside6-lupdate not found. Install it with: pip install pyside6 & exit /b 1)
where pyside6-lrelease >nul 2>nul || (echo Error: pyside6-lrelease not found. Install it with: pip install pyside6 & exit /b 1)
where pyside6-rcc >nul 2>nul || (echo Error: pyside6-rcc not found. Install it with: pip install pyside6 & exit /b 1)
rem 1. Update every translation source file in place.
rem comic2ebook.py must stay in the list: the CLI-side messages live there.
for %%f in (translations\*.ts) do (
pyside6-lupdate kindlecomicconverter\KCC_gui.py kindlecomicconverter\comic2ebook.py gui\KCC.ui gui\MetaEditor.ui -ts "%%f"
if errorlevel 1 exit /b 1
)
rem 2. Compile each .ts into its .qm runtime file.
for %%f in (translations\*.ts) do (
pyside6-lrelease "%%f" -qm "%%~dpnf.qm"
if errorlevel 1 exit /b 1
)
rem 3. Re-bundle the .qm files into KCC_rc.py via the Qt resource file.
pyside6-rcc gui\KCC.qrc > kindlecomicconverter\KCC_rc.py
if errorlevel 1 exit /b 1
echo Translation files updated and re-bundled.
endlocal