8

The other day a colleague was asking about the sc_lang query string parameter and how Sitecore knows to use that for the language. The conversation was seeking answers to the following questions:

  • What are all the ways in which Sitecore determines which language to use?
  • What is the order of priority for each method in relation to the other?
  • Is there a way to include other procedures to determine the language?
  • 2
    Hey Michael have you checked this post? community.sitecore.net/technical_blogs/b/sitecorejohn_blog/… – Diego Oct 30 '17 at 13:48
  • Thank you. No I've not seen that article. Does it still hold true for Sitecore 9? – Michael West Oct 30 '17 at 13:50
  • Not sure to be honest. It was valid for previous versions though – Diego Oct 30 '17 at 13:52
  • Nothing in the release notes suggest that this part of the codebase has changed in any way. – jammykam Oct 30 '17 at 13:52
9

I think this is well covered on John West's post which in summary describes what the priority is and how Sitecore handles them:

"The Sitecore layout engine retrieves content from the Sitecore repository in the context language (Sitecore.Context.Language). The default logic to determine the context language is to use the first of these variables that specifies a value:

  1. The sc_lang query string parameter.

    https://www.company.com/about-us/?sc_lang=en

  2. The language prefix in the path in the requested URL.

    https://www.company.com/en/about-us/

  3. The language cookie associated with the context site.

    company#lang

  4. The default language associated with the context logical site.
<site name="company" patch:before="site[@name='website']" 
    virtualFolder="/" physicalFolder="/" 
    rootPath="/sitecore/content/company" language="en" 
    hostName="www.company.com" />
  1. The DefaultLanguage setting specified in web.config.
<setting name="DefaultLanguage" value="en" />

References:

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.