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 => { (key: string): string | undefined => {
const match = key.match(/^\$\{([^{]+)\}$/); const match = key.match(/^\$\{([^{]+)\}$/);
if (match === null) { const resolvedKey = match === null ? key : match[1];
return key;
}
return ( const out =
id<Record<string, string | undefined>>( id<Record<string, string | undefined>>(
kcMessages[kcLanguageTag], kcMessages[kcLanguageTag],
)[key] ?? )[resolvedKey] ??
id<Record<string, string | undefined>>(kcMessages["en"])[key] id<Record<string, string | undefined>>(kcMessages["en"])[
); resolvedKey
];
return out !== undefined ? out : match === null ? key : undefined;
}, },
[msgStr], [msgStr],
); );