mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-11-26 07:26:18 +01:00
fix(translations): drop the unreachable RestoreRegistryFailures_one key (#902)
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user