feat: add core i18n runtime and catalogs

This commit is contained in:
poyrazavsever
2026-07-19 03:06:38 +03:00
parent 0548820584
commit f4a2342ac4
12 changed files with 776 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import { interpolateMessage } from "./format";
import type { TranslationValues } from "./types";
export type Translator = {
locale: string;
messages: Record<string, string>;
t: (key: string, values?: TranslationValues) => string;
};
export function createTranslatorFromMessages(
locale: string,
messages: Record<string, string>,
): Translator {
return {
locale,
messages,
t(key, values) {
const message = messages[key] ?? key;
return interpolateMessage(message, values, locale);
},
};
}