Skip to content

Format i18n message arguments with the message locale - #4500

Open
Meemaw wants to merge 1 commit into
graphql-java:masterfrom
Meemaw:fix/i18n-message-format-locale
Open

Meemaw wants to merge 1 commit into
graphql-java:masterfrom
Meemaw:fix/i18n-message-format-locale

Conversation

@Meemaw

@Meemaw Meemaw commented Oct 17, 2026

Copy link
Copy Markdown

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

This branch has not been deployed

No deployments
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