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.

The first time you enter the URL page of the specified language, nuxt-i18n triggers HTTP status code 302

See original GitHub issue

Version

nuxt-i18n: ^6.15.4 nuxt: ^2.14.6

Nuxt configuration

mode:

  • universal
  • [] spa

Nuxt-i18n configuration

i18n: {
   locales: [{
		code: 'en',
		iso: 'en-US',
		name: 'English'
	},
	{
		code: 'zh',
		iso: 'zh-ZH',
		name: '中文'
	}
	],
	defaultLocale: 'zh',
	vueI18n: {
		fallbackLocale: 'zh',
		messages: {
			en: Object.assign(langEn, require('./lang/en')),
			zh: Object.assign(langZhCN, require('./lang/zh'))
		}
	}
}

When I enter the page for the first time, I assume that the address I visited is http://localhost:3000/en/demo ; nuxt-i18n It will trigger automatically HTTP status code 302 Get to this page http://localhost:3000/demo ; This page is my default language page; I found that it might be cookie Among them i18n_redirected problem,If i18n_redirected exists, I will be able to access normally. If not, 302 will be triggered

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
RopeHuocommented, Nov 30, 2020

Try enabling onlyOnRoot option in detectBrowserLanguage https://i18n.nuxtjs.org/options-reference#detectbrowserlanguage .

It will become enabled by-default in the future but for now, it’s recommended to set it manually.

This is so cool, it seems to solve my problem perfectly, thank you very much

0reactions
rchlcommented, Nov 30, 2020

Try enabling onlyOnRoot option in detectBrowserLanguage https://i18n.nuxtjs.org/options-reference#detectbrowserlanguage .

It will become enabled by-default in the future but for now, it’s recommended to set it manually.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redirecting to the same page but switched language url ...
You can see I am passing in the locale argument which is the language code that was choosen and we use the $nuxt.$router...
Read more >
How to redirect the index / after setting noPrefixDefaultLocale
Hello, i have problem: i set noPrefixDefaultLocale to false in the description: By default, paths generated for the default language don't ...
Read more >
Options - i18n-module
Here are all the options available when configuring the module and their default values:
Read more >
Language Aware Nuxt.js Routing - Abdelrahman Awad
The problem is if we just exclude the current locale from the localization logic, it prevents us from using URLs with different language...
Read more >
Changelog - Cypress Documentation
Component Testing is now generally available for projects using React, Next.js, Angular, and Vue! Component tests allow you to see and test your...
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