Files
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

36 lines
1.4 KiB
PowerShell

[CmdletBinding()]
param(
[string]$RepositoryRoot,
[string]$EnglishFilePath
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
. (Join-Path $PSScriptRoot 'Languages\TranslationJsonTools.ps1')
. (Join-Path $PSScriptRoot 'Languages\TranslationSourceTools.ps1')
$resolvedRepositoryRoot = Resolve-TranslationSyncRepositoryRoot -RepositoryRoot $RepositoryRoot
$resolvedEnglishFilePath = Resolve-EnglishLanguageFilePath -ResolvedRepositoryRoot $resolvedRepositoryRoot -EnglishFilePath $EnglishFilePath
if (-not (Test-Path -Path $resolvedEnglishFilePath -PathType Leaf)) {
throw "English translation file not found: $resolvedEnglishFilePath"
}
$snapshot = Get-TranslationSourceSnapshot -RepositoryRoot $resolvedRepositoryRoot
$englishTranslations = Read-OrderedJsonMapPermissive -Path $resolvedEnglishFilePath
$extractedKeySet = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::Ordinal)
foreach ($key in $snapshot.KeyOrder) {
[void]$extractedKeySet.Add([string]$key)
}
$unusedKeys = New-Object System.Collections.Generic.List[string]
foreach ($entry in $englishTranslations.GetEnumerator()) {
$key = [string]$entry.Key
if (-not $extractedKeySet.Contains($key)) {
$unusedKeys.Add($key)
Write-Output "Unused key: $key"
}
}
Write-Output "Scan completed. Checked $(@($snapshot.SourceFiles).Count) file(s); found $($unusedKeys.Count) unused key(s)."