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 siteurl.com/es-es "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?

Hello,

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. siteurl.com, or No params in URL : it should go to siteurl.com/es-es, and add the following snippet in link-resolver.js:
 if (doc.type == "home_page" && doc.lang==“es-es”) {
   return "/";
 }
  1. siteurl.com/en-us or other than default locale presented as lang in URL:
 if (doc.type == "home_page" && doc.lang!=“es-es”) {
     return `/${doc.lang}`; 
 }
  1. siteurl.com/en-us/UID or have lang and uid params presented in URL:
 if (doc.type == "page" && doc.lang) { 
    return `/${doc.lang}/${doc.uid}`; 
 }
  1. siteurl.com/UID 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,
Priyanka

1 Like

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