Can't set localeDetection in the next-i18next.config
See original GitHub issueI hope everything is alright since this is my very first report. I just tried to upgrade my nextjs application. Which worked fine so far. But when I try to build the application I get an error:
🐛 Bug Report
Type error: Argument of type '{ i18n: { locales: string[]; defaultLocale: string; localeDetection: boolean; }; debug: boolean; nonExplicitSupportedLngs: boolean; reloadOnPrerender: boolean; trailingSlash: boolean; }' is not assignable to parameter of type 'UserConfig'.
Types of property 'i18n' are incompatible.
Type '{ locales: string[]; defaultLocale: string; localeDetection: boolean; }' is not assignable to type 'NextJsI18NConfig'.
Object literal may only specify known properties, and 'localeDetection' does not exist in type 'NextJsI18NConfig'.
To Reproduce
the next-i18next.config.js looks like this:
module.exports = {
i18n: {
locales: ['default', 'de', 'en'],
defaultLocale: 'en',
localeDetection: false,
},
debug: process.env.NODE_ENV === 'development',
nonExplicitSupportedLngs: true,
reloadOnPrerender: process.env.NODE_ENV === 'development',
trailingSlash: true,
};
our _app.page.tsx looks like this:
import { appWithTranslation } from 'next-i18next';
import nextI18NextConfig from '../../next-i18next.config.js';
...
export default appWithTranslation(MyApp, nextI18NextConfig);
Expected behaviour
I would expect that the method appWithTranslation/UserConfig accepts the property localeDetection. Since nextjs would accept it by default. I used this approach to always have the language in the URL https://nextjs.org/docs/advanced-features/i18n-routing
Our Environment
node v16.14.0 “next”: “13.0.6”, “next-i18next”: “^13.0.0”, “i18next”: “^22.0.8”, “react-i18next”: “^12.0.0”,
Issue Analytics
- State:
- Created 9 months ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Impossible to use language detection now (?) · Issue #1841
I'm trying to implement language detection based on query string. ... then sets it as lng property of i18next config which disables language...
Read more >next-i18next detect locale with querystring
I want to detect locale from querystring. (www.example.com/detail?lang=en) But it does not work. next-i18next.config.js is already active in ...
Read more >Advanced Features: Internationalized Routing
When localeDetection is set to false Next.js will no longer automatically redirect based on the user's preferred locale and will only provide locale...
Read more >Configuration Options - i18next documentation
Set it to false if your backend loads resources synchronously - that way, calling i18next. t() after init() is possible without relying on...
Read more >A Guide to React Localization with i18next
We'll see how we can load in resources asynchronously, and how to detect the user's language from the browser, a bit later. The...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
changing that to
boolean
would not solve it… The problem is next.js itself is defining it asfalse
here and here … and on the installed next.js version it is included innode_modules/next/dist/next-config-validate.js
as boolean… This means the Vercel team (@Timer) needs to adapt their types first to beboolean
instead offalse
everywhere.Thx for mention, I’m still off a couple of days but I’ll read properly soon and see what we can do.