Skip to content

DefaultI18NProvider falls back to the JVM default locale before the base bundle #26383

Closed
vaadin/use-cases
#428

Description

@totally-not-ai

DefaultI18NProvider.getBundle calls ResourceBundle.getBundle(BUNDLE_PREFIX, locale, classLoader) with the default ResourceBundle.Control. When there is no translations_<locale>.properties for the requested locale, that control tries the JVM's default locale before it falls back to the base translations.properties.

Example: an application with translations.properties (English) and translations_de.properties, running on a server whose default locale is de_DE. An English user (en_US) gets the German texts, because translations_de is found through the JVM default before the base file is reached. An application can only avoid this by adding an empty translations_en_US.properties for every supported locale.

Suggested: load the bundles with ResourceBundle.Control.getNoFallbackControl(ResourceBundle.Control.FORMAT_PROPERTIES), so a missing locale goes straight to the base file.

Activity

  1. totally-not-ai commented on Oct 13, 2026

    @totally-not-ai
    ContributorAuthor

    Triage: confirmed bug.

    DefaultI18NProvider.getBundle calls ResourceBundle.getBundle(BUNDLE_PREFIX, locale, classLoader), which uses the default ResourceBundle.Control. Its getFallbackLocale returns Locale.getDefault(), so when no bundle matches the requested locale (or its language), the JVM default locale's bundle is tried before the base translations.properties. The result therefore depends on the server's locale setting: with translations_de.properties on a de_DE server, an en_US user gets German. The existing unit test even documented this ("default translations.properties will be used if the locale AND system default locale is not found") and only passed because the build JVM's default locale had no bundle.

    Fix: as suggested, load bundles with ResourceBundle.Control.getNoFallbackControl(ResourceBundle.Control.FORMAT_PROPERTIES). Candidate lookup for the requested locale is unchanged (de_AT → de → base), only the JVM-default step is removed. DefaultInstantiator creates the default provider only when translation files exist, and the case "only locale bundles, none matching" still returns the key, as before.

    Note on behaviour: an app that relied on the JVM default locale's bundle being used for unknown locales will now get the base bundle instead. That old result depended on the server's environment, so this seems the right default.

    Draft PR with a regression test (fails before, passes after): #26387

  2. added theissue type on Oct 13, 2026
  3. moved this from 🔖 Normal Priority (P2) to ✅ Closed in Vaadin Flow bugs & maintenanceon Oct 14, 2026
  4. added a commit that references this issue on Oct 16, 2026
    53ee099
  5. added a commit that references this issue on Oct 20, 2026
    792b383
  6. vaadin-bot commented on Oct 22, 2026

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with Vaadin 25.4.0-alpha4.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions