I'm creating multiple item in multiple language in Sitecore using PowerShell Script I'm using 2 script for different different language is this possible in single script. Adding here both script.
First script
$json =ConvertFrom-Json @'
{
"item1": "value in english",
"item2": "value in english"
}
'@
foreach ($array in @($json.psobject.properties)) {
$newItem = New-Item -Path "master:/sitecore/content/Home/blogdetail" -Name $array.Name -ItemType "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"
write-host "$($array.Name) = $($array.Value)"
$newItem.Editing.BeginEdit()
$newItem["text"] = $array.Name
$newItem["title"] = $array.Value
$newItem.Editing.EndEdit()
}
Second script
$folders = Get-ChildItem -Recurse -Path "master:/sitecore/content/Home/blogdetail"
$json =ConvertFrom-Json @'
{
"myitem1": "value in arabic",
"myitem2": "value in arabic"
}
'@
foreach ($path in $folders)
{
#write-host "$($path.Name)"
foreach($jsonitem in @($json.psobject.properties))
{
#write-host "$($path.Name) and $($jsonitem.Name)"
if($path.Name -eq ($jsonitem.Name)){
$newvar= Add-ItemVersion -Item $path -IfExist Append -TargetLanguage "ar-SA"
$newvar.Editing.BeginEdit()
$newvar["text"] = $jsonitem.Name
$newvar["title"] = $jsonitem.Value
$newvar.Editing.EndEdit()
}
}
}
Help me here.