aralroca / next-translate

Next.js plugin + i18n API for Next.js 🌍 - Load page translations and use them in an easy way!
MIT License
2.61k stars 208 forks source link

Namespaces are not loaded if .babelrc with plugin(s) are used #514

Closed srigi closed 3 years ago

srigi commented 3 years ago

I'm using superjson together with Babel plugin, so I don't need to transform Dates loaded from DB in getServerSideProps() function:

[package.json]

{
  ...
  "dependencies": {
    "@babel/core": "^7.12.10",
    "babel-plugin-superjson-next": "^0.2.1",
    ...
    "next": "10.0.3",
    "next-translate": "^1.0.2",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "superjson": "~1.6.1",
  },
  ...
}

[.babelrc]

{
  "presets": ["next/babel"],
  "plugins": ["superjson-next"]
}

With this setup the useTranslate() hook cannot find translation namespaces:

[next-translate] "common:title" is missing in current namespace configuration. Try adding "title" to the namespace "common".

I have to opt into usage with the loader:false option. Can this be solved in more pragmatic way?

aralroca commented 3 years ago

@srigi can you confirm if it works for you on 1.0.5-canary.2?

srigi commented 3 years ago

@aralroca It is fixed! But with one caveat - I have to update Next.js too. I have to use 10.0.3 specifically because newer versions fail to build in Azure app-service deployment.

Anyway, I believe, that this issue is resolved (with Next.js 10.0.7) and can be closed.