Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// reload languages
i18next.reloadResources(['de', 'fr'])
// reload namespaces for all languages
i18next.reloadResources(null, ['ns1', 'ns2'])
// reload namespaces in languages
i18next.reloadResources(['de', 'fr'], ['ns1', 'ns2'])
// for current language
i18next.dir()
// for another language
i18next.dir('en-US') // -> "ltr";
i18next.dir('ar') // -> "rtl";
// key = 'hello {{what}}'
i18next.t('key', { what: i18next.format('world', 'uppercase') }) // -> hello WORLD
const newInstance = i18next.createInstance(
{
fallbackLng: 'en',
ns: ['file1', 'file2'],
defaultNS: 'file1',
debug: true,
},
(err: any, t: i18next.TranslationFunction) => {
if (err) {
console.log('something went wrong loading', err)
return
}
i18next.reloadResources()
// reload languages
i18next.reloadResources(['de', 'fr'])
// reload namespaces for all languages
i18next.reloadResources(null, ['ns1', 'ns2'])
// reload namespaces in languages
i18next.reloadResources(['de', 'fr'], ['ns1', 'ns2'])
// for current language
i18next.dir()
// for another language
i18next.dir('en-US') // -> "ltr";
i18next.dir('ar') // -> "rtl";
// key = 'hello {{what}}'
i18next.t('key', { what: i18next.format('world', 'uppercase') }) // -> hello WORLD
const newInstance = i18next.createInstance(
{
fallbackLng: 'en',
ns: ['file1', 'file2'],
defaultNS: 'file1',
debug: true,
},
(err: any, t: i18next.TranslationFunction) => {
if (err) {
console.log('something went wrong loading', err)
return
})
// reload all
i18next.reloadResources()
// reload languages
i18next.reloadResources(['de', 'fr'])
// reload namespaces for all languages
i18next.reloadResources(null, ['ns1', 'ns2'])
// reload namespaces in languages
i18next.reloadResources(['de', 'fr'], ['ns1', 'ns2'])
// for current language
i18next.dir()
// for another language
i18next.dir('en-US') // -> "ltr";
i18next.dir('ar') // -> "rtl";
// key = 'hello {{what}}'
i18next.t('key', { what: i18next.format('world', 'uppercase') }) // -> hello WORLD
const newInstance = i18next.createInstance(
{
fallbackLng: 'en',
ns: ['file1', 'file2'],
defaultNS: 'file1',
debug: true,
},
(err: any, t: i18next.TranslationFunction) => {
i18n.on('languageChanged', language => {
if (!languages.hasOwnProperty(language)) {
return
}
console.log(i18n.language)
console.log(i18n.dir(i18n.language))
I18nManager.forceRTL(isRTL())
})
i18n.on('languageChanged', language => {
if (!languages.hasOwnProperty(language)) {
return
}
console.log(i18n.language)
console.log(i18n.dir(i18n.language))
I18nManager.forceRTL(isRTL())
})
const isRTL = () => i18n.dir(i18n.language) === 'rtl'
res.locals.dir = function( lng ) {
return i18next.dir( lng );
};
res.locals.basePath = req.app.get( 'base path' );
const isRTL = () => i18n.dir(i18n.language) === 'rtl'
const isRTL = () => i18n.dir(i18n.language) === 'rtl'
const isRTL = () => i18n.dir(i18n.language) === 'rtl'