Fix translation keys (#4111)
This commit is contained in:
parent
86a3abdd5a
commit
bc3f203f6c
1 changed files with 10 additions and 6 deletions
|
@ -9,21 +9,25 @@ type TranslationKeys = keyof typeof leftOperatorsMessages;
|
||||||
export const useTranslate = () => {
|
export const useTranslate = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
|
const formatLeftOperand = (label: TranslationKeys) => {
|
||||||
|
const key = leftOperatorsMessages[label];
|
||||||
|
|
||||||
|
if (!key) return label;
|
||||||
|
|
||||||
|
return intl.formatMessage(leftOperatorsMessages[label]);
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
translateOperandOptions: (operands: LeftOperand[]) =>
|
translateOperandOptions: (operands: LeftOperand[]) =>
|
||||||
operands.map(el => ({
|
operands.map(el => ({
|
||||||
...el,
|
...el,
|
||||||
label: intl.formatMessage(
|
label: formatLeftOperand(el.label as TranslationKeys),
|
||||||
leftOperatorsMessages[el.label as TranslationKeys],
|
|
||||||
),
|
|
||||||
})),
|
})),
|
||||||
translateSelectedOperands: (container: FilterContainer) =>
|
translateSelectedOperands: (container: FilterContainer) =>
|
||||||
container.map(el => {
|
container.map(el => {
|
||||||
if (FilterElement.isCompatible(el)) {
|
if (FilterElement.isCompatible(el)) {
|
||||||
el.value.setLabel(
|
el.value.setLabel(
|
||||||
intl.formatMessage(
|
formatLeftOperand(el.value.label as TranslationKeys),
|
||||||
leftOperatorsMessages[el.value.label as TranslationKeys],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue