fix(i18n): complete command center texts and merge client fallbacks
This commit is contained in:
1 parent
8b59bd1d2d
commit
b12e405b34
5 files changed
+272
-5
No files matched your search
@@ -0,0 +1,17 @@
|
||||
export type MessageTree = { [key: string]: string | MessageTree };
|
||||
|
||||
/** Fill missing translations before sending messages to server and client consumers. */
|
||||
export function mergeMessages(
|
||||
fallback: MessageTree,
|
||||
localized: MessageTree,
|
||||
): MessageTree {
|
||||
const result: MessageTree = { ...fallback };
|
||||
for (const [key, value] of Object.entries(localized)) {
|
||||
const base = fallback[key];
|
||||
result[key] =
|
||||
typeof value === "object" && typeof base === "object"
|
||||
? mergeMessages(base, value)
|
||||
: value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in new issue
Block a user