feat: add compile-time i18n for log and exception messages#17613
Merged
Conversation
Add Maven-based compile-time internationalization infrastructure that
switches between English and Chinese message constants via profile,
with zero runtime overhead (javac inlines static final String constants).
Build commands:
mvn clean package -DskipTests # English (default)
mvn clean package -DskipTests -Pwith-zh-locale # Chinese
Infrastructure:
- Add i18n.locale property (default: en) and with-zh-locale profile
- Configure build-helper-maven-plugin to add src/main/i18n/${i18n.locale}
as additional source directory
Message constant classes (25 en + 25 zh = 50 files):
- node-commons: AuthMessages, ClientMessages, CommonMessages,
ConfigMessages, PathMessages, PipeMessages, QueryMessages,
SchemaMessages, ServiceMessages, UtilMessages
- datanode: StorageEngineMessages, DataNodeQueryMessages,
DataNodePipeMessages, DataNodeSchemaMessages, DataNodeMiscMessages
- confignode: ConfigNodeMessages, ManagerMessages, ProcedureMessages
- consensus: ConsensusMessages, IoTConsensusMessages,
IoTConsensusV2Messages, RatisMessages
- session: SessionMessages
- cli: CliMessages
- jdbc: JdbcMessages
4635 hardcoded strings replaced with compile-time constants across
7 modules.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #17613 +/- ##
============================================
- Coverage 40.42% 40.40% -0.03%
Complexity 2574 2574
============================================
Files 5179 5179
Lines 349261 349628 +367
Branches 44683 44683
============================================
+ Hits 141206 141258 +52
- Misses 208055 208370 +315 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add compile-time i18n message constants for service-rpc, calc-commons, library-udf, udf-api, metrics/interface, metrics/core, subscription, isession, mqtt, rest, pipe-api, and trigger-api modules.
…sus, confignode, session, and partial node-commons/datanode
…ssages - Replace ~230 hardcoded strings with i18n constants across all target modules - Modules covered: datanode, confignode, node-commons, consensus, calc-commons - Add Chinese translations for all new constants in zh locale files - Add CI compile check for Chinese locale build - Update README/README_ZH/CLAUDE.md with Chinese build instructions - Both EN and ZH locale compilation verified
Apply fixes from code review of ty/chinese i18n PR: - Remove unused PipeMessages.PATH_TRAVERSAL_DETECTED (P0: EN/ZH inconsistency) - Replace prefix/suffix fragment concatenation with String.format in CalcMessages, JdbcMessages, DataNodeQueryMessages so single-placeholder format strings are used end-to-end - Rename short/ambiguous constants: DataNodeQueryMessages.VS -> TYPE_MISMATCH_FMT; drop the OF/EXISTS fragments in favour of SOURCE_HANDLE_FOR_PLAN_NODE_EXISTS_FMT - Shorten three 70+ char constant names in confignode (Manager/Procedure messages) - Remove unused SessionMessages.REDIRECT_TWICE_EXCEPTION/REDIRECT_TWICE_SUFFIX; move local REDIRECT_TWICE/REDIRECT_TWICE_RETRY out of Session.java and split into REDIRECT_TWICE_LOG[_WITH_SQL] / REDIRECT_TWICE_MSG[_WITH_SQL] pairs
|
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
-Pwith-zh-localeprofilepublic static final Stringconstants are inlined by javac into bytecodeBuild commands
Design
src/main/i18n/en/andsrc/main/i18n/zh/directories with same-package same-class message constant filesbuild-helper-maven-pluginaddssrc/main/i18n/${i18n.locale}as compile source root{}(SLF4J), exception messages use%s(String.format) or plain stringsModules covered
Test plan
mvn compilewith default (en) profile — BUILD SUCCESSmvn compile -Pwith-zh-locale— BUILD SUCCESSjavap -cverification: Chinese strings inlined directly into bytecode