feat(ui): add locales and split catalogs
Adds Spanish, French, Russian, Japanese, and Simplified Chinese catalogs and wires supported locales into the i18n layer.
This commit is contained in:
@@ -14,7 +14,7 @@ import { sessionMessages } from "./session"
|
||||
import { settingsMessages } from "./settings"
|
||||
import { timeMessages } from "./time"
|
||||
import { toolCallMessages } from "./toolCall"
|
||||
import { mergeMessageParts } from "./merge"
|
||||
import { mergeMessageParts } from "../merge"
|
||||
|
||||
export const enMessages = mergeMessageParts(
|
||||
folderSelectionMessages,
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
export type MessageCatalog = Record<string, string>
|
||||
|
||||
type MergeParts<Parts extends readonly MessageCatalog[]> = Parts extends readonly [
|
||||
infer Head extends MessageCatalog,
|
||||
...infer Tail extends MessageCatalog[],
|
||||
]
|
||||
? Head & MergeParts<Tail>
|
||||
: {}
|
||||
|
||||
export function mergeMessageParts<const Parts extends readonly MessageCatalog[]>(
|
||||
...parts: Parts
|
||||
): MergeParts<Parts> {
|
||||
const result: Record<string, string> = Object.create(null)
|
||||
|
||||
for (const part of parts) {
|
||||
for (const [key, value] of Object.entries(part)) {
|
||||
if (key in result) {
|
||||
throw new Error(`Duplicate i18n message key: ${key}`)
|
||||
}
|
||||
result[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
return result as MergeParts<Parts>
|
||||
}
|
||||
Reference in New Issue
Block a user