diff --git a/js/apps/account-ui/test/personal-info/personal-info.spec.ts b/js/apps/account-ui/test/personal-info/personal-info.spec.ts index 2527647347..41c785c802 100644 --- a/js/apps/account-ui/test/personal-info/personal-info.spec.ts +++ b/js/apps/account-ui/test/personal-info/personal-info.spec.ts @@ -54,7 +54,10 @@ test.describe("Personal info with userprofile enabled", async () => { await expect(page.locator("#select")).toBeVisible(); await expect(page.getByTestId("help-label-select")).toBeVisible(); - expect(page.getByText("Alternative email")).toBeDefined(); + expect(page.getByText("Alternative email")).toHaveCount(1); + expect(page.getByPlaceholder("Deutsch")).toHaveCount(1); + page.getByTestId("help-label-email2").click(); + await expect(page.getByText("EspaƱol")).toHaveCount(1); }); test("save user profile", async ({ page }) => { diff --git a/js/apps/account-ui/test/personal-info/user-profile.json b/js/apps/account-ui/test/personal-info/user-profile.json index 31e46e2ac4..570bcc4e45 100644 --- a/js/apps/account-ui/test/personal-info/user-profile.json +++ b/js/apps/account-ui/test/personal-info/user-profile.json @@ -214,7 +214,10 @@ ] }, "annotations": { - "inputType": "html5-email" + "inputType": "html5-email", + "inputHelperTextBefore": "${locale_es}", + "inputHelperTextAfter": "${locale_fr}", + "inputTypePlaceholder": "${locale_de}" }, "validations": { "email": {} diff --git a/js/libs/ui-shared/src/user-profile/TextComponent.tsx b/js/libs/ui-shared/src/user-profile/TextComponent.tsx index 6a1338c650..b3ae3832dd 100644 --- a/js/libs/ui-shared/src/user-profile/TextComponent.tsx +++ b/js/libs/ui-shared/src/user-profile/TextComponent.tsx @@ -2,7 +2,7 @@ import { TextInput, TextInputTypes } from "@patternfly/react-core"; import { UserProfileFieldProps } from "./UserProfileFields"; import { UserProfileGroup } from "./UserProfileGroup"; -import { fieldName, isRequiredAttribute } from "./utils"; +import { fieldName, isRequiredAttribute, label } from "./utils"; export const TextComponent = (props: UserProfileFieldProps) => { const { form, inputType, attribute } = props; @@ -17,7 +17,10 @@ export const TextComponent = (props: UserProfileFieldProps) => { id={attribute.name} data-testid={attribute.name} type={type} - placeholder={attribute.annotations?.["inputTypePlaceholder"] as string} + placeholder={label( + props.t, + attribute.annotations?.["inputTypePlaceholder"] as string, + )} readOnly={attribute.readOnly} isRequired={isRequired} {...form.register(fieldName(attribute.name))} diff --git a/js/libs/ui-shared/src/user-profile/UserProfileGroup.tsx b/js/libs/ui-shared/src/user-profile/UserProfileGroup.tsx index bed646db8c..9fb7ad0325 100644 --- a/js/libs/ui-shared/src/user-profile/UserProfileGroup.tsx +++ b/js/libs/ui-shared/src/user-profile/UserProfileGroup.tsx @@ -11,6 +11,7 @@ import { UserFormFields, fieldName, isRequiredAttribute, + label, labelAttribute, } from "./utils"; @@ -28,7 +29,10 @@ export const UserProfileGroup = ({ renderer, children, }: PropsWithChildren) => { - const helpText = attribute.annotations?.["inputHelperTextBefore"] as string; + const helpText = label( + t, + attribute.annotations?.["inputHelperTextBefore"] as string, + ); const { formState: { errors }, } = form; diff --git a/themes/src/main/resources/theme/base/login/user-profile-commons.ftl b/themes/src/main/resources/theme/base/login/user-profile-commons.ftl index 25d26d89b3..8aa885ddcd 100644 --- a/themes/src/main/resources/theme/base/login/user-profile-commons.ftl +++ b/themes/src/main/resources/theme/base/login/user-profile-commons.ftl @@ -92,7 +92,7 @@ aria-invalid="<#if messagesPerField.existsError('${attribute.name}')>true" <#if attribute.readOnly>disabled <#if attribute.autocomplete??>autocomplete="${attribute.autocomplete}" - <#if attribute.annotations.inputTypePlaceholder??>placeholder="${attribute.annotations.inputTypePlaceholder}" + <#if attribute.annotations.inputTypePlaceholder??>placeholder="${advancedMsg(attribute.annotations.inputTypePlaceholder)}" <#if attribute.annotations.inputTypePattern??>pattern="${attribute.annotations.inputTypePattern}" <#if attribute.annotations.inputTypeSize??>size="${attribute.annotations.inputTypeSize}" <#if attribute.annotations.inputTypeMaxlength??>maxlength="${attribute.annotations.inputTypeMaxlength}" diff --git a/themes/src/main/resources/theme/keycloak.v2/login/user-profile-commons.ftl b/themes/src/main/resources/theme/keycloak.v2/login/user-profile-commons.ftl index c6748dd9fb..7a22b4936b 100644 --- a/themes/src/main/resources/theme/keycloak.v2/login/user-profile-commons.ftl +++ b/themes/src/main/resources/theme/keycloak.v2/login/user-profile-commons.ftl @@ -109,7 +109,7 @@ aria-invalid="<#if messagesPerField.existsError('${attribute.name}')>true" <#if attribute.readOnly>disabled <#if attribute.autocomplete??>autocomplete="${attribute.autocomplete}" - <#if attribute.annotations.inputTypePlaceholder??>placeholder="${attribute.annotations.inputTypePlaceholder}" + <#if attribute.annotations.inputTypePlaceholder??>placeholder="${advancedMsg(attribute.annotations.inputTypePlaceholder)}" <#if attribute.annotations.inputTypePattern??>pattern="${attribute.annotations.inputTypePattern}" <#if attribute.annotations.inputTypeSize??>size="${attribute.annotations.inputTypeSize}" <#if attribute.annotations.inputTypeMaxlength??>maxlength="${attribute.annotations.inputTypeMaxlength}"