Customising Language prefix in url

Vote:
 

Hi all,

Is there a way to control the language prefix in a globalised site such that '/uk/' is displayed in the url instead of '/en-GB/'?

if so, any help or pointers would be greatly appreciated.

Thank You

#52373
Jul 20, 2011 11:48
Vote:
 

Go in to cms admin, click "Manage Website Languages" under the config tab. Then select your language and define a value for "Web address prefix".

#52375
Jul 20, 2011 13:30
Vote:
 

Hi Linus and thank you for your response.

If I set a uk variant to have the web prefix of 'uk' in Admin mode, is there some way in code to access the web prefix via the framework API instead of url parsing?

Thank You

#52402
Jul 21, 2011 16:39
Vote:
 

This is depending on the place where you need to access the language code. If you have the language branch loaded you should of course get hold of this prefix. The language branch could be loaded from the PageData.LanguageBranch property.

http://sdk.episerver.com/library/cms6.1/html/P_EPiServer_DataAbstraction_LanguageBranch_URLSegment.htm

If you have a link and want to determine the language branch it's a bit more trickier but if your code is running before the friendly URL-parser then you can look for the value of the epslanguage query string parameter. I would assume that this has the id of the language branch that you can use to load it and determine the URL segment for the language branch.

#52458
Jul 27, 2011 17:50
Vote:
 

Hi Linus!

If the page has a fallback language how can we get the web address prefix for the preferred language?

I've found the ContentLanguage.PreferredCulture, but how do I go from there to the prefix?

#61665
Sep 26, 2012 18:21
Vote:
 

I can answer my own question;

LanguageBranch.Load(ContentLanguage.PreferredCulture).CurrentUrlSegment

#61666
Sep 26, 2012 18:26
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.