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.

Locales loaded, but missing key for namespace error (for all keys)

See original GitHub issue

I am unable to get any of the translations working – for all {key} and {ns}, get this error:

[next-translate] "{key}" is missing in current namespace configuration. Try adding "{key}" to the namespace "{ns}".

next: ^12.0.8 next-translate: ^1.3.3

i18n.js

modules.export = {
  locales: ['nb', 'nn', 'en'],
  defaultLocale: 'nb',
  loadLocaleFrom: (lang, ns) =>
    import(`./public/locales/${lang}/${ns}.json`).then((m) => m.default),
  pages: {
    '*': ['common', 'header', 'mainMenu'],
    '/': ['welcome'],

  // some more
  }
}

_app.js

import i18nConfg from '../../i18n';

// MyApp

export default appWithI18n(MyApp, i18nConfig);

pages/index.tsx

const Index = () => {
  const { t } = useTranslation('welcome');
  return (
    <div>
      <div>{t('title')}</div>
      <div>{t('welcomeText')}</div>
    </div>
  );
}

export default Index

public/locales/nb/welcome.json:

{
  "title": "Velkommen",
  "welcomeText": "Dette er din hjemmside"
}

Messages: next-translate - compiled page: / - locale: nb - namespaces: common, header, mainMenu, welcome - used loader: getInitialProps

console error: [next-translate] "welcome:title" is missing in current namespace configuration. Try adding "title" to the namespace "welcome". [next-translate] "welcome:welcomeText" is missing in current namespace configuration. Try adding "welcomeText" to the namespace "welcome".

what am I doing wrong ?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
wuifdesigncommented, Feb 21, 2022

having the same problem. if the json file for one of the namespaces is missing all of them will become null.

locales/en/common.json exists locales/en/home.json does not exist

pages: {
    '*': ['common'],
    '/': ['home'],
},

this will end up in:

{"pageProps":{"__lang":"en","__namespaces":{"common":null,"home":null}},"__N_SSG":true}

but instead only home should be null.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Locales loaded, but missing key for namespace error ... - GitHub
I am unable to get any of the translations working -- for all {key} and {ns}, get this error: [next-translate] "{key}" is missing...
Read more >
i18next with namespace does not fetch expected translation file
As you can see, I want to load my translation files over http (which are served by a node server and this works)....
Read more >
i18next - initialization
The current locale to set and looked up in the given cookie parameter. ... If turned on, all missing key/values will be sent...
Read more >
Namespaces - i18next documentation
Namespaces are a feature in i18next internationalization framework which allows you to separate translations that get loaded into multiple files.
Read more >
Authenticate access to Azure Event Hubs with shared access ...
Any client that has access to name of an authorization rule name and one of its signing keys can generate a SAS token....
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