I would like to know if there's a way to set the current script's context language through code. I know there's a way to set it in the ISE but I need some code that could override it and force a specific script to always run in a certain language.

Something like this:

$Context.Language = [Sitecore.Data.Managers.LanguageManager]::GetLanguage("nl")

1 Answer 1


You can set context language using


 #get language to be switched
 $lan = [Sitecore.Globalization.Language]::Parse("$switchLanguage")
 #Set Context language, use 'ispersistent' parameter based on your requirement.in my case it should be for a while i.e. creation of master content.
 [Sitecore.Context]::SetLanguage( $lan,$false)

Below is one of the PS script used in one of my project. :)


PS script to switch context lang to en-US from en(default)

Actual Script:

$defaultContextLang = [Sitecore.Context]::Language.Name
Write-Host "Default context language is '$defaultContextLang'"
$switchLanguage = "en-US"
$lan = [Sitecore.Globalization.Language]::Parse("$switchLanguage")
 [Sitecore.Context]::SetLanguage( $lan,$false)
 $switchedContextLang = [Sitecore.Context]::Language.Name
 Write-Host "Switched context language is '$switchedContextLang'"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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