i18next / i18next-http-backend

i18next-http-backend is a backend layer for i18next using in Node.js, in the browser and for Deno.
MIT License
452 stars 70 forks source link

Initial fetch call on vite serve mode #124

Closed constantineMelios85 closed 1 year ago

constantineMelios85 commented 1 year ago

🐛 Bug Report

I have a react app for years now that I use i18next http backend for my translations. Recently I wanted to move from CRA to vite.

The issue is that on vite serve seems like no call is made from the backend, unless I config a reload interval. After the reload if I trigger a HMR change to my app the translations are shown until an app refresh.

When I build the app and deploy it the backend works as expected.


i18n
  .use(Backend)
  .use(initReactI18next)
  .init({
    react: {
      useSuspense: false,
    },
    debug: false,
    lng: 'en',
    fallbackLng: 'en',
    interpolation: {
      escapeValue: false, // not needed for react as it escapes by default
    },
    backend: {
      loadPath: '../locales/{{lng}}/{{ns}}.json',
      requestOptions: {
        cache: 'no-store',
      },
    },
  });

## Expected behaviour

Backend make the initial fetch call for translations.

## Your Environment

- *runtime version*: node v18.13.0, chromium browser
- *i18next version*: 23.6.0
- *os*: Mac
- *any other relevant information*
adrai commented 1 year ago

Can you please provide a minimal reproducible example. I suspect this is not directly related to i18next.

constantineMelios85 commented 1 year ago

Yes you are right the problem was created cause to an i18next instance coming form another library.