mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-01 20:29:17 +01:00
* feat: add support for all languages from old homarr * fix: add mantine-react-table translations, remove arabic language * refactor: change translations to json for better crowdin support * fix: issues with loading dayjs and mantine-react-table translations * chore: add additional translations with variables * fix: format and deepsource issues * fix: test failing because of missing coverage exclusions * fix: format issues * fix: format issue
23 lines
764 B
TypeScript
23 lines
764 B
TypeScript
import { supportedLanguages } from "./config";
|
|
|
|
const _enTranslations = () => import("./lang/en.json");
|
|
type EnTranslation = typeof _enTranslations;
|
|
|
|
export const createLanguageMapping = () => {
|
|
const mapping: Record<string, unknown> = {};
|
|
|
|
for (const language of supportedLanguages) {
|
|
mapping[language] = () => import(`./lang/${language}.json`);
|
|
}
|
|
|
|
return mapping as Record<(typeof supportedLanguages)[number], () => ReturnType<EnTranslation>>;
|
|
};
|
|
|
|
type NestedKeyOf<ObjectType extends object> = {
|
|
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object
|
|
? `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key]>}`
|
|
: `${Key}`;
|
|
}[keyof ObjectType & (string | number)];
|
|
|
|
export type TranslationKeys = NestedKeyOf<EnTranslation>;
|