Files
omni-tools/src/i18n/index.ts

36 lines
714 B
TypeScript
Raw Normal View History

2025-07-13 15:39:12 +01:00
import i18n, { ParseKeys } from 'i18next';
2025-07-12 23:02:35 -07:00
import { initReactI18next } from 'react-i18next';
import Backend from 'i18next-http-backend';
2025-07-15 18:30:02 +01:00
export const validNamespaces: (string | 'translation')[] = [
2025-07-14 18:04:30 +01:00
'string',
'number',
'video',
'list',
'json',
'time',
'csv',
'pdf',
'audio',
'xml',
'translation',
'image'
];
export type I18nNamespaces = (typeof validNamespaces)[number];
2025-07-13 16:59:57 +01:00
export type FullI18nKey = {
[K in I18nNamespaces]: `${K}:${ParseKeys<K>}`;
}[I18nNamespaces];
2025-07-12 23:02:35 -07:00
2025-07-14 19:38:46 +01:00
i18n
.use(Backend)
.use(initReactI18next)
.init({
lng: localStorage.getItem('lang') || 'en',
fallbackLng: 'en',
backend: {
loadPath: '/locales/{{lng}}/{{ns}}.json'
}
});
2025-07-12 23:02:35 -07:00
export default i18n;