Next-i18next: [8.0.0-beta.4] fallbackLng is ignored

Created on 20 Feb 2021  路  6Comments  路  Source: isaachinman/next-i18next

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.

All 6 comments

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!

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] || {}
    )
  })

I'll need someone to provide a reproducible repository.

I've been struggling with this since migrating over to the beta branch a few weeks ago (https://github.com/isaachinman/next-i18next/issues/869#issuecomment-767923052). 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

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

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
Was this page helpful?
0 / 5 - 0 ratings