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

POST 404 with saveMissing:true #312

Closed jesspagan closed 5 years ago

jesspagan commented 5 years ago

I am able to get a GET 200 for loadPath but I get a POST 404 when there is a missing key and the missing key does not save. I see a bunch of snippets of config but I am not able to find any complete example of how to implement the save missing key feature correctly.

Here is the i18n config:

import i18next from 'i18next';
import backend from 'i18next-xhr-backend';
import languagedetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';

i18next
  .use(languagedetector)
  .use(backend) // lazy loading resources
  .use(initReactI18next) // passes i18n down to react-i18next
  .init({
    debug: true,
    fallbackLng: 'en-US',
    defaultNS: 'common',
    saveMissing: true,
    interpolation: {
      escapeValue: false, // react already safes from xss
    },
    detection: {
      // order from where user language should be detected
      order: ['navigator'],
    },
    nsSeparator: ':',
    keySeparator: '.',
  });

export default i18next;

Here is a http response:

image

jamuhl commented 5 years ago

You try using saveMissing during development time? using the devserver from webpack? that won't work - that server provides no route to save missing strings...

you need a real server (eg. express)...or use a service like https://locize.com you can directly replace your xhr-backend with the one of the service.

jesspagan commented 5 years ago

thanks