Next-translate: Translation doesn't work with the template typescript-eslint-jest starter of Next.js

Created on 25 Dec 2020  路  3Comments  路  Source: vinissimus/next-translate

Hi! I want to thank you for this awesome library!
I just started a new next.js project with Next.js template for Typescript, ESlint and Jest then I configured next-translate following the documentation and after finished, when I start the app, the texts aren't translated as expected.

Steps to reproduce the behaviour

  1. yarn create next-app --example with-typescript-eslint-jest myNextApp
  2. cd myNextApp
  3. yarn add next-translate
  4. create i18n.json at the root directory with the code below
{
    "locales": ["en", "fr"],
    "defaultLocale": "en",
    "pages": {
      "*": ["common"],
      "/": ["common"]
    }
}
  1. create next-config.js with the code below
const nextTranslate = require('next-translate');

module.exports = nextTranslate();
  1. Create at the project root directory a directory named locales and add inside two subfolders en and fr then create a file named common.json inside each subfolder
  2. Inside common.json, add this code
{
    "welcome": "Welcome"
}
  1. Inside pages/index.tsx, add the code below somewhere
{/* import useTranslation from next-translate/useTranslation */}
{/* const { t } = useTranslation() */}
<h1 className="title">
     {t("common:welcome")}
</h1>

Output

I expect the result to be Welcome but it is common:welcome

System Information

OS: macOS 10.15
Browser: Firefox
The version of Next.js: 10.0.4
The version of Node.js: 10.22.1
Start: yarn dev
bug

All 3 comments

Thanks to report it @tericcabrel The steps you describe seem right, I'll see what's going on 馃憤

@tericcabrel It worked well for me with react 17.

 "dependencies": {
    "next": "latest",
    "next-translate": "1.0.1",
    "react": "17.0.1",
    "react-dom": "17.0.1"
  },

I have to say that there is a typo in the steps, the file next-config.js has to be called next.config.js.

Hope it helps.

Yess! It works for me! Thank you for your help

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OmarZeidan picture OmarZeidan  路  3Comments

dimaip picture dimaip  路  4Comments

giovannipds picture giovannipds  路  4Comments

josephfarina picture josephfarina  路  6Comments

popuguytheparrot picture popuguytheparrot  路  4Comments