From 35e205e2d39e8fbdd5a90babb2673686426320a9 Mon Sep 17 00:00:00 2001 From: Dmitry Kirdyashkin Date: Wed, 27 Sep 2023 00:38:33 +0300 Subject: [PATCH] added script --- translate.ps1 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 translate.ps1 diff --git a/translate.ps1 b/translate.ps1 new file mode 100644 index 0000000..3d68480 --- /dev/null +++ b/translate.ps1 @@ -0,0 +1,19 @@ +#replace spell name and description to localized one +$db = "src\packs\sc-spells.db" +$spellList = "C:\Users\dmitr\Documents\Repos\local\modules\sc-spells\src\packs\sc-spells.json" +$localizationFile = "localization\ru.json" + +$null | Set-Content $db +$data = get-content $spellList | ConvertFrom-Json +$localizationData = get-content $localizationFile | ConvertFrom-Json + +foreach ($entry in $data){ + if ($entry.name -in $localizationData.name){ + $localizedEntry = $localizationData | Where-Object -Property name -eq "$($entry.name)" + $entry.name = "$($localizedEntry.localizedName)/$($entry.name)" + $entry.system.description.value = "$($localizedEntry.description)" + } else { + Write-Warning "$($entry.name) is absent in localization file" + } + @($entry) | convertto-json -Depth 32 -Compress >> $db +} \ No newline at end of file