question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Translations aren't loaded while isFallback = true

See original GitHub issue

Hey!

I noticed an issue that translations aren’t loaded while in the isFallback state.

This is my getStaticPaths for one of the pages:

export const getStaticPaths: GetStaticPaths = async ({ locales }) => {
  const cities = await Api.getCities()
  let paths: Path[] = []

  locales?.forEach((locale) => {
    const localePaths = cities.map((city) => ({
      params: {
        citySlug: city.slug,
      },
      locale,
    }))
    paths = paths.concat(localePaths)
  })

  return {
    paths,
    fallback: true,
  }

getStaticProps:

export const getStaticProps: GetStaticProps<Props, Params> = async ({
  params,
}) => {
  let notFound = false

  if (!params || !params.citySlug) {
    notFound = true
    return {
      notFound,
    }
  }

  const home = await Api.getHome(params.citySlug)
  const city = await Api.getSingleCity(params.citySlug)

  if (!home || !city) {
    notFound = true
  }

  return {
    props: {
      home,
      city,
    },
    notFound,
    revalidate: 60,
  }
}

So when the new props are being fetched (isFallback is true), the translations aren’t loaded. Once isFallback is false, then you can see all the translations. image

image

For now, I’m just setting if (isFallback) return null - so that the screen is white while in fallback, but this is not that user friendly 😦

Do you guys have any ideas on how to fix that?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
berndartmuellercommented, Apr 22, 2021

Digging through the commits since 1.0.5, I was able to pin-point the issue down to https://github.com/vinissimus/next-translate/blob/8abc45855cdc95bed873657379499c758483829a/src/useTranslation.tsx#L11

useMemo() has the wrong dependencies. ctx.t should be listed in the deps instead of ctx.lang.

@aralroca Can you change it and release a hotfix patch version or should I create a PR?

0reactions
richardhsuehcommented, May 11, 2021

But for my page, the required translation is just under common namespace , and i did added '*': ['common'] in 18n.js . Also the translation only missing when go to page directly (paste the link to browser and press enter), if I navigate inside the website and land into the not found page, the translation will display correctly .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Translations aren't loaded while isFallback = true #575 - GitHub
I noticed an issue that translations aren't loaded while in the isFallback state. This is my getStaticPaths for one of the pages: export...
Read more >
NextJS: Failed when fallback set to true - Stack Overflow
Inside your /clip/[player]/[id].js file, you need to handle the fallback state when that page is being requested on-demand.
Read more >
Load balancing across backend servers | Apigee X
When target1 and target2 are unavailable, all traffic is routed to target3 . Path. Path defines a URI fragment that will be appended...
Read more >
Add or Load Translations - i18next documentation
If you want to lazy load some translations via a backend plugin, you may need to use the partialBundledLanguages: true option. This allows...
Read more >
Database Administration Manual - Global Title Translation
or class0, load sharing for all Class 1 SCCP messages is supported only in the dominant mode. If the messages are not in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found