Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14.0.5 with custom defaultNS and useSuspense: false does not work with i18next-resources-to-backend #1728

Closed
arechsteiner opened this issue Mar 6, 2024 · 4 comments · Fixed by #1731

Comments

@arechsteiner
Copy link

arechsteiner commented Mar 6, 2024

💥 Regression Report

Keys are not loading on refresh anymore, instead the raw key name is displayed. It seems to be an edge case with our combination of settings (see title and repro-steps).

This applies to the dev environment with vite, I haven't tested it in any production setting.

One curious thing is that when doing any change to the template to trigger a hot module reload, the key starts showing.

Last working version

Worked up to version: 14.0.4

Stopped working in version: 14.0.5

To Reproduce

I've created a repository with the minimal possible setup that shows the issue. It's based on vite / react-ts. I've included a commit that reverts to 14.0.4 where the setup is working fine.

https://github.com/arechsteiner/react-i18next-repro

The main parts are:

  • using resouresToBackend
  • useSuspense: false <- removing this will make it work
  • defaultNS: 'common' <- removing this will also make it work
import i18n from 'i18next'
import { useTranslation, initReactI18next } from 'react-i18next'
import resourcesToBackend from 'i18next-resources-to-backend'
import en from './locales/en/translation.json'

i18n
  .use(
    resourcesToBackend((language, namespace, callback) => {
      console.log('namespace', namespace, language)
      callback(null, en)
    }),
  )
  .use(initReactI18next)
  .init({
    defaultNS: 'common',
    lng: 'en',
    fallbackLng: 'en',
    react: {
      useSuspense: false,
    },
    interpolation: {
      escapeValue: false,
    },
  })

Expected behavior

The key should show it's translation right away as in 14.0.4

Your Environment

  • runtime version: Node v18.14.2, Chrome 122.0.6261.94
  • i18next version: ^23.10.0
  • os: Mac
@adrai
Copy link
Member

adrai commented Mar 6, 2024

this was the only change #1720
@timheilman can you have a look at this?

@timheilman
Copy link
Contributor

sure thing, I'll take a look

@adrai
Copy link
Member

adrai commented Mar 6, 2024

Can you try with v14.0.8 ?

@arechsteiner
Copy link
Author

I've tried with the latest version (v14.1.0) and that seems to work fine so far. Thanks for the quick handling!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants