8000 Add locale attribute to the registration context by rmartinc · Pull Request #38549 · keycloak/keycloak · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add locale attribute to the registration context #38549

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

Merged
merged 1 commit into from
Apr 2, 2025

Conversation

rmartinc
Copy link
Contributor

Closes #38029

This PR adds the locale attribute to the User Profile in the registration context. The idea is the registration page also sends the current locale of the user as another attribute of the registration. There have been several issues about the same so I think that it's better to add this attribute when internationalization is enabled in the realm. The theme just manages the locale attribute separately (exactly as the admin and account console are doing in UserProfileFields.tsx). The change is better checked hiding white-spaces (the ftl files are only adding an if-else and the big change is in indentation).

It's a draft for the moment because it's a little change in behavior. But it's minor and I think that it's an improvement. WDYT? If accepted, do this need a release note?

Closes keycloak#38029

Signed-off-by: rmartinc <rmartinc@redhat.com>
@mposolda mposolda self-assigned this Mar 31, 2025
@mposolda
Copy link
Contributor
mposolda commented Apr 1, 2025

IMO the change is good. However I would like also the review from @keycloak/core-iam team as it is user-profile related issue.

I have one concern though: In case that attribute locale is explicitly defined in the user-profile, then it is the question what happens in case that there is different language shown in the locale combobox ( locale.currentLanguageTag ) and as the value of the locale attribute on the registration attributes? It seems that with the current PR, the combobox will have preference. Which IMO is OK behaviour. But just checking (also with @keycloak/core-iam ) if this is expected.

@rmartinc
Copy link
Contributor Author
rmartinc commented Apr 1, 2025

@mposolda The locale works exactly the same than in the account and admin console. If it is re-defined in the UP it is just skipped and used in the same way. I mean, the definition does not matter, the selectbox in account and admin console is presented with the realm values, and in the registration page the hidden input is set with the value set by the language combobox (currentLanguageTag).

@mposolda
Copy link
Contributor
mposolda commented Apr 1, 2025

@mposolda The locale works exactly the same than in the account and admin console. If it is re-defined in the UP it is just skipped and used in the same way. I mean, the definition does not matter, the selectbox in account and admin console is presented with the realm values, and in the registration page the hidden input is set with the value set by the language combobox (currentLanguageTag).

Yes, that is what I can spot as well. Thanks for the clarification. If @keycloak/core-iam is fine with the PR, I hope we can merge.

@rmartinc
Copy link
Contributor Author
rmartinc commented Apr 1, 2025

I first thought about adding a special input type locale to do this (instead of using the attribute name, we use the input locale to display the select-box in consoles and the hidden input in registration). But this was more complicated (not much) and I would need to change also the consoles.

Copy link
Contributor
@sguilhen sguilhen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the approach makes sense and I have no objections to have this PR merged. I would just ensure @pedroigor gives his ack too.

Copy link
Contributor
@jonkoops jonkoops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor
@pedroigor pedroigor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @rmartinc. LGTM.

@mposolda
Copy link
Contributor
mposolda commented Apr 2, 2025

@pedroigor @jonkoops @sguilhen Thanks everyone for the review!

@mposolda mposolda merged commit 43c79e8 into keycloak:main Apr 2, 2025
75 checks passed
@davidjbng
Copy link

Hi all,
this turned out to be a breaking change for anyone using a custom theme for user-profile-commons.
Updating to Keycloak 26.2.0 made the locale attribute appear in our registration page using a custom theme.

Is it expected for users to check for required updates to their templates on every release themselves?
I think this should have at least been mentioned in the migration guide. Maybe this can still be added for those that haven't upgraded.

@ahus1
Copy link
Contributor
ahus1 commented May 8, 2025

@davidjbng - please open a bug issue and link it to this PR to discuss if there should be an addition to the migration guide, or if the implementation should change to be backwards compatible with other themes.

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

Successfully merging this pull request may close these issues.

User created with undefined locale except when they explicitely select their language
7 participants
0