Better locale management in the admin console

Closes #39934

Signed-off-by: rmartinc <rmartinc@redhat.com>
This commit is contained in:
rmartinc
2025-05-27 17:58:09 +02:00
committed by Marek Posolda
parent 4b0ce0d92b
commit 9e7ef7989d
3 changed files with 19 additions and 2 deletions

View File

@@ -2888,6 +2888,7 @@ emptyPermissionInstructions=If you want to create a permission, please click the
webAuthnPolicyAvoidSameAuthenticatorRegisterHelp=Avoid registering an authenticator that has already been registered.
memberofLdapAttribute=Member-of LDAP attribute
supportedLocales=Supported locales
invalidLocale=Invalid locale selected
showPasswordDataValue=Value
webAuthnPolicyAttestationConveyancePreference=Attestation conveyance preference
copyOf=Copy of {{name}}
@@ -3490,4 +3491,4 @@ fullNameClaimHelp=The name of the claim from the JSON document returned by the u
givenNameClaim=Given name Claim
givenNameClaimHelp=The name of the claim from the JSON document returned by the user profile endpoint representing the user's given name. If not provided, defaults to `given_name`.
familyNameClaim=Family name Claim
familyNameClaimHelp=The name of the claim from the JSON document returned by the user profile endpoint representing the user's family name. If not provided, defaults to `family_name`.
familyNameClaimHelp=The name of the claim from the JSON document returned by the user profile endpoint representing the user's family name. If not provided, defaults to `family_name`.

View File

@@ -98,8 +98,15 @@ export const LocalizationTab = ({
name="supportedLocales"
isScrollable
label={t("supportedLocales")}
labelIcon={t("supportedLocalesHelp")}
controller={{
defaultValue: defaultSupportedLocales,
rules: {
required: t("required"),
validate: (value: string[]) =>
value.every((v) => allLocales.includes(v)) ||
t("invalidLocale"),
},
}}
variant="typeaheadMulti"
placeholderText={t("selectLocales")}
@@ -111,8 +118,14 @@ export const LocalizationTab = ({
<SelectControl
name="defaultLocale"
label={t("defaultLocale")}
labelIcon={t("defaultLocaleHelp")}
controller={{
defaultValue: DEFAULT_LOCALE,
rules: {
required: t("required"),
validate: (value: string) =>
watchSupportedLocales?.includes(value) || t("required"),
},
}}
data-testid="select-default-locale"
options={watchSupportedLocales!.map((l) => ({

View File

@@ -564,7 +564,10 @@ public class ModelToRepresentation {
}
rep.setInternationalizationEnabled(realm.isInternationalizationEnabled());
rep.setSupportedLocales(realm.getSupportedLocalesStream().collect(Collectors.toSet()));
Set<String> supportedLocales = realm.getSupportedLocalesStream().collect(Collectors.toSet());
if (!supportedLocales.isEmpty()) {
rep.setSupportedLocales(supportedLocales);
}
rep.setDefaultLocale(realm.getDefaultLocale());
if (internal) {
exportAuthenticationFlows(session, realm, rep);