feat: add i18n support with zh-Hant and zh-CN translations
Ready to merge
JA
7mo ago+769+769+012345678901234567890123456789-175-175-012345678901234567890123456789
Summary
- Add
I18nutility class with UTF-8ResourceBundleloading and locale parsing - Extract all user-facing strings from renderers (Console, Markdown, HTML, AsciiDoc) into
.propertiesresource bundles - Add
--langCLI option to select output language (en,zh-Hant,zh-CN) - Add CJK-aware display width calculation for correct console alignment with Chinese characters
- Add Traditional Chinese (
zh-TW) and Simplified Chinese (zh-CN) translation files - Set HTML
langattribute dynamically based on locale
Usage
# Default (English)
openapi-diff old.yaml new.yaml
# Traditional Chinese
openapi-diff old.yaml new.yaml --lang zh-Hant
# Simplified Chinese
openapi-diff old.yaml new.yaml --lang zh-CN
Test plan
- All 266 existing tests pass with default English locale
- Verify console output alignment with Chinese characters
- Verify HTML output includes correct
langattribute for each locale - Verify
--langCLI option selects correct translations
Summary by cubic
Add internationalization across renderers and the CLI with English, Traditional Chinese (zh-Hant), and Simplified Chinese (zh-CN). Adds a --lang option, CJK-aware console alignment, per-locale HTML lang, and hardens i18n with thread-safe and null-safe handling.
-
New Features
- Introduced
I18nutility with UTF-8ResourceBundleloading and locale parsing. - Replaced hardcoded strings in Console/Markdown/HTML/AsciiDoc with bundle messages.
- Added translations:
messages.properties(en),messages_zh_TW.properties(zh-Hant),messages_zh_CN.properties(zh-CN). - Added
--langCLI option (en,zh-Hant,zh-CN), acceptszh-TW/zh-Hansaliases. - Implemented CJK-aware display width for proper console alignment.
- HTML output now sets the
langattribute based on the selected locale.
- Introduced
-
Bug Fixes
- Prevented NPEs by adding null checks to CJK centering helpers.
- Made
I18nlocale and bundle handling thread-safe (volatile fields, synchronizedsetLocale).