added inputOptionLabelsI18nPrefix
when looking up label (#31577)
fixes: #31111 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
parent
3139b82e3c
commit
c8d64f2891
4 changed files with 17 additions and 3 deletions
|
@ -18,6 +18,9 @@ export const OptionComponent = (props: UserProfileFieldProps) => {
|
|||
|
||||
const optionLabel =
|
||||
(attribute.annotations?.["inputOptionLabels"] as OptionLabel) || {};
|
||||
const prefix = attribute.annotations?.[
|
||||
"inputOptionLabelsI18nPrefix"
|
||||
] as string;
|
||||
|
||||
return (
|
||||
<UserProfileGroup {...props}>
|
||||
|
@ -32,7 +35,7 @@ export const OptionComponent = (props: UserProfileFieldProps) => {
|
|||
key={option}
|
||||
id={option}
|
||||
data-testid={option}
|
||||
label={label(props.t, optionLabel[option], option)}
|
||||
label={label(props.t, optionLabel[option], option, prefix)}
|
||||
value={option}
|
||||
isChecked={field.value.includes(option)}
|
||||
onChange={() => {
|
||||
|
|
|
@ -40,9 +40,12 @@ export const SelectComponent = (props: UserProfileFieldProps) => {
|
|||
|
||||
const optionLabel =
|
||||
(attribute.annotations?.["inputOptionLabels"] as OptionLabel) || {};
|
||||
const prefix = attribute.annotations?.[
|
||||
"inputOptionLabelsI18nPrefix"
|
||||
] as string;
|
||||
|
||||
const fetchLabel = (option: string) =>
|
||||
label(props.t, optionLabel[option], option);
|
||||
label(props.t, optionLabel[option], option, prefix);
|
||||
|
||||
const convertOptions = (selected: string) =>
|
||||
options
|
||||
|
|
|
@ -20,6 +20,8 @@ export const TextComponent = (props: UserProfileFieldProps) => {
|
|||
placeholder={label(
|
||||
props.t,
|
||||
attribute.annotations?.["inputTypePlaceholder"] as string,
|
||||
attribute.name,
|
||||
attribute.annotations?.["inputOptionLabelsI18nPrefix"] as string,
|
||||
)}
|
||||
readOnly={attribute.readOnly}
|
||||
isRequired={isRequired}
|
||||
|
|
|
@ -31,7 +31,13 @@ export const label = (
|
|||
t: TFunction,
|
||||
text: string | undefined,
|
||||
fallback?: string,
|
||||
) => (isBundleKey(text) ? t(unWrap(text!)) : text) || fallback;
|
||||
prefix?: string,
|
||||
) => {
|
||||
const value = text || fallback;
|
||||
const bundleKey = isBundleKey(value) ? unWrap(value!) : value;
|
||||
const key = prefix ? `${prefix}.${bundleKey}` : bundleKey;
|
||||
return t(key || "");
|
||||
};
|
||||
|
||||
export const labelAttribute = (
|
||||
t: TFunction,
|
||||
|
|
Loading…
Reference in a new issue