elements icon indicating copy to clipboard operation
elements copied to clipboard

i18n: consistently fall back to default locale

Open max-baz opened this issue 10 months ago • 0 comments

Preflight checklist

Ory Network Project

No response

Describe your problem

In some cases (e.g. in registration) you manually define "defaultMessage", in order to have a user-friendly English fallback.

https://github.com/ory/elements/blob/7a6254a8bfc38e4285689a2669df852639c72abd/packages/elements-react/src/theme/default/components/card/footer.tsx#L102-L105

In other cases (e.g. in settings) the UI falls back to "id" of the translation, making the UI really not something you want to show to your visitors.

Image

Furthermore, those defaultMessages are sometimes inconsistent with the English locale (e.g. "Don't have an account?" has a fallback "No account?") and they don't respect custom translations provided for the English locale.

Describe your ideal solution

In IntlContext, after you merged custom translations:

https://github.com/ory/elements/blob/7a6254a8bfc38e4285689a2669df852639c72abd/packages/elements-react/src/context/intl-context.tsx#L164-L169

Run another helper that would loop over all locales and add all missing translations with values from the en locale. Then remove all mentions of defaultMessage from the codebase.

Perhaps make it optional to disable this in development mode, if you want to keep the in order to catch missing localization.

Ease of development however should not be prioritized over nice user experience, and right now using ory/elements on an internationalized website makes a very bad user experience, where users are presented with some internal localization IDs.

Workarounds or alternatives

  1. Translate ory/elements into all locales 🙌

  2. Instead of passing the current website locale to ory/elements components, maintain a mapping in own code of what locales ory/elements currently supports, and pass "en" instead when it's known that ory/elements doesn't fully support the given locale.

Version

1.0.0-rc.2

Additional Context

No response

max-baz avatar May 11 '25 13:05 max-baz