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.

in ssr when then namespace not exist in the selected resource/language this is false and render return null

See original GitHub issue

Describe the bug In ssr when then namespace not exist in the selected resource/language this is false and set ready in false.

const ready = !!language && namespaces.every(ns => props.i18n.hasResourceBundle(language, ns));

later when we want make render of the component, this line return null https://github.com/i18next/react-i18next/blob/11e23a4c482a3449ca1e664eedd745975957e3d6/src/NamespacesConsumer.js#L165

Occurs in react-i18next version I’m using “next-i18next”: “^0.31.0” who require “react-i18next@^9.0.4”.

my config is:

{
  defaultLanguage: 'en',
  otherLanguages: ['en-US', 'es-ES'],
  ignoreRoutes: [
    '/_next',
    '/static',
    '/reload',
    '/uploads',
    '/assets',
    'favicon.ico',
  ],
  detection: {
    order: ['locale'],
  },
  customDetectors: [
    {
      name: 'locale',
      lookup: (req, res, options) => {
        const { locale } = res.locals; //locale set "es-ES" or "en-US" based on the domain.
        return locale;
      }
    }
  ],
  fallbackLng: ['en'],
  debug: (process.env.DEBUG && process.env.DEBUG.indexOf('i18n') >= 0),
  saveMissing: (process.env.DEBUG && process.env.DEBUG.indexOf('i18n') >= 0),
  saveMissingTo: 'current',
}

To Reproduce

  1. start a new next project with nexti18next.
  2. configure your application to change your language on send one or other url
  3. run your app to start with language one.
  4. see how you have a nice ssr version of your page
  5. change the url to load the other language.
  6. ssr not happen.

Expected behaviour

  1. hasResourceBundle https://github.com/i18next/i18next/blob/master/i18next.js#L602 should return true when some namespace exist in the required language or the fallback language.
  2. this line should return true https://github.com/i18next/react-i18next/blob/v9.x.x/src/NamespacesConsumer.js#L49 if the previus condition is true
  3. translated component should be render in the server.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
nathanredblurcommented, Apr 9, 2019

thanks for your help, meanwhile I will create the empty namespaces files to not break the render.

0reactions
jamuhlcommented, Apr 4, 2019

the community over at next-i18next is large…i’m rather sure they will help you finding the cause.

But like said…while this seems like a problem…it’s not - in production you do not use saveMissing and es-ES and en-US are fully translated

Read more comments on GitHub >

github_iconTop Results From Across the Web

type resources does not exist in namespace error
Open the project properties (right click > properties) · Click the Resources section · In the Add Resource drop down select Add Existing...
Read more >
next-i18next - npm
The easiest way to translate your NextJs apps.. Latest version: 13.0.2, last published: 14 days ago. Start using next-i18next in your ...
Read more >
Taking the new Chromium WebView2 Control for a Spin in .NET
This is Part 1 of a two part article that gives an overview of the new WebView2 Web browser control that is based...
Read more >
Web on Servlet Stack - Spring
When it returns false, the DispatcherServlet assumes the interceptor itself has taken care of requests (and, for example, rendered an appropriate view) and...
Read more >
Server Rendering with React and React Router - ui.dev
There was no dynamic content, and there definitely wasn't any JavaScript. Just pages and links. Not long after that, someone had the great...
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