feat: add i18n support with zh-Hant and zh-CN translations#899
Open
Jacky97s wants to merge 5 commits intoOpenAPITools:masterfrom
Open
feat: add i18n support with zh-Hant and zh-CN translations#899Jacky97s wants to merge 5 commits intoOpenAPITools:masterfrom
Jacky97s wants to merge 5 commits intoOpenAPITools:masterfrom
Conversation
- 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.
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-aiwith guidance or docs links (includingllms.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.
core/src/main/java/org/openapitools/openapidiff/core/output/ConsoleRender.java
Show resolved
Hide resolved
core/src/main/java/org/openapitools/openapidiff/core/output/I18n.java
Outdated
Show resolved
Hide resolved
- 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
Author
|
review again |
@Jacky97s I have started the AI code review. It will take a few minutes to complete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
I18nutility class with UTF-8ResourceBundleloading and locale parsing.propertiesresource bundles--langCLI option to select output language (en,zh-Hant,zh-CN)zh-TW) and Simplified Chinese (zh-CN) translation fileslangattribute dynamically based on localeUsage
Test plan
langattribute for each locale--langCLI option selects correct translationsSummary by cubic
Add internationalization across renderers and the CLI with English, Traditional Chinese (
zh-Hant), and Simplified Chinese (zh-CN). Adds a--langoption, CJK-aware console alignment, per-locale HTMLlang, and hardens i18n with thread-safe and null-safe handling.New Features
I18nutility with UTF-8ResourceBundleloading and locale parsing.messages.properties(en),messages_zh_TW.properties(zh-Hant),messages_zh_CN.properties(zh-CN).--langCLI option (en,zh-Hant,zh-CN), acceptszh-TW/zh-Hansaliases.langattribute based on the selected locale.Bug Fixes
I18nlocale and bundle handling thread-safe (volatile fields, synchronizedsetLocale).Written for commit da71782. Summary will update on new commits.