← 输入框|github.com|刷新
Skip to content

Format i18n message arguments with the message locale - #4500

Merged
bbakerman merged 1 commit into
graphql-java:masterfrom
Meemaw:fix/i18n-message-format-locale
Oct 19, 2026
Merged

bbakerman merged 1 commit into
graphql-java:masterfrom
Meemaw:fix/i18n-message-format-locale

Conversation

@Meemaw

@Meemaw Meemaw commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Problem

I18n.msgImpl creates its formatter with new MessageFormat(msgPattern), which uses the JVM default (format) locale. So the message text comes from the requested locale's bundle, but the arguments (line/column numbers, counts, etc.) are formatted with whatever locale the JVM happens to run in.

For example, with a JVM default locale of sl_SI, an English parser error renders as:

... Offending token '\uD83D' at line −1 column −1     (U+2212 minus sign)
... Offending token at line −1 column 1.234

instead of line -1 column -1 / column 1,234. A side effect is that StringValueParsingUnicodeTest (which explicitly requests Locale.ENGLISH) fails 14 tests on machines with such a default locale.

Fix

Pass the I18n instance's locale to the MessageFormat, so arguments are formatted consistently with the message. This is the only MessageFormat usage in src/main.

Note: for a JVM whose default locale already matches the requested locale (the common case) the output is unchanged.

Verification

  • Added I18nTest case that sets the JVM default to sl-SI and checks that an English message formats -1 / 1,234 and a German message formats 1.234. Without the fix it fails with line −1 column 1.234.
  • The 14 previously failing StringValueParsingUnicodeTest tests now pass on a sl_SI machine.
  • Full test suite passes (5773 tests, JDK 25, LANG=sl_SI.UTF-8).

🤖 Generated with Claude Code

I18n.msgImpl created its MessageFormat without a locale, so message
arguments such as line and column numbers were formatted with the JVM
default locale rather than the locale the message was requested in.
On a JVM whose default locale is for example sl_SI, an English message
renders -1 with a unicode minus sign and 1234 as "1.234", which also
made StringValueParsingUnicodeTest fail on such machines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Meemaw
Meemaw marked this pull request as ready for review October 17, 2026 20:00
@github-actions

Copy link
Copy Markdown
Contributor

Test Report

Test Results

Java Version Total Passed Failed Errors Skipped
Java 11 5963 (+1 🟢) 5907 (+1 🟢) 0 (±0) 0 (±0) 56 (±0)
Java 17 5963 (+1 🟢) 5906 (+1 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 21 5963 (+1 🟢) 5906 (+1 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 25 5963 (+1 🟢) 5906 (+1 🟢) 0 (±0) 0 (±0) 57 (±0)
jcstress 32 (±0) 32 (±0) 0 (±0) 0 (±0) 0 (±0)
Total 23884 (+4 🟢) 23657 (+4 🟢) 0 (±0) 0 (±0) 227 (±0)

Code Coverage (Java 25)

Metric Covered Missed Coverage vs Master
Lines 30140 3118 90.6% ±0.0%
Branches 8838 1520 85.3% ±0.0%
Methods 8048 1207 87.0% ±0.0%

No per-class coverage changes detected.

Full HTML report: build artifact jacoco-html-report

Updated: 2026-10-19 00:18:25 UTC

@bbakerman bbakerman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@bbakerman
bbakerman merged commit ec73202 into graphql-java:master Oct 19, 2026
10 checks passed
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