fix: i18n.ts

This commit is contained in:
Ibrahima G. Coulibaly
2025-07-14 19:38:46 +01:00
parent 9dec2a82e9
commit a6ec09283c

View File

@@ -2,26 +2,6 @@ import i18n, { ParseKeys } from 'i18next';
import { initReactI18next } from 'react-i18next';
import Backend from 'i18next-http-backend';
const isDevelopment = !import.meta.env.PROD;
const isContributor = import.meta.env.VITE_CONTRIBUTOR_MODE === 'true';
const useLocize = isDevelopment && isContributor;
if (useLocize) {
const { default: LocizeBackend } = await import('i18next-locize-backend');
i18n.use(LocizeBackend);
console.log('Using Locize backend in development/contributor mode');
} else {
// Use static files in production
i18n.use(Backend);
}
const locizeOptions = {
projectId: 'e7156a3e-66fb-4035-a0f0-cebf1c63a3ba',
apiKey: import.meta.env.LOCIZE_API_KEY,
referenceLng: 'en',
version: 'latest'
};
export const validNamespaces: string[] = [
'string',
'number',
@@ -41,17 +21,15 @@ export type FullI18nKey = {
[K in I18nNamespaces]: `${K}:${ParseKeys<K>}`;
}[I18nNamespaces];
i18n.use(initReactI18next).init({
i18n
.use(Backend)
.use(initReactI18next)
.init({
lng: localStorage.getItem('lang') || 'en',
fallbackLng: 'en',
debug: false,
backend: useLocize
? locizeOptions
: {
backend: {
loadPath: '/locales/{{lng}}/{{ns}}.json'
},
saveMissing: useLocize,
updateMissing: useLocize
});
}
});
export default i18n;