Skip to content

Complete zh locale i18n: convert leftover literals, review translations, add zh-compile CI#18110

Merged
JackieTien97 merged 15 commits into
masterfrom
ty/locale-zh
Jul 5, 2026
Merged

Complete zh locale i18n: convert leftover literals, review translations, add zh-compile CI#18110
JackieTien97 merged 15 commits into
masterfrom
ty/locale-zh

Conversation

@JackieTien97

Copy link
Copy Markdown
Contributor

Motivation

Finish the Chinese (zh) locale i18n effort so that every user/log/exception-facing message flows through a MessagesClass constant and renders correctly under the zh build, and add CI to keep the zh locale from regressing.

iotdb uses compile-time i18n: each participating module has twin EN / ZH Messages classes swapped by the i18n.locale property (profile with-zh-locale). The default CI only compiled the EN locale, so leftover raw English string literals and zh-key/en-key drift could slip in untested.

Changes

Convert leftover raw literals → i18n constants. 185 call-sites across all i18n-enabled modules (datanode, confignode, node-commons, consensus, calc-commons, client libs, library-udf, api) that set a response message, threw an exception, or logged via LOGGER.x(...) with a hard-coded English literal now reference a *Messages constant. Includes leading-literal conversions (162), trailing-fragment merges into single full-message constants, and missed siblings — e.g. DataNodeInternalRPCServiceImpl.getDataPartitionTableGeneratorProgress, AstBuilder "Supported formats", WriteBackSink.

Exhaustive zh translation review. Reviewed all 9258 EN/ZH constant pairs (37 file pairs) and fixed ~1100 entries: untranslated prose (zh == en), garbled/mixed-language log messages (e.g. "任务 finishes 成功, time cost 是{} s"), a real output bug (UtilMessages doubled backslash), ",," double-comma typos, and a broken-Chinese "为 不" typo. Terms of art (TsFile, DataRegion, Consensus, SQL keywords, snake_case config keys, class/method names) are intentionally kept in English; format specifiers (%s/%d/{}) are preserved exactly.

Add zh-locale CI. New .github/workflows/zh-locale-compile.yml runs mvn clean test-compile -P with-zh-locale -DskipTests on push/PR to master/rel/*/rc/* — catches EN/ZH key-parity regressions and zh Messages class compile errors the EN-only CI misses.

Bug fix. ConfigurationFileUtils.acquireTargetFileLock logged WAITING_TO_ACQUIRE_CONFIG_FILE_LOCK (already the full message) concatenated with two fragment constants that duplicated its middle/last sentences, producing doubled output and an unbound trailing {}. Simplified to the single constant; removed the now-orphaned fragments from EN + ZH.

Verification

  • mvn test-compile -DskipTestsBUILD SUCCESS (EN)
  • mvn test-compile -DskipTests -P with-zh-localeBUILD SUCCESS (ZH)
  • EN/ZH parity: 9258 pairs, 0 missing / 0 extra / 0 format-specifier mismatches
  • A targeted grep for the original literal-in-message-call pattern returns 0 leftover slip-throughs across i18n-enabled modules
  • spotless:check clean

🤖 Generated with Claude Code

Run `mvn clean test-compile -P with-zh-locale -DskipTests` on push/PR
to master/rel/*/rc/* to guard the Chinese locale build, catching
key-parity regressions and zh Messages class compile errors that the
default EN-only CI misses.
Convert 185 raw English string literals in log/exception/setMessage
calls to MessagesClass constants across all i18n-enabled modules, so
they translate under the zh locale. Covers the leading-literal pass
(162 sites), trailing-fragment merges and missed siblings (23 sites,
e.g. DataNodeInternalRPCServiceImpl.getDataPartitionTableGeneratorProgress,
AstBuilder, WriteBackSink).

Review all 9258 zh translation pairs (37 file pairs); fix ~1100
untranslated and garbled/mixed-language messages while preserving
format specifiers and terms of art (TsFile, DataRegion, SQL keywords,
config keys, class/method names).

Fix a doubled-output bug in ConfigurationFileUtils.acquireTargetFileLock
where the full WAITING_TO_ACQUIRE_CONFIG_FILE_LOCK message was
concatenated with two fragment constants duplicating its middle/last
sentences (also leaving a stray {} unbound).

en/zh parity: 0 missing / 0 extra / 0 format-specifier mismatches;
both mvn test-compile and mvn test-compile -P with-zh-locale pass.
Convert 13 raw English string literals introduced by the master merge
to DataNodeQueryMessages constants in Analysis.java (1) and
StatementAnalyzer.java (12): requireNonNull precondition messages
and a String.format exception template. Reuses 3 existing constants
(EXPRESSION_IS_NULL, SCOPE_IS_NULL, MISSING_REQUIRED_ARGUMENT_S);
adds 10 new ones to en + zh with matching translations.

Document the convention in CLAUDE.md: never inline a user-facing
English literal in log/exception/setMessage/requireNonNull/format
calls; constant naming (PREFIX_NORMALIZED_MD5[:8]); en/zh parity;
verify with spotless + both-locale compile.
The source referenced EXCEPTION_LATERALCOLUMNALIYREFERENCES_IS_NULL
(typo) while the en/zh DataNodeQueryMessages define ...ALIASREFERENCES_,
causing 'cannot find symbol'. The earlier single-module incremental
compile masked it via a stale target class.
Add a Build-pitfall note: mvn compile -pl <module> builds against
stale ~/.m2 jars and target/ classes, so it can mask 'cannot find
symbol' for newly added/renamed *Messages constants or other cross-
module API changes. Verify i18n / cross-module edits with a full-
reactor mvn test-compile (both locales), and check the maven exit
code directly rather than via 'mvn ... && echo' (set -e skips &&).
@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 27.99296% with 409 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.82%. Comparing base (05e592c) to head (737ad0e).

Files with missing lines Patch % Lines
...gation/grouped/GroupedMaxMinByBaseAccumulator.java 0.00% 15 Missing ⚠️
...apache/iotdb/confignode/manager/ConfigManager.java 0.00% 14 Missing ⚠️
...apache/iotdb/tool/tsfile/ImportTsFileRemotely.java 0.00% 11 Missing ⚠️
...otdb/calc/plan/planner/TableOperatorGenerator.java 0.00% 11 Missing ⚠️
...rce/relational/aggregation/AccumulatorFactory.java 0.00% 10 Missing ⚠️
...aggregation/grouped/GroupedFirstByAccumulator.java 0.00% 10 Missing ⚠️
.../aggregation/grouped/GroupedLastByAccumulator.java 0.00% 10 Missing ⚠️
...in/java/org/apache/iotdb/jdbc/IoTDBConnection.java 0.00% 9 Missing ⚠️
...sion/subscription/AbstractSubscriptionSession.java 0.00% 8 Missing ⚠️
...aggregation/grouped/GroupedExtremeAccumulator.java 0.00% 8 Missing ⚠️
... and 106 more
Additional details and impacted files
@@             Coverage Diff             @@
##             master   #18110     +/-   ##
===========================================
  Coverage     41.81%   41.82%             
  Complexity      318      318             
===========================================
  Files          5296     5296             
  Lines        372207   373384   +1177     
  Branches      48183    48210     +27     
===========================================
+ Hits         155629   156152    +523     
- Misses       216578   217232    +654     

☔ View full report in Codecov by Harness.
📢 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.

…tiveOptimizer, etc.

Review-feedback fixes for PR #18110:
- ManagerMessages ZH: fix 8 constants with doubled backslash escapes
  (\\t/\\n/\\\") that printed literal \t/\n/\" under zh locale
  instead of tab/newline/quote — same bug class as UtilMessages.
- DataNodePipeMessages ZH: translate ~81 untranslated prose constants,
  fix 11 mixed-language '成功 transferred...' messages, fix half-width
  comma, correct 稀后->稍后 typo.
- IterativeOptimizer: RULE_S_BEFORE_S_AFTER_S used %s in a LOG.debug
  (SLF4J) call, silently dropping 3 args; change %s -> {} in en+zh.
- SessionMessages: fix doubled }} placeholder (en+zh).
- Half-width punctuation between Chinese chars -> full-width in
  DataNodeMiscMessages, StorageEngineMessages, CommonMessages.
- IoTConsensusServerImpl: merge a debug log split across two constants
  into one full-message constant; drop the two orphaned constants.
- CLAUDE.md: prefix rule now matches the codebase's actual
  LOG_/MESSAGE_/EXCEPTION_ three-way convention; add exemption that
  pure-punctuation fragments should not be constants, and one
  message = one constant (not concatenated fragments).
The i18n conversion in CastFunctionUtils swapped the throw messages but
the exception paths (long/double/text out-of-range, invalid boolean
text) had no unit tests. Add focused UT covering each cast method's
happy path and its SemanticException throw — 19 tests, all passing.
@sonarqubecloud

sonarqubecloud Bot commented Jul 5, 2026

Copy link
Copy Markdown

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

@JackieTien97 JackieTien97 merged commit 71cb6e6 into master Jul 5, 2026
43 of 44 checks passed
@JackieTien97 JackieTien97 deleted the ty/locale-zh branch July 5, 2026 12:16
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.

1 participant