2023-01-18 15:21:17 +03:00
|
|
|
const i18next = require('i18next');
|
|
|
|
|
2023-03-22 10:50:29 +03:00
|
|
|
const SUPPORTED_LOCALES = [
|
|
|
|
'en',
|
|
|
|
'nl'
|
|
|
|
];
|
2023-01-18 20:21:36 +03:00
|
|
|
|
2023-03-01 11:10:11 +03:00
|
|
|
/**
|
|
|
|
* @param {string} [lng]
|
2023-03-16 16:15:01 +03:00
|
|
|
* @param {'ghost'|'portal'|'test'} ns
|
2023-03-01 11:10:11 +03:00
|
|
|
*/
|
|
|
|
module.exports = (lng = 'en', ns = 'portal') => {
|
2023-01-18 15:21:17 +03:00
|
|
|
const i18nextInstance = i18next.createInstance();
|
|
|
|
i18nextInstance.init({
|
|
|
|
lng,
|
|
|
|
|
|
|
|
// 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-03-01 11:10:11 +03:00
|
|
|
ns: ns,
|
|
|
|
defaultNS: ns,
|
|
|
|
|
2023-03-01 12:30:18 +03:00
|
|
|
resources: SUPPORTED_LOCALES.reduce((acc, locale) => {
|
|
|
|
acc[locale] = {
|
|
|
|
[ns]: require(`../locales/${locale}/${ns}.json`)
|
|
|
|
};
|
2023-03-01 11:10:11 +03:00
|
|
|
return acc;
|
|
|
|
}, {})
|
2023-01-18 15:21:17 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
return i18nextInstance;
|
|
|
|
};
|
2023-01-18 20:21:36 +03:00
|
|
|
|
|
|
|
module.exports.SUPPORTED_LOCALES = SUPPORTED_LOCALES;
|