This is my i18next config:
import i18n from 'i18next';
import {initReactI18next} from 'react-i18next';
import en from './lang/en.json';
import cn from './lang/cn.json';
import bh from './lang/bh.json';
const resources = {
en: {
translation: en,
},
cn: {
translation: cn,
},
bh: {
translation: bh,
},
};
export type TSupportedLanguages = keyof typeof resources;
export const SupportedLanguages = Object.keys(
resources,
) as (keyof typeof resources)[]; // I turn object keys to an array
i18n
.use(initReactI18next) // passes i18n down to react-i18next
.init({
compatibilityJSON: 'v3',
resources,
fallbackLng: 'en',
lng: 'en',
interpolation: {
escapeValue: false, // react already safes from xss
},
});
export default i18n;
later i can use SupportedLanguages as an array of Supported Languages