refactor: move from next-international to next-intl (#1368)
* refactor: move from next-international to next-intl * refactor: restructure translation package, * chore: change i18n-allay framework to next-intl * fix: add missing bold html tag to translation * fix: format issue * fix: address deepsource issues * fix: remove international-types dependency * fix: lint and typecheck issues * fix: typecheck issue * fix: typecheck issue * fix: issue with translations
This commit is contained in:
22
packages/translation/src/mapping.ts
Normal file
22
packages/translation/src/mapping.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { supportedLanguages } from "./config";
|
||||
|
||||
const _enTranslations = () => import("./lang/en");
|
||||
type EnTranslation = typeof _enTranslations;
|
||||
|
||||
export const createLanguageMapping = () => {
|
||||
const mapping: Record<string, unknown> = {};
|
||||
|
||||
for (const language of supportedLanguages) {
|
||||
mapping[language] = () => import(`./lang/${language}`) as ReturnType<EnTranslation>;
|
||||
}
|
||||
|
||||
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>;
|
||||
Reference in New Issue
Block a user