fix(translations): drop the unreachable RestoreRegistryFailures_one key (#902)

This commit is contained in:
wang13zhe
2026-11-13 20:49:46 +01:00
committed by GitHub
parent 516fe42d47
commit c465292add
5 changed files with 36 additions and 4 deletions
+36
View File
@@ -95,3 +95,39 @@ Describe 'Shipped language catalogs: <LanguageCode>' -ForEach $languageCases {
}
}
}
Describe 'Plural keys in catalogs for languages without a singular form' {
BeforeAll {
. (Join-Path $PSScriptRoot '..\Scripts\FileIO\Import-LanguageFile.ps1')
$script:LanguagesPath = Join-Path $PSScriptRoot '..\Config\Languages'
# A language needs no '_one' key when Get-PluralCategory cannot return 'one'
# for it. Probe with the counts that CLDR rules actually branch on.
function Get-LanguageNeedsSingular {
param([string]$LanguageCode)
foreach ($count in @(0, 1, 2, 5, 11, 21, 100, 1000000)) {
if ((Get-PluralCategory -LanguageCode $LanguageCode -Count $count) -eq 'one') {
return $true
}
}
return $false
}
}
It 'has no unreachable "_one" keys in <LanguageCode>' -ForEach $languageCases {
if (Get-LanguageNeedsSingular -LanguageCode $LanguageCode) {
Set-ItResult -Skipped -Because "$LanguageCode has a singular category"
return
}
$chromePath = Join-Path $script:LanguagesPath "$LanguageCode/Chrome.json"
$chrome = Get-Content -LiteralPath $chromePath -Raw -Encoding UTF8 | ConvertFrom-Json -ErrorAction Stop
$deadKeys = @($chrome.PSObject.Properties.Name | Where-Object { $_ -like '*_one' })
$keyList = $deadKeys -join ', '
$deadKeys.Count | Should -Be 0 -Because "$LanguageCode never resolves the one category, so these keys are unreachable and only add translation burden: $keyList"
}
}