When you work with the LinkURL property in the PageData object in EPiServer, the Url will always be set to the current language. If you are working with a multi-language website, however, sometimes you need to create links to different languages dynamically. In order to generate a link to a specific language, you can use one of the following methods:
Manually Adding A Link
Out of the box, Episervers multi-language feature works by appending a language segment into the URL as a query string, so for example for my website, www.jondjones.com/. I would add a language parameter, like so:
The simple way to create a language on a page is to change the /en/ part to the language you care about.
Dynamically Creating a Link For A Page
Ok so the last section is quite a horrible way so let's get onto something that is more flexible.
In the back end, all this really does is appending the language query string as 'sv'. When the page loads, Episerver will read in this value in the route definition and load the correct page accordingly. Besides passing in the culture code you care about, you can also use the page.LanguageID property to get it automatically from the page, so the code above could also be generated like this:
As long as the page instance you are using is the Swedish version.