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

Missing Key Error with gatsby-plugin-react-i18next #182

Open
lpieri opened this issue Jan 9, 2024 · 0 comments
Open

Missing Key Error with gatsby-plugin-react-i18next #182

lpieri opened this issue Jan 9, 2024 · 0 comments

Comments

@lpieri
Copy link

lpieri commented Jan 9, 2024

I am encountering an issue with gatsby-plugin-react-i18next where it's not able to locate the translation keys in my JSON files. Despite having the translations defined in my JSON files, I keep getting a missingKey error.

Error Message:

i18next::translator: missingKey fr translation welcome welcome

Relevant Configuration:

Gatsby Config:

// Gatsby Config Excerpt
const config: GatsbyConfig = {
  // ...other configurations...
  plugins: [
    // ...other plugins...
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        name: 'locale',
        path: `${__dirname}/src/locales/`
      },
      __key: "locale"
    },
    {
      resolve: '@herob/gatsby-plugin-react-i18next',
      options: {
        languages: ["fr"],
        fallbackLanguage: "fr",
        trailingSlash: 'never',
        verbose: true,
        i18nextOptions: {
          debug: true,
          interpolation: {
            escapeValue: false,
          },
          keySeparator: false,
          nsSeparator: false,
        },
      }
    }
    // ...other plugins...
  ]
};

Component using the t function:

// React Component Excerpt
const Home: React.FC = () => {
  const { t } = useI18next();
  // ...other component logic...
  return (
    <Box>
      {/* ...other JSX... */}
      {t("welcome")}
      {/* ...other JSX... */}
    </Box>
  );
};

JSON File (locales/fr/index.json):

{
  "welcome": "Welcome on my website",
}

Attempted Solutions:

  • Verified the JSON file path and format.
  • Ensured the correct usage of the t function.
  • Restarted the development server after changes.
  • Checked for typos and syntax errors.

Despite these efforts, the issue persists. Any guidance or assistance in resolving this would be greatly appreciated.

Environment:

Gatsby version: "5.9.1"
gatsby-plugin-react-i18next version: latest

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

1 participant