Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (format === 'uppercase') return value.toUpperCase()
return value
}
}
}
// for browser use xhr backend to load translations and browser lng detector
if (process.browser) {
i18n
.use(XHR)
// .use(Cache)
.use(LanguageDetector)
}
// initialize if not already initialized
if (!i18n.isInitialized) i18n.init(options)
// a simple helper to getInitialProps passed on loaded i18n data
i18n.getInitialProps = (req, namespaces) => {
if (!namespaces) namespaces = i18n.options.defaultNS
if (typeof namespaces === 'string') namespaces = [namespaces]
req.i18n.toJSON = () => {} // do not serialize i18next instance to prevent circular references on the client
const initialI18nStore = {}
req.i18n.languages.forEach((l) => {
initialI18nStore[l] = {}
namespaces.forEach((ns) => {
initialI18nStore[l][ns] = (req.i18n.services.resourceStore.data[l] || {})[ns] || {}
})
})
//debug: true,
saveMissing: false,
lng: 'en',
fallbackLng: 'en',
whitelist: languages,
react: {
wait: false,
},
namespace: 'translation',
};
i18n
.use(reactI18nextModule)
// initialize if not already initialized
if (!i18n.isInitialized) {
i18n
.init(i18nextOptions);
}
module.exports = i18n;
if (format === 'uppercase') return value.toUpperCase()
return value
}
}
}
// for browser use xhr backend to load translations and browser lng detector
if (process.browser) {
i18n
.use(XHR)
// .use(Cache)
.use(LanguageDetector)
}
// initialize if not already initialized
if (!i18n.isInitialized) i18n.init(options)
// a simple helper to getInitialProps passed on loaded i18n data
i18n.getInitialProps = (req, namespaces) => {
if (!namespaces) namespaces = i18n.options.defaultNS
if (typeof namespaces === 'string') namespaces = [namespaces]
req.i18n.toJSON = () => null // do not serialize i18next instance and send to client
const initialI18nStore = {}
req.i18n.languages.forEach(l => {
initialI18nStore[l] = {}
namespaces.forEach(ns => {
initialI18nStore[l][ns] =
(req.i18n.services.resourceStore.data[l] || {})[ns] || {}
})
})
return value;
},
},
wait: process && !process.release,
};
// for browser use xhr backend to load translations and browser lng detector
if (process && !process.release) {
i18n
.use(XHR)
// .use(Cache)
.use(LanguageDetector);
}
// initialize if not already initialized
if (!i18n.isInitialized) i18n.init(options);
module.exports = i18n;
if (format === 'uppercase') return value.toUpperCase()
return value
}
}
}
// for browser use xhr backend to load translations and browser lng detector
if (process.browser) {
i18n
.use(XHR)
// .use(Cache)
.use(LanguageDetector)
}
// initialize if not already initialized
if (!i18n.isInitialized) i18n.init(options)
// a simple helper to getInitialProps passed on loaded i18n data
i18n.getInitialProps = (req, namespaces) => {
if (!namespaces) namespaces = i18n.options.defaultNS
if (typeof namespaces === 'string') namespaces = [namespaces]
req.i18n.toJSON = () => {} // do not serialize i18next instance to prevent circular references on the client
const initialI18nStore = {}
req.i18n.languages.forEach((l) => {
initialI18nStore[l] = {}
namespaces.forEach((ns) => {
initialI18nStore[l][ns] = (req.i18n.services.resourceStore.data[l] || {})[ns] || {}
})
})
jsonIndent: 2,
},
// debug: true,
// saveMissing: true,
interpolation: {
escapeValue: false
},
lng: settings && settings.getSync('PREFERRED_LANGUAGE', 'en') || 'en',
fallbackLng: config.fallbackLng,
whitelist: config.languages,
react: {
wait: false
}
};
if (!i18n.isInitialized) {
i18n
.use(initReactI18next)
.use(i18nextBackend)
.init(i18nextOptions);
}
export default i18n;
if (format === 'uppercase') { return value.toUpperCase() }
return value
}
}
}
// for browser use xhr backend to load translations and browser lng detector
if (process.browser) {
i18n
.use(XHR)
// .use(Cache)
.use(LanguageDetector)
}
// initialize if not already initialized
if (!i18n.isInitialized) {
i18n.init(options)
}
// a simple helper to getInitialProps passed on loaded i18n data
i18n.getInitialProps = (req, namespaces) => {
if (!namespaces) { namespaces = i18n.options.defaultNS }
if (typeof namespaces === 'string') { namespaces = [namespaces] }
req.i18n.toJSON = () => null // do not serialize i18next instance and send to client
const initialI18nStore = {}
req.i18n.languages.forEach((l) => {
initialI18nStore[l] = {}
namespaces.forEach((ns) => {
initialI18nStore[l][ns] = (req.i18n.services.resourceStore.data[l] || {})[ns] || {}
})
jsonIndent: 2,
},
// debug: true,
// saveMissing: true,
interpolation: {
escapeValue: false
},
lng: settings && settings.getSync('PREFERRED_LANGUAGE', 'en') || 'en',
fallbackLng: config.fallbackLng,
whitelist: config.languages,
react: {
wait: false
}
};
if (!i18n.isInitialized) {
i18n
.use(i18nextBackend)
.init(i18nextOptions);
}
export default i18n;
return value;
},
},
react: {
wait: false,
},
};
if (process.browser) {
i18n.use(LanguageDetector);
}
i18n.use(reactI18nextModule);
if (!i18n.isInitialized) i18n.init(options);
module.exports = i18n;
}, (err, t) => {
if (err) {
logger.logError("Error initializing File-watcher NLS Instance: " + err);
isNLSInitialized = false;
reject(err);
return;
}
logger.logTrace("locale.initNLSInstance() translation test: " + t("buildscripts.buildImage"));
logger.logTrace("locale.initNLSInstance(): " + t("filewatcherUtil.fwNLSInitSuccess"));
logger.logTrace("locale.initNLSInstance() isInitialized: " + i18next.isInitialized);
if (i18next.isInitialized) {
isNLSInitialized = true;
}
logger.logTrace("locale.initNLSInstance() Initialized File-watcher NLS Instance to: " + i18next.language);
i18TransFn = t;
resolve(t);
});
});