Files
kaman-cable/src/i18n/index.ts
T

15 lines
594 B
TypeScript

import { ar } from "@/i18n/ar";
import { defaultLocale, isLocale, type Locale } from "@/i18n/config";
import { en } from "@/i18n/en";
import { fa, type Messages } from "@/i18n/fa";
export const dictionaries: Record<Locale, Messages> = { fa, en, ar };
export function getMessages(locale: Locale | string | null | undefined): Messages {
return dictionaries[isLocale(locale) ? locale : defaultLocale];
}
export function interpolate(template: string, vars: Record<string, string>) {
return Object.entries(vars).reduce((text, [key, value]) => text.split(`{${key}}`).join(value), template);
}