feat: add compile-time i18n for log and exception messages#17613
Open
JackieTien97 wants to merge 8 commits intomasterfrom
Open
feat: add compile-time i18n for log and exception messages#17613JackieTien97 wants to merge 8 commits intomasterfrom
JackieTien97 wants to merge 8 commits intomasterfrom
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.25% 40.22% -0.04%
Complexity 2554 2554
============================================
Files 5177 5177
Lines 348701 348964 +263
Branches 44600 44600
============================================
- Hits 140367 140357 -10
- Misses 208334 208607 +273 ☔ 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
|
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