Created
April 12, 2017 15:25
-
-
Save RobsonAutomator/29c248827a8dfdcfdbe64fed609ccbec to your computer and use it in GitHub Desktop.
Simple script to export dictionary domain items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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