How to use the i18next.isInitialized function in i18next

To help you get started, we’ve selected a few i18next examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeit / next.js / examples / with-react-i18next / i18n.js View on Github external
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] || {}
    })
  })
github sandiz / rs-manager / src / app-config / i18next.config.client.js View on Github external
//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;
github MyBitFoundation / MyBit-Go.website / i18n.js View on Github external
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] || {}
    })
  })
github i18next / react-i18next / example / v9.x.x / razzle-ssr / src / i18n.js View on Github external
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;
github revskill10 / next-template / packages / lib / i18n.js View on Github external
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] || {}
    })
  })
github appium / appium-desktop / app / configs / i18next.config.renderer.js View on Github external
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;
github mercari / mtc2018-web / web / i18n.js View on Github external
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] || {}
    })
github appium / appium-desktop / app / configs / i18next.config.js View on Github external
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;
github vergecurrency / vergecurrency.com / i18n.js View on Github external
return value;
    },
  },

  react: {
    wait: false,
  },
};

if (process.browser) {
  i18n.use(LanguageDetector);
}

i18n.use(reactI18nextModule);

if (!i18n.isInitialized) i18n.init(options);

module.exports = i18n;
github eclipse / codewind / src / pfe / file-watcher / server / src / utils / locale.ts View on Github external
}, (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);
        });
    });