How to use the i18next.init 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 crimx / ext-saladict / src / _helpers / i18n.ts View on Github external
export function i18nLoader (
  locales: { [namespace: string]: RawLocales },
  defaultNS: string,
  cb?: i18n.Callback
): i18n.i18n {
  const namespaces = Object.keys(locales)
  const instance = i18n
    .init({
      lng: browser.i18n.getUILanguage(),
      fallbackLng: 'en',
      debug: process.env.NODE_ENV === 'development',
      saveMissing: false,
      load: 'currentOnly',

      defaultNS: defaultNS || namespaces[0] || 'translation',

      whitelist: ['en', 'zh-CN', 'zh-TW'],

      interpolation: {
        escapeValue: false, // not needed for react!!
      },

      resources: namespaces.reduce((res, ns) => {
github cheng-kang / wildfire / src / aio.js View on Github external
wf.auth = wf.dbApp.auth()
    wf.authService = firebase.auth.EmailAuthProvider.credential
  }

  wf.b64EncodeUnicode = b64EncodeUnicode
  wf.b64DecodeUnicode = b64DecodeUnicode

  _Vue.prototype.$_wf = wf

  // Dynamically update `pageTitle` & `pageURL`
  _Vue.prototype.$_updateWildfirePageInfo = function ({ pageTitle, pageURL }) {
    if (pageTitle) { this.$_wf.config.pageTitle = pageTitle }
    if (pageURL) { this.$_wf.config.pageURL = b64EncodeUnicode(pageURL) }
  }

  i18next.init({
    lng: locale,
    fallbackLng: 'en',
    debug: true,
    resources: {
      en: {
        translation: langEn
      },
      'zh-CN': {
        translation: langZhCN
      },
      'zh-TW': {
        translation: langZhTW
      }
    }
  }, (err, t) => {
    if (err) {
github IpshitaC / sociable / config / i18n.js View on Github external
module.exports = function(app) {

  i18n.init(i18nOptions, function(err) {
    if (err)
      console.warn('error initializing i18n module');
    else
      console.log('i18n module initialized');
  });

  app.use(i18n.handle);
  i18n.registerAppHelper(app);
};
github openforge / OPENFORGE.IO / src / services / translation.service.ts View on Github external
init(lang) {
    i18next.init(
      {
        lng: lang,
        debug: true,
        resources: {
          en: {
            translation: translations.translation,
          },
        },
      },
      err => {
        if (err) {
          console.error(err);
        }
      }
    );
  }
github d3plus / d3plus-common / src / locale.js View on Github external
import i18next from "i18next";

const namespace = "d3plus";
import enUS from "./locales/en-US/d3plus.json";
import esES from "./locales/es-ES/d3plus.json";

export default i18next.init({
  fallbackLng: "en-US",
  defaultNS: namespace,
  fallbackNS: namespace,
  initImmediate: false,
  ns: namespace,
  resources: {
    "en-US": {[namespace]: enUS},
    "es-ES": {[namespace]: esES}
  }
});
github ProcessMaker / modeler / src / main.js View on Github external
import translations from '@/setup/translations.json';
import * as VueDeepSet from 'vue-deepset';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap-vue/dist/bootstrap-vue.css';

import '@fortawesome/fontawesome-free/css/all.min.css';

Vue.use(BootstrapVue);

Vue.use(VueDeepSet);

Vue.config.productionTip = false;

Vue.use(VueI18Next);

i18next.init({
  lng: 'en',
  resources: { en: { translation: translations } },
});

const i18n = new VueI18Next(i18next);

new Vue({
  render: h => h(ModelerApp),
  i18n,
}).$mount('#modeler-app');
github hupe1980 / gatsby-i18n / packages / gatsby-plugin-i18next / src / setupI18next.js View on Github external
function setupI18next(fallbackLng, i18nextOptions) {
  i18next.init({
    debug: false,
    defaultNS: 'messages',
    fallbackLng,
    react: {
      useSuspense: false,
    },
    ...i18nextOptions,
  });

  return i18next;
}
github LedgerHQ / ledger-live-desktop / src / renderer / i18n / instanciate.js View on Github external
export function createWithResources(resources) {
  i18n.init({
    ...commonConfig,
    ...resources,
  })
  return addPluralRule(i18n)
}
github mirumee / saleor / saleor / static / dashboard-next / i18n.ts View on Github external
import i18n from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import XHR from "i18next-xhr-backend";

i18n.use(XHR);
i18n.use(LanguageDetector);
i18n.init({
  defaultNS: "dashboard",
  fallbackLng: "en",
  interpolation: {
    escapeValue: false
  },
  keySeparator: false,
  ns: ["dashboard"],
  nsSeparator: false
});

export default i18n;