Generate routes for multilanguage site

Hello there :v:,
These days I play around with nuxt SSR full static and prismic.
I created a demo project, you can see the code here and check-out production at the link.

1. first problem

in my project I have two languages (English and German) and 3 different type of documents:

  • unrepeatable type index document.
  • repeatable type page document. ( about, blog, contact )
  • unrepeatable type blog-post document.

my link.resolver looks like this

export default function (doc) {
	if (doc.type === 'index') {
		if (doc.lang === 'en-us') return '/'
		else return `/${doc.lang}/`
	} else if (doc.type === 'page') {
		return `/${doc.lang}/${doc.uid}`
	} else if (doc.type === 'blog-post') {
		if (doc.lang === 'en-us') return `/post/${doc.uid}`
		else return `/${doc.lang}/post/${doc.uid}`
	}
}

pages

As you can see I want to create my page structure where I will hide the language prefix if it is the main language ( en-us ) , however if i write the condition in the link.resolver for document type page I get error.I guess its the same problem that I found in the forum, however i struggle to implement the validation or perhaps I have a wrong page structure in the pages directory.

2. second problem
for some reason, none of my dynamic pages were generated by Nuxt.
Currently i implemented a hacky way where I render nuxt-links with all alternative languages of each document. I guess I need to use the route resolver but I do not have experience with it.

2. second problem solved
I guess the problem was that some of the packages were not updated to latest.
However i still struggle with first problem.

Hey @martingjorceski, for your first issue. I can recommend you to use i18n-nuxt to enable internationalized routing. The routing setup will allow you to skip the lang code prefix in the default language pages.

Sorry for replaying late, but I would prefer to have solution without i18n-nuxt.
I already have logic for local switcher and routes with prismic so I wanna stick with prismic.

We don't have an example project to showcase how to do this, but if we ever develop a new one, we'll be sure to add it to the Nuxt example project list!

In the meantime, if you're interested in another solution, we do have an example multilanguage site built with Nuxt.js, this one uses the lang code for the master language.

If you're interested in seeing how we built this, check it out here: