Skip to content

feat: add compile-time i18n for log and exception messages#17613

Open
JackieTien97 wants to merge 10 commits intomasterfrom
ty/chinese
Open

feat: add compile-time i18n for log and exception messages#17613
JackieTien97 wants to merge 10 commits intomasterfrom
ty/chinese

Conversation

@JackieTien97
Copy link
Copy Markdown
Contributor

@JackieTien97 JackieTien97 commented May 7, 2026

Summary

  • Add Maven-based compile-time i18n infrastructure that switches between English and Chinese message constants via -Pwith-zh-locale profile
  • Zero runtime overhead: public static final String constants are inlined by javac into bytecode
  • Create 25 message constant classes (en + zh = 50 files) across 7 modules
  • Replace 4635 hardcoded log/exception message strings with compile-time constants

Build commands

mvn clean package -DskipTests                  # English (default)
mvn clean package -DskipTests -Pwith-zh-locale # Chinese

Design

  • Each module has src/main/i18n/en/ and src/main/i18n/zh/ directories with same-package same-class message constant files
  • build-helper-maven-plugin adds src/main/i18n/${i18n.locale} as compile source root
  • Log messages use {} (SLF4J), exception messages use %s (String.format) or plain strings
  • Language determined at compile time, not runtime — no ResourceBundle, no reflection

Modules covered

Module Message classes Constants
node-commons 10 718
datanode 5 2120
confignode 3 1068
consensus 4 237
session 1 133
cli 1 29
jdbc 1 99

Test plan

  • mvn compile with default (en) profile — BUILD SUCCESS
  • mvn compile -Pwith-zh-locale — BUILD SUCCESS
  • javap -c verification: Chinese strings inlined directly into bytecode
  • Integration test with Chinese build

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.
@JackieTien97 JackieTien97 requested a review from Copilot May 7, 2026 03:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 5.20487% with 856 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.22%. Comparing base (f5fbaa2) to head (80a5141).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ava/org/apache/iotdb/session/pool/SessionPool.java 6.29% 119 Missing ⚠️
...in/java/org/apache/iotdb/jdbc/IoTDBConnection.java 0.00% 34 Missing ⚠️
...rg/apache/iotdb/tool/backup/IoTDBDataBackTool.java 0.00% 20 Missing ⚠️
...ache/iotdb/jdbc/IoTDBAbstractDatabaseMetadata.java 0.00% 20 Missing ⚠️
...che/iotdb/confignode/manager/ProcedureManager.java 0.00% 20 Missing ⚠️
...ain/java/org/apache/iotdb/jdbc/IoTDBStatement.java 14.28% 18 Missing ⚠️
...tor/process/window/partition/frame/RangeFrame.java 0.00% 18 Missing ⚠️
...rc/main/java/org/apache/iotdb/session/Session.java 13.33% 13 Missing ⚠️
...he/iotdb/confignode/persistence/pipe/PipeInfo.java 0.00% 13 Missing ⚠️
...egation/ApproxPercentileWithWeightAccumulator.java 0.00% 12 Missing ⚠️
... and 207 more
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants