* implement i18n capability * reset package.lock file * remove custom fallback * fix relative path for i18n files * check for language support before fetch request * add LanguageDropdown component, es translation file to prove functionality * remove boilerplate * bundle default english translation with app * add missing file * rollup component-level i18n files * cleanup Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
30 lines
761 B
TypeScript
30 lines
761 B
TypeScript
import i18n from 'i18next';
|
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
import { initReactI18next } from 'react-i18next';
|
|
|
|
import { Language } from 'types';
|
|
|
|
import I18nBackend from './i18n-backend';
|
|
|
|
// Bundle default translation with application
|
|
import translation from './i18n-default.json';
|
|
|
|
i18n
|
|
.use(I18nBackend)
|
|
.use(LanguageDetector)
|
|
.use(initReactI18next)
|
|
// for all options read: https://www.i18next.com/overview/configuration-options
|
|
.init({
|
|
fallbackLng: Language['en-US'],
|
|
resources: {
|
|
[Language['en-US']]: { translation },
|
|
},
|
|
partialBundledLanguages: true,
|
|
|
|
interpolation: {
|
|
// not needed for react as it escapes by default
|
|
escapeValue: false,
|
|
},
|
|
});
|
|
|
|
export default i18n;
|