Files
devolutions--unigetui/scripts/translation/Merge-TranslationDiffBatches.ps1
wehub-resource-sync 643e9f9fcb
.NET Tests / test-codebase (push) Waiting to run
Translation Validation / validate-translations (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:01:52 +08:00

39 lines
1.2 KiB
PowerShell

[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$BatchDir,
[Parameter(Mandatory = $true)]
[string]$OutputTranslatedPatch
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
. (Join-Path $PSScriptRoot 'Languages\TranslationJsonTools.ps1')
$batchRoot = Get-FullPath -Path $BatchDir
$outputPath = Get-FullPath -Path $OutputTranslatedPatch
$manifestPath = Join-Path $batchRoot 'manifest.json'
if (-not (Test-Path -Path $manifestPath -PathType Leaf)) {
throw "Batch manifest not found: $manifestPath"
}
$manifest = Get-Content -Path $manifestPath -Raw | ConvertFrom-Json
$mergedMap = New-OrderedStringMap
foreach ($batch in @($manifest.batches | Sort-Object batchNumber)) {
$translatedPath = Join-Path $batchRoot ([string]$batch.translated)
if (-not (Test-Path -Path $translatedPath -PathType Leaf)) {
throw "Translated batch file not found: $translatedPath"
}
$translatedMap = Read-OrderedJsonMap -Path $translatedPath
foreach ($entry in $translatedMap.GetEnumerator()) {
$mergedMap[[string]$entry.Key] = [string]$entry.Value
}
}
Write-OrderedJsonMap -Path $outputPath -Map $mergedMap
Write-Output "Merged $($manifest.batchCount) translation batch(es) into $outputPath"