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

Some i18n configuration options throw warnings in NextJs 12.2.3 #1920

Closed
MonstraG opened this issue Jul 26, 2022 · 8 comments
Closed

Some i18n configuration options throw warnings in NextJs 12.2.3 #1920

MonstraG opened this issue Jul 26, 2022 · 8 comments

Comments

@MonstraG
Copy link

πŸ› 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

@adrai
Copy link
Member

adrai commented Jul 26, 2022

Based on the types here it should extend the options correctly... How does your config look like? I suspect you're defining the options in the i18n property, but you should define them outside: https://github.com/i18next/next-i18next/blob/master/examples/simple/next-i18next.config.js

I'm not a TypeScript user (maybe @pedrodurek can help?)...

@MonstraG
Copy link
Author

Reproducable with
next.config.js:

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

module.exports = {
	i18n
};

next-i18next.config.js:

module.exports = {
	i18n: {
		defaultLocale: "en-GB",
		locales: ["en-GB"],
		keySeparator: "."
	}
};

@adrai
Copy link
Member

adrai commented Jul 26, 2022

Try:

module.exports = {
	i18n: {
		defaultLocale: "en-GB",
		locales: ["en-GB"]
	},
        keySeparator: "."
};

@MonstraG
Copy link
Author

MonstraG commented Jul 26, 2022

Yep, I am defining them inside. Outside doesn't warn, thanks!

@JunlinPan-Crypto
Copy link

JunlinPan-Crypto commented Aug 11, 2022

Still have the warning in Nextjs v12.2.4

warn  - Invalid next.config.js options detected:
The root value has an unexpected property, returnEmptyString (and fallbackLng) which is not in the list of allowed properties
module.exports = {
	i18n: {
		defaultLocale: "en-GB",
		locales: ["en-GB"]
	},
         fallbackLng: 'en',
         returnEmptyString: false,
};

If I put them inside i18n, then similar warning:

warn  - Invalid next.config.js options detected: 
  - The value at .i18n has an unexpected property, fallbackLng, which is not in the list of allowed properties (defaultLocale, domains, localeDetection, locales).
  - The value at .i18n has an unexpected property, returnEmptyString, which is not in the list of allowed properties (defaultLocale, domains, localeDetection, locales).

Where should I put those i18next configs?

@adrai
Copy link
Member

adrai commented Aug 11, 2022

@MonstraG Can you confirm?

@MonstraG
Copy link
Author

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;

@JunlinPan-Crypto
Copy link

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 ❀️

sylvainlg added a commit to refugies-info/karfur that referenced this issue Nov 28, 2022
feat: ⬆️ Upgrade to Next 12.2
Modify i18n configuration : i18next/next-i18next#1920 / https://github.com/i18next/next-i18next#passing-other-config-options
Rename middleware file : https://nextjs.org/docs/messages/middleware-upgrade-guide#how-to-upgrade

fix: πŸ› Fix typing bug => src take only string input

chore: ⬆️ Upgrade i18next version 22

wip

refactor: ⬆️ Run next-image-to-legacy-image codemod

fix: πŸ› Fix middleware.ts folder

fix: ♻️ Fix TS linter error with react-i18next mainly

chore: ⬆️ Upgrade some dependencies

chore: ⬆️ Upgrades dependencies

fix: ♻️ TS types fixes

chore: ⬆️ Upgrades dependencies

fix: βœ… πŸš€
sylvainlg added a commit to refugies-info/karfur that referenced this issue Dec 5, 2022
feat: ⬆️ Upgrade to Next 12.2
Modify i18n configuration : i18next/next-i18next#1920 / https://github.com/i18next/next-i18next#passing-other-config-options
Rename middleware file : https://nextjs.org/docs/messages/middleware-upgrade-guide#how-to-upgrade

fix: πŸ› Fix typing bug => src take only string input

chore: ⬆️ Upgrade i18next version 22

wip

refactor: ⬆️ Run next-image-to-legacy-image codemod

fix: πŸ› Fix middleware.ts folder

fix: ♻️ Fix TS linter error with react-i18next mainly

chore: ⬆️ Upgrade some dependencies

chore: ⬆️ Upgrades dependencies

fix: ♻️ TS types fixes

chore: ⬆️ Upgrades dependencies

fix: βœ… πŸš€
sylvainlg added a commit to refugies-info/karfur that referenced this issue Dec 7, 2022
feat: ⬆️ Upgrade to Next 12.2
Modify i18n configuration : i18next/next-i18next#1920 / https://github.com/i18next/next-i18next#passing-other-config-options
Rename middleware file : https://nextjs.org/docs/messages/middleware-upgrade-guide#how-to-upgrade

fix: πŸ› Fix typing bug => src take only string input

chore: ⬆️ Upgrade i18next version 22

wip

refactor: ⬆️ Run next-image-to-legacy-image codemod

fix: πŸ› Fix middleware.ts folder

fix: ♻️ Fix TS linter error with react-i18next mainly

chore: ⬆️ Upgrade some dependencies

chore: ⬆️ Upgrades dependencies

fix: ♻️ TS types fixes

chore: ⬆️ Upgrades dependencies

fix: βœ… πŸš€
sylvainlg added a commit to refugies-info/karfur that referenced this issue Dec 7, 2022
Integration of https://github.com/dataesr/react-dsfr for header and footer

 ⬆️ Update NextJS 12 => 13 (React 18)
 βž• Install dsfr for React
 Numerous dependencies upgrades
 πŸ’„ Change global font for Marianne
 πŸ› Prevent NPE when themes are not loaded
 ✨ Creation of the header in DSFR format
 ✨ Creation of the footer in DSFR format
 ✨ Creation of the backend header in DSFR format
 🌍 Add translations
 πŸ§ͺ Update tests
Impacts :

Image import => using legacy mode
Linter : most of modified files are linted by prettier
reacti18n : rewrites to Typescript => typings adapations
links : use legacyBehavior on every pre-existing <Link> (to be processed later)
SubscribeNewsletterModal rewrites to use redux for is state (show / hide)

----

* feat: ⬆️ Upgrade Next

feat: ⬆️ Upgrade to Next 12.2
Modify i18n configuration : i18next/next-i18next#1920 / https://github.com/i18next/next-i18next#passing-other-config-options
Rename middleware file : https://nextjs.org/docs/messages/middleware-upgrade-guide#how-to-upgrade

fix: πŸ› Fix typing bug => src take only string input

chore: ⬆️ Upgrade i18next version 22

wip

refactor: ⬆️ Run next-image-to-legacy-image codemod

fix: πŸ› Fix middleware.ts folder

fix: ♻️ Fix TS linter error with react-i18next mainly

chore: ⬆️ Upgrade some dependencies

chore: ⬆️ Upgrades dependencies

fix: ♻️ TS types fixes

chore: ⬆️ Upgrades dependencies

fix: βœ… πŸš€

* chore: βž• Install dsfr for React

* feat: πŸ’„ Change global font for Marianne

* fix: πŸ› Prevent NPE when themes are not loaded

* feat: ✨ Creation of the header in DSFR format

* feat: ✨ Creation of the Footer & Backend Header in DSFR format

Many other adjustment after technical upgrades and UI updates

* fix: 🚸 The translation menu is visible even if the screen is small

* fix: πŸ’„ Fix footer copyright label size
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

3 participants