Sitecore PowerShell Extensions
  • Introduction
  • Disclaimer
  • Installation
    • Contributor Guide
  • Training
  • Community
  • Interfaces
    • Console
    • Scripting
    • Interface Configuration
    • Interactive Dialogs
    • Help
  • Working with Items
    • Item Languages
    • Item Renderings
    • Variables
    • Providers
  • Modules
    • Libraries and Scripts
    • Integration Points
      • Content Editor
      • Control Panel
      • Data Sources
      • Event Handlers
      • Functions
      • ISE Plugins
      • Page Editor
      • Pipelines
      • Reports
        • Authoring Reports
      • Tasks
        • Authoring Tasks
      • Toolbox
      • Web API
      • Workflows
    • Packaging
  • Remoting
  • Security
    • Users and Roles
  • Releases
  • Troubleshooting
  • Code Snippets
    • Item Links
    • Field Types
    • Manage Templates
  • Appendix
    • Common
      • Add-BaseTemplate
      • Add-ItemVersion
      • Close-Window
      • ConvertFrom-CliXml
      • ConvertFrom-ItemClone
      • ConvertTo-CliXml
      • Expand-Token
      • Get-Archive
      • Get-ArchiveItem
      • Get-Cache
      • Get-Database
      • Get-ItemClone
      • Get-ItemCloneNotification
      • Get-ItemField
      • Get-ItemReference
      • Get-ItemReferrer
      • Get-ItemTemplate
      • Get-ItemWorkflowEvent
      • Get-SitecoreJob
      • Get-SpeModule
      • Get-SpeModuleFeatureRoot
      • Get-TaskSchedule
      • Get-UserAgent
      • Import-Function
      • Invoke-JavaScript
      • Invoke-Script
      • Invoke-ShellCommand
      • Invoke-Workflow
      • New-ItemClone
      • New-ItemWorkflowEvent
      • New-UsingBlock
      • Out-Download
      • Publish-Item
      • Read-Variable
      • Receive-File
      • Receive-ItemCloneNotification
      • Remove-BaseTemplate
      • Remove-ArchiveItem
      • Remove-ItemVersion
      • Reset-ItemField
      • Restart-Application
      • Restore-ArchiveItem
      • Send-File
      • Send-SheerMessage
      • Set-HostProperty
      • Set-ItemTemplate
      • Show-Alert
      • Show-Application
      • Show-Confirm
      • Show-FieldEditor
      • Show-Input
      • Show-ListView
      • Show-ModalDialog
      • Show-Result
      • Show-YesNoCancel
      • Start-TaskSchedule
      • Test-BaseTemplate
      • Test-Rule
      • Update-ItemReferrer
      • Update-ListView
      • Write-Log
    • Indexing
      • Find-Item
      • Get-SearchIndex
      • Initialize-Item
      • Initialize-SearchIndex
      • Initialize-SearchIndexItem
      • Remove-SearchIndexItem
      • Resume-SearchIndex
      • Stop-SearchIndex
      • Suspend-SearchIndex
    • Packaging
      • Export-Item
      • Export-Package
      • Export-UpdatePackage
      • Get-Package
      • Get-Preset
      • Get-UpdatePackageDiff
      • Import-Item
      • Install-Package
      • Install-UpdatePackage
      • New-ExplicitFileSource
      • New-ExplicitItemSource
      • New-FileSource
      • New-ItemSource
      • New-SecuritySource
      • Import-Item
      • New-Package
    • Presentation
      • Add-PlaceholderSetting
      • Add-Rendering
      • Get-Layout
      • Get-LayoutDevice
      • Get-PlaceholderSetting
      • Get-Rendering
      • Get-RenderingParameter
      • Merge-Layout
      • New-PlaceholderSetting
      • New-Rendering
      • Remove-PlaceholderSetting
      • Remove-Rendering
      • Remove-RenderingParameter
      • Reset-Layout
      • Set-Layout
      • Set-Rendering
      • Set-RenderingParameter
      • Switch-Rendering
    • Provider
      • Get-Item
    • Security
      • Add-ItemAcl
      • Add-RoleMember
      • Clear-ItemAcl
      • Disable-User
      • Enable-User
      • Export-Role
      • Export-User
      • Get-Domain
      • Get-ItemAcl
      • Get-Role
      • Get-RoleMember
      • Get-User
      • Import-Role
      • Import-User
      • Lock-Item
      • Login-User
      • Logout-User
      • New-Domain
      • New-ItemAcl
      • New-Role
      • New-User
      • Protect-Item
      • Remove-Domain
      • Remove-Role
      • Remove-RoleMember
      • Remove-User
      • Set-ItemAcl
      • Set-User
      • Set-UserPassword
      • Test-Account
      • Test-ItemAcl
      • Unlock-Item
      • Unprotect-Item
      • Unlock-User
    • Session
      • Get-ScriptSession
      • Get-Session
      • Receive-ScriptSession
      • Remove-ScriptSession
      • Remove-Session
      • Start-ScriptSession
      • Stop-ScriptSession
      • Wait-ScriptSession
Powered by GitBook
On this page
  • Add Language Version
  • Remove Language Version
  • New Item with Forced Language Version
  • Parameters and Configuration
  • References
Export as PDF
  1. Working with Items

Item Languages

PreviousWorking with ItemsNextItem Renderings

Last updated 2 years ago

The section on provided a variety of examples in retrieving items based on their language. In this section will show how to manage items and their languages.

Add Language Version

Example: The following example queries all of the content items and adds a new language version of "en-ca", while overwriting any that exist.

Get-ChildItem "master:\content" -Recurse | 
    Add-ItemLanguage -Language "en-us" -TargetLanguage "en-ca" -IfExist OverwriteLatest

Example: The following example adds a language version from English to US and Polish while leaving the Title field blank. If a version already exists nothing happens.

$languageParameters = @{
    Path = "master:\content\home"
    Language = "en"
    TargetLanguage = @("pl-pl","en-us")
    IfExist = "Skip"
    IgnoredFields = @("Title")
}
Add-ItemLanguage @languageParameters

Example: The following example adds a language version from English to Polish of Template Name Sample Item. If the version exists a new version is created for that language. Finally the results are displayed as a table showing only the Name, Language, and Version.

Get-ChildItem "master:\content\home" -Language "en" -Recurse |
    Where-Object { $_.TemplateName -eq "Sample Item" } |
    Add-ItemLanguage -TargetLanguage "pl-pl" -IfExist Append |
    Format-Table Name, Language, Version -AutoSize

Example: The following example adds a language version in Polish to the Home item and all its children. If the version exists nothing happens. No fields were harmed in the making of this version.

Add-ItemLanguage -Path "master:\content\home" -TargetLanguage "pl-pl" -IfExist Skip -DoNotCopyFields -Recurse

Remove Language Version

Example: The following example queries all of the content items and removes the language version of "fr-CA".

Get-ChildItem "master:\content" -Recurse | 
    Remove-ItemLanguage -Language "fr-CA"

New Item with Forced Language Version

Example: The following example creates a new item with language versions only matching the specified languages; all other language version are removed.

$itemPath = "master:\content\home\sample item\Sample Item 3"
New-Item -Path $itemPath -ItemType "Sample/Sample Item" -Language "en-CA"

Name          Children Language Version Id                                     TemplateName
----          -------- -------- ------- --                                     ------------
Sample Item 3 False    en-CA    1       {C9517583-3AF9-4AFB-B247-BB0A09F55D94} Sample Item

Parameters and Configuration

Supported parameters:

  • -Recurse Translates item and its children

  • -IfExist Accepts one of 3 pretty self explanatory actions: Skip, Append or OverwriteLatest

  • -TargetLanguage accepts a list of languages that should be created

  • -DoNotCopyFields creates a new version but does not copy field values from original language

  • -IgnoredFields list of fields that should not be copied over from original item this can contain e.g. __Security if you don't want the new version to have the same restrictions as the original version.

On top of the ignored fields in the -IgnoredFields the following fields are ignored as configured within the Spe.config file:

<configuration xmlns:patch="https://www.sitecore.net/xmlconfig/">
  <sitecore>
    <powershell>
      <translation>
        <ignoredFields>
          <field>__Archive date</field>
          <field>__Archive Version date</field>
          <field>__Lock</field>
          <field>__Owner</field>
          <field>__Page Level Test Set Definition</field>
          <field>__Reminder date</field>
          <field>__Reminder recipients</field>
          <field>__Reminder text</field>
          <!--field>__Security</field-->
        </ignoredFields>
      </translation>
  </sitecore>
</configuration>

References

working with items
Issue 184
Remove All Content items in French