Skip to content

Instantly share code, notes, and snippets.

@RobsonAutomator
Created April 12, 2017 15:25
Show Gist options
  • Save RobsonAutomator/29c248827a8dfdcfdbe64fed609ccbec to your computer and use it in GitHub Desktop.
Save RobsonAutomator/29c248827a8dfdcfdbe64fed609ccbec to your computer and use it in GitHub Desktop.
Simple script to export dictionary domain items
$dialog = Read-Variable -Parameters `
@{ Name = "dictionaryDomain"; Title = "dictionary"; Source="DataSource=/sitecore/content&DatabaseName=master&IncludeTemplatesForDisplay=Dictionary domain" ; Editor="treelist"}, `
@{ Name = "language"; Title = "Language"; Source="DataSource=/sitecore/system/languages" ; Editor="droplist"}, `
@{ Name = "emptyOption"; Value=$true; Title = "Export empty items" ; Editor="bool"} `
-Description "This script will export Dictionary data into file." `
-Width 400 -Height 200 `
-Title "Dictionary Toolbox" `
-OkButtonName "Export" `
-CancelButtonName "Cancel"
if ($dialog -ne "ok")
{
Exit
}
$dictionaryEntries = Get-ChildItem -Recurse -ID $dictionaryDomain.ID -Language $language.Name | Where-Object { $_.TemplateName -eq "Dictionary entry" } | ForEach-Object { return AddPathMember($_) }
$csv = $dictionaryEntries | Select-Object -Property Name,Key,Phrase,ID, Path | ConvertTo-Csv -NoTypeInformation | Out-String
$fileName = CreateFileName($language)
Out-Download -Name $fileName -InputObject $csv | Out-Null
function AddPathMember($item)
{
$path = $item.Paths.Path;
$item | Add-Member -MemberType NoteProperty -Name Path -Value $path;
return $item
}
function CreateFileName($language)
{
$user = Get-User -Identity $me
$date = Get-Date -Format ddMMyyyyHHMMss
$fileName = "dictionary", $language.Name, $user.LocalName, $date -join "_"
return "$fileName.csv"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment