2023-01-18 15:21:17 +03:00
|
|
|
const i18next = require('i18next');
|
|
|
|
|
2023-03-22 10:50:29 +03:00
|
|
|
const SUPPORTED_LOCALES = [
|
2023-05-30 16:31:09 +03:00
|
|
|
'af', // Afrikaans
|
|
|
|
'bg', // Bulgarian
|
|
|
|
'ca', // Catalan
|
|
|
|
'cs', // Czech
|
|
|
|
'da', // Danish
|
|
|
|
'de', // German
|
|
|
|
'en', // English
|
|
|
|
'eo', // Esperanto
|
|
|
|
'es', // Spanish
|
|
|
|
'fi', // Finnish
|
|
|
|
'fr', // French
|
2023-06-14 13:27:40 +03:00
|
|
|
'hr', // Croatian
|
2023-05-30 16:31:09 +03:00
|
|
|
'hu', // Hungarian
|
|
|
|
'id', // Indonesian
|
|
|
|
'it', // Italian
|
|
|
|
'ko', // Korean
|
|
|
|
'mn', // Mongolian
|
2023-06-14 13:27:40 +03:00
|
|
|
'ms', // Malay
|
2023-05-30 16:31:09 +03:00
|
|
|
'nl', // Dutch
|
|
|
|
'no', // Norwegian
|
|
|
|
'pl', // Polish
|
|
|
|
'pt', // Portuguese
|
|
|
|
'pt-BR', // Portuguese (Brazil)
|
|
|
|
'ro', // Romanian
|
|
|
|
'ru', // Russian
|
|
|
|
'si', // Sinhala
|
|
|
|
'sl', // Slovenian
|
|
|
|
'sq', // Albanian
|
|
|
|
'sr', // Serbian
|
|
|
|
'sv', // Swedish
|
|
|
|
'tr', // Turkish
|
|
|
|
'uk', // Ukrainian
|
|
|
|
'uz', // Uzbek
|
|
|
|
'vi', // Vietnamese
|
2023-05-31 10:52:42 +03:00
|
|
|
'zh', // Chinese
|
|
|
|
'zh-Hant' // Traditional Chinese
|
2023-03-22 10:50:29 +03:00
|
|
|
];
|
2023-01-18 20:21:36 +03:00
|
|
|
|
2023-03-01 11:10:11 +03:00
|
|
|
/**
|
|
|
|
* @param {string} [lng]
|
2023-05-31 11:37:21 +03:00
|
|
|
* @param {'ghost'|'portal'|'test'|'signup-form'} 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;
|