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.

Some i18n configuration options throw warnings in NextJs 12.2.3

See original GitHub issue

🐛 Bug Report

Warning example:

warn  - Invalid next.config.js options detected: 
[
  {
    "instancePath": "/i18n",
    "schemaPath": "#/properties/i18n/additionalProperties",
    "keyword": "additionalProperties",
    "params": {
      "additionalProperty": "fallbackLng"
    },
    "message": "must NOT have additional properties"
  },
  ...
]

For me this happens with fallbackLng, keySeparator, nsSeparator, localePath, reloadOnPrerender, but I’m assuming it would happen with each property that is not mentioned in I18NConfig, which is

export interface I18NConfig {
    defaultLocale: string;
    domains?: DomainLocale[];
    localeDetection?: false;
    locales: string[];
}

To Reproduce

Update to nextjs 12.2.3, add one of the mentioned properties to i18n section and run build.

Expected behavior

No warnings.

Your Environment

"next": "^12.2.3",
"next-i18next": "^11.3.0",
...
"i18next@npm:^21.8.13":
  version: 21.8.14
  
windows

Folks from nextjs said that the issue is on this end

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
JunlinPan-Cryptocommented, Aug 11, 2022

Sorry, it was my mistake that I passed all i18next configs to Next . I missed the instruction https://github.com/i18next/next-i18next#passing-other-config-options that only need to import i18n object for Next config.

Thank you for the reminder ❤️

0reactions
MonstraGcommented, Aug 11, 2022

No, for me everything is ok.

next-i18next.config.js:

const path = require("path");
const languages = require("./i18n.languages.js");

/** @type import("next").I18NConfig */
const i18n = {
	defaultLocale: process.env.DEFAULT_LANGUAGE,
	locales: languages,
	localeDetection: false // disable automatic redirection on the user's preferred locale
};

/** @type import("next-i18next").UserConfig */
const next18nextConfig = {
	i18n,
	fallbackLng: process.env.NEXT_PUBLIC_FALLBACK_LANGUAGE,
	keySeparator: ".",
	nsSeparator: ":",
	localePath: path.resolve("./public/static/locales"),
	reloadOnPrerender: process.env.NODE_ENV === "development"
};

module.exports = next18nextConfig;

next.config.js:

const { i18n } = require("./next-i18next.config");

/** @type import("next").NextConfig */
const config = {
	swcMinify: true,
	optimizeFonts: false,
	compiler: {
		emotion: true
	},
	i18n
};

module.exports = config;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting next config warning adding nex-i18n additional property
when using a path resolution to the locale paths NextJS complains about a property warn - Invalid next.config.js options detected: ...
Read more >
Advanced Features: Error Handling - Next.js
This component will be responsible to: Render a fallback UI after an error is thrown; Provide a way to reset the Application's state;...
Read more >
next-i18next - npm
The easiest way to translate your NextJs apps. ... passing translations and configuration options into pages as props with SSG/SSR support.
Read more >
Next.js 12.2 Overview: Middleware, Layouts, and more
Next.js 12.2 introduces stable Middleware and On-Demand ISR, experimental Edge SSR and API Routes, and more.0:00 Intro1:50 Agenda2:30 ...
Read more >
Manual Setup for Next.js - Sentry Documentation
As a result, some of the auto-instrumentation done by @sentry/nextjs doesn't ... build-time configuration options sentry: { // See the sections below for ......
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