Try our conversational search powered by Generative AI!

Getting a language specific URL for a page?

Vote:
 

I have a problem getting the language specific URLs for pages in EPiServer.

The background: I have developed a site with several enabled languages. EPiServerFramework.config is set up so that www.[client].se maps to the Swedish versions of the pages, www.[client].com to English, www.[client].es to Spanish, etc.

This works very well, and the pages doesn't have the /language/ URL prefix.

On the pages there is a possibility to click on links on the page to change to other language versions of the page (generated server-side).

My problem is - is there an easy way to generate these links, and automatically get them to point to the corrent domain name?

Right now I'm building the links with UriSupport.AddLanguageSelection(...), but that results in links such as /sv/blabla/ and /en/yadayada/, i.e. not including the domain, and each URL is prefixed with the language code.

While I realize it's easy to loop through EPiServerFrameworkSection.Instance.SiteHostMapping and do everything manually, I'd really like a more elegant (and automated) solution to this.

Does anyone have any experience of doing this?

Regards,

/Patrik

#45475
Nov 08, 2010 16:53
Vote:
 
 UrlBuilder url = new UrlBuilder(EPiServer.Configuration.Settings.Instance.SiteUrl + linkUrl);
EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, page.PageLink, UTF8Encoding.UTF8);

    

Will give the right url, but you need to provide the SiteUrl

#45480
Nov 08, 2010 19:40
Vote:
 

Good idea, although it still includes the language URL prefix.

I ended up writing my own utility method for building the corresponding URL.

#45501
Nov 09, 2010 15:36
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.