Skip to content

Translations overridden by server defaults #601

Description

@vilasp

Preflight checklist

Ory Network Project

No response

Describe the bug

Upgrading to Ory elements v1.2.0 we found a bug in translations not being honored. When trying to sign up with a already existing email, for an account with no social signing options, we get the error message back in english instead of our translation.

Looking further into the issue it seems like the following happens,

In node_modules/@ory/elements-react/dist/theme/default/index.mjs → uiTextToFormattedMessage (line 1269):

  if (isKratosMessageId(id)) {
    const hasEmptyArrayContext = Object.values(context).some(
      (v) => Array.isArray(v) && v.length === 0
    );
    if (hasEmptyArrayContext) {
      return text;                                    // ← returns raw server text (English), skips translation
    }
    return intl.formatMessage(kratosMessages[id], contextInjectedMessage);
  }

If any value in the message's context is an empty array, Ory bails out and returns the raw server text — never running it through intl.formatMessage, so our customTranslations (svOry.json) are bypassed.

Reproducing the bug

  1. Use Ory/elements-react v1.2.0
  2. Add a custom translation for a different language other than English
  3. Create a account using a non social signing provider option, like email + password
  4. Logout and try to repeat 2 with the same email
  5. The error message is now in English instead of your language set in the translation file

Relevant log output

Relevant configuration

Version

1.2.0

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

Other

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions