Ghost/ghost/i18n/lib/i18n.js
Daniel Lockyer 2cf161168b
Added yarn translate:portal command
refs https://github.com/TryGhost/Ghost/issues/15502

- the amazing `i18next-parser` dependency will extract our translated
  strings from Portal and dump them into locale files, so we never have
  to add them manually
2023-01-18 18:23:53 +01:00

34 lines
729 B
JavaScript

const i18next = require('i18next');
const RESOURCES = {
en: {
translation: require('../locales/en.json')
},
nl: {
translation: require('../locales/nl.json')
}
};
const SUPPORTED_LOCALES = Object.keys(RESOURCES);
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,
// do not load a fallback
fallbackLng: false,
resources: RESOURCES
});
return i18nextInstance;
};
module.exports.SUPPORTED_LOCALES = SUPPORTED_LOCALES;