fix useKcMessage

This commit is contained in:
garronej 2021-10-11 23:35:32 +02:00
parent 403aedf1fe
commit 0e8984e5b1

View File

@ -64,16 +64,17 @@ export function useKcMessage() {
(key: string): string | undefined => {
const match = key.match(/^\$\{([^{]+)\}$/);
if (match === null) {
return key;
}
const resolvedKey = match === null ? key : match[1];
return (
const out =
id<Record<string, string | undefined>>(
kcMessages[kcLanguageTag],
)[key] ??
id<Record<string, string | undefined>>(kcMessages["en"])[key]
);
)[resolvedKey] ??
id<Record<string, string | undefined>>(kcMessages["en"])[
resolvedKey
];
return out !== undefined ? out : match === null ? key : undefined;
},
[msgStr],
);