Multi-langual paths without lang param

If I have two different locales ("es-es" and "en-us"), but I want the url for the master language "es-es" to not have "es-es" at the end. How would that look like in the asyncData function? I have the same setup as your example on here

In my link-resolver.js I figure you can do something like this:

if (doc.type === "page" && doc.lang !== "es-es") {
    return `/${doc.lang}/${doc.uid}`;

if (doc.type === "page" && doc.lang === "es-es") {
    return `/${doc.uid}`;

Another thing. What's the best way if I want to lose the "-es" and the "-us" in the locale url. Create a custom language with just the "es" and "en" as locale, or something else?


Thanks for reaching out to us.

If I understood your question well. You have 2 questions:

Removal of default locale string ('es-es') from the URL:

Let me assume locale page custom type is “home_page”

  1., or No params in URL : it should go to, and add the following snippet in link-resolver.js:
 if (doc.type == "home_page" && doc.lang==“es-es”) {
   return "/";
  1. or other than default locale presented as lang in URL:
 if (doc.type == "home_page" && doc.lang!=“es-es”) {
     return `/${doc.lang}`; 
  1. or have lang and uid params presented in URL:
 if (doc.type == "page" && doc.lang) { 
    return `/${doc.lang}/${doc.uid}`; 
  1. or should have only one param presented in url: Here in code there will be an issue for understanding lang param as UID because the first param after root url is treated as lang, not as UID. Please see here .

Another question
Removal of ("-es" or "-us") from locale in the URL:
You need to use slice function of javascript to remove character from the url. You will find more detail here.

Let me know if you have any question on that.

Thank you,

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.