Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations don't work for registration traits #160

Open
3 of 5 tasks
Benehiko opened this issue Oct 13, 2023 · 2 comments
Open
3 of 5 tasks

Translations don't work for registration traits #160

Benehiko opened this issue Oct 13, 2023 · 2 comments

Comments

@Benehiko
Copy link
Contributor

Preflight checklist

Ory Network Project

No response

Describe your problem

The translations don't work well with registration traits due to the dynamic nature of the trait titles. This data is set by the Identity schema and requires that the implementer somehow replace the titles before they are used by the Ory Elements UserAuthCard. See this discussion on the topic #118 (reply in thread)

Describe your ideal solution

However, considering that we support translations now, it might make sense to add keys related to the traits per language. For example

{
  "identities.messages.1010001": "Sign in",
  "identities.messages.1010002": "Sign in with {provider}",
  "traits.email": "Email",
  "traits.phone": "Mobile Number"
}

Workarounds or alternatives

One could replace the JSON data for these specific traits in the language you would like them to display in. But this requires implementing your own strategy outside of the translation layer of Ory Elements, which isn't ideal.

Version

0.1.0-beta-10

Additional Context

No response

@calliope-codes
Copy link

calliope-codes commented Nov 21, 2023

As a temporary workaround for internationalization-related errors for custom user fields, I was able to get rid of translation errors for custom traits (email, first name, and last name from the email-password quick start schema) on the registration form (flowType="registration") while retaining the default UI input labels by using the following custom translation configuration:

const customTranslations: CustomLanguageFormats = {
  en: {
    ...locales.en,
    'identities.messages.1070002': '',
  },
};

I tried using an empty string as the value after noticing that all custom traits had the same id (1070002), which made it impossible to specify each identifier separately. My environment is Node 20.9.0, NextJS 14.0.1, Ory Kratos v1.0.0 (self-hosted in Docker on my local machine), and @ory/elements 0.1.0-beta.12.

@1xtr
Copy link
Contributor

1xtr commented Feb 16, 2024

And why ID is same?
image
so always Error in console

Error: [@formatjs/intl Error FORMAT_ERROR] Error formatting message: "identities.messages.1070002", using default message as fallback.
MessageID: identities.messages.1070002
Default Message: Username
Description: undefined

And of course, in translate we set both field if provide field identities.messages.1070002

const customTranslations: CustomLanguageFormats = {
  en: {
    ...locales.en,
    'login.title': 'Login',
    // reg form email and username both change
    // 'identities.messages.1070002': 'Email', 
    'identities.messages.1070004': 'Email',
  },
}

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

No branches or pull requests

3 participants