GeezerVison is showing github.com — feat: add i18n support with zh-Hant and zh-CN translations by Jacky97s · Pull Request #899 · OpenAPITools/openapi-diff
Conversation
Jacky97s
commented
Mar 20, 2026
•
edited by cubic-dev-ai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
- Add
I18n utility class with UTF-8 ResourceBundle loading and locale parsing
- Extract all user-facing strings from renderers (Console, Markdown, HTML, AsciiDoc) into
.properties resource bundles
- Add
--lang CLI 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
lang attribute 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
lang attribute for each locale
- Verify
--lang CLI 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
I18n utility with UTF-8 ResourceBundle loading 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
--lang CLI option (en, zh-Hant, zh-CN), accepts zh-TW/zh-Hans aliases.
- Implemented CJK-aware display width for proper console alignment.
- HTML output now sets the
lang attribute based on the selected locale.
-
Bug Fixes
- Prevented NPEs by adding null checks to CJK centering helpers.
- Made
I18n locale and bundle handling thread-safe (volatile fields, synchronized setLocale).
Written for commit da71782. Summary will update on new commits.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- Add I18n utility class with UTF-8 ResourceBundle loading and locale parsing
- Add English messages.properties as default resource bundle
- Replace hardcoded strings in ConsoleRender, MarkdownRender, HtmlRender, AsciidocRender with I18n.getMessage() calls
- Add CJK-aware display width calculation for correct console alignment
- Add --lang CLI option to select output language
- Set HTML lang attribute dynamically based on locale
- Add messages_zh_TW.properties with full Traditional Chinese translations
…upport
- Add messages_zh_CN.properties with full Simplified Chinese translations
- Add zh-Hant, zh-TW, zh-Hans, zh-CN locale parsing to I18n
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 10 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="core/src/main/java/org/openapitools/openapidiff/core/output/ConsoleRender.java">
<violation number="1" location="core/src/main/java/org/openapitools/openapidiff/core/output/ConsoleRender.java:362">
P2: New CJK centering helper is not null-safe and can throw NPE during rendering/formatting.</violation>
</file>
<file name="core/src/main/java/org/openapitools/openapidiff/core/output/I18n.java">
<violation number="1" location="core/src/main/java/org/openapitools/openapidiff/core/output/I18n.java:20">
P2: `I18n` uses unsynchronized mutable static locale/bundle state, which is not thread-safe and can leak or mismatch language state across concurrent operations.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-ai with guidance or docs links (including llms.txt)
- Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Add null checks to centerCjk() and displayWidth() to prevent NPE
when title or text is null during rendering
- Make I18n locale/bundle fields volatile and setLocale() synchronized
to prevent state mismatch across concurrent operations
https://claude.ai/code/session_01XTXX1WQecRWzUdK5ewwnrZ
cubic-dev-ai[bot] reacted with eyes emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
@cubic-dev-ai
review again
@Jacky97s I have started the AI code review. It will take a few minutes to complete.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 10 files
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as duplicate.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
[](https://gitpod.io/#https://github.com/OpenAPITools/openapi-diff)
|
|
|
[](https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g)
|
|
|
[Contribute with Gitpod](https://gitpod.io/#https://github.com/OpenAPITools/openapi-diff)
|
|
|
[Join the Slack chat room](https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This replaces the badge image links with plain text links for Build, Sonar, Maven Central, Gitpod, Slack, and Docker. That removes the visible badges from the rendered README and appears unrelated to the i18n feature. Please revert the README formatting-only changes, or at least keep the existing badge image syntax.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
DrSatyr
DrSatyr left review comments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|