i18next / i18next-xhr-backend

[deprecated] can be replaced with i18next-http-backend
https://github.com/i18next/i18next-http-backend
MIT License
253 stars 75 forks source link

How to read from json file #353

Closed uendar closed 4 years ago

uendar commented 4 years ago

I am trying to get my translation from and api endpoint and the code i have is:

i18n

  .use(Backend)
  .use(LanguageDetector)
  .use(initReactI18next)
  .init({
    fallbackLng: 'it-IT',
    debug: false,
    keySeparator:false,

    interpolation: {
      escapeValue: false, 
    },

    react: {
      defaultTransParent: 'div', 
      wait: true,
    },

    request: getTranslations('en')

  });

The function getTransaltions() returns json data. Now my question is what i need other in configuration to make it work and read my translations in code.

for example {t('dashboard.title')}

adrai commented 4 years ago

This module is deprecated, please have a look at i18next-http-backend and this example: https://github.com/i18next/i18next-http-backend/blob/master/example/node/app.js

I think you don't need to define the request option at all...