2023-01-18 15:21:17 +03:00
|
|
|
const i18next = require('i18next');
|
|
|
|
|
2023-01-18 20:21:36 +03:00
|
|
|
const RESOURCES = {
|
|
|
|
en: {
|
|
|
|
translation: require('../locales/en.json')
|
|
|
|
},
|
|
|
|
nl: {
|
|
|
|
translation: require('../locales/nl.json')
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const SUPPORTED_LOCALES = Object.keys(RESOURCES);
|
|
|
|
|
2023-01-18 15:21:17 +03:00
|
|
|
module.exports = (lng = 'en') => {
|
|
|
|
const i18nextInstance = i18next.createInstance();
|
|
|
|
i18nextInstance.init({
|
|
|
|
lng,
|
|
|
|
debug: process.env.NODE_ENV === 'development',
|
|
|
|
|
|
|
|
// allow keys to be phrases having `:`, `.`
|
|
|
|
nsSeparator: false,
|
|
|
|
keySeparator: false,
|
|
|
|
|
2023-02-27 15:17:27 +03:00
|
|
|
// if the value is an empty string, return the key
|
|
|
|
returnEmptyString: false,
|
|
|
|
|
2023-01-18 15:21:17 +03:00
|
|
|
// do not load a fallback
|
|
|
|
fallbackLng: false,
|
|
|
|
|
2023-01-18 20:21:36 +03:00
|
|
|
resources: RESOURCES
|
2023-01-18 15:21:17 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
return i18nextInstance;
|
|
|
|
};
|
2023-01-18 20:21:36 +03:00
|
|
|
|
|
|
|
module.exports.SUPPORTED_LOCALES = SUPPORTED_LOCALES;
|