Skip to content

i18n locale loading fails for regional locales (e.g. de-DE) #6257

@dev-cb

Description

@dev-cb

When the application initializes, i18next attempts to load locale files based on the browser language (e.g. de-DE).

The backend only provides base language files (e.g. de.json, en.json), but not regional variants like de-DE.json.

As a result:

  • GET /api/v1/locales/de-DE.json → 406 Not Acceptable
  • Response body is empty (Content-Length: 0)
  • The frontend does not handle this failure gracefully

This leads to a runtime error:

TypeError: Cannot read properties of null (reading 'data')

And finally React rendering fails during initialization.

Observed Behavior:
Despite valid fallback languages being loaded, the failed de-DE request causes the app to crash.

Expected Behavior:
The app should either

  1. Normalize de-DE → de before requesting locale files, or
  2. Gracefully fall back to de / en if a regional locale is not available

A failed locale request must not crash the application

Assumed root cause:
Frontend configuration uses:

load: 'currentOnly'

This forces i18next to load the exact locale (de-DE) instead of falling back to the base language (de).

Backend only supports base locales (de, en) and returns 406 for unsupported locales.

Additionally, the frontend does not defensively handle failed HTTP responses.


Besides that, I suggest to ensure that HTTP failures are handled safely.
Avoid assuming response shape (response.data) without validation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions