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

[8.0.0-beta.4] fallbackLng is ignored #953

Closed
romaincointepas opened this issue Feb 20, 2021 · 6 comments
Closed

[8.0.0-beta.4] fallbackLng is ignored #953

romaincointepas opened this issue Feb 20, 2021 · 6 comments

Comments

@romaincointepas
Copy link

Describe the bug

dev is still used as a fallbackLng (missing string for a locale) even when setting fallbackLng: 'en'

Occurs in next-i18next version

8.0.0-beta.4

Steps to reproduce

Setting fallbackLng: 'en' in next-i18next.config.js.

Expected behaviour

Should use en as fallback language when a string is missing for a locale.

@isaachinman
Copy link
Contributor

I cannot reproduce. If I checkout the next-v10 branch, and add next-i18next.config.js:

module.exports = {
  fallbackLng: 'en'
}

It works as expected. Please provide repro steps. Thanks!

@njarraud
Copy link

njarraud commented Feb 23, 2021

I am having the same problem. In serverSideTranslations, only the store for initialLocale is populated and not for the fallback language.

namespacesRequired.forEach((ns) => {
    initialI18nStore[initialLocale][ns] = (
      (i18n.services.resourceStore.data[initialLocale] || {})[ns] || {}
    )
  })

@isaachinman
Copy link
Contributor

I'll need someone to provide a reproducible repository.

@dmeents
Copy link

dmeents commented Feb 23, 2021

I've been struggling with this since migrating over to the beta branch a few weeks ago (#869 (comment)). I have tried a few times to identify why, and fix it myself, but without any success.

I put together this minimum reproduction real quick that is also failing to load fallbackLngs. Hope it helps! https://github.com/dmeents/fallback-ignored-example

@isaachinman
Copy link
Contributor

Thanks for the repro, @dmeents. This is indeed a genuine bug, and I will fix it immediately.

@isaachinman
Copy link
Contributor

A couple things to note:

  1. I've re-added the functionality from current next-i18next to automatically set fallbackLng if the user doesn't pass a value, or false (to disable)
  2. i18next technically supports fallbackLng as an array. I haven't written support for this yet, but would accept a PR from any user who desires this functionality

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

No branches or pull requests

4 participants