Next.js has the capability to automatically identify the preferred locale of a user based on the Accept-Language
header received in the page request.
In this scenario, even though the default locale is set as sq
, the en
locale gets detected in the Accept-Language
header, leading to redirection to the locale-specific path.
This functionality can be turned off by configuring localeDetection
to false
in your i18n settings.
// next.config.js
module.exports = {
i18n: {
locales: ['sq', 'en'],
defaultLocale: 'sq',
localeDetection: false
}
}
Referencing the documentation on Disabling Automatic Locale Detection:
By setting localeDetection
to false
, Next.js will no longer automatically redirect based on the user's preferred locale and will solely rely on locale information from either the domain or path.
Additionally, regarding the error related to @formatjs/intl
, it implies that the environment/browser used lacks support for the sq
locale. Consider exploring @formatjs/intl-numberformat
to polyfill the necessary locale data.