You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It 'Should use the localized string key <LocalizedKey> from the localization resource file'-TestCases $testCases_LocalizedKeys-Skip:$skipTest_LocalizedKeys {
1391
+
param
1392
+
(
1393
+
[Parameter()]
1394
+
[System.String]
1395
+
$LocalizedKey
1396
+
)
1397
+
1398
+
$usedLocalizationKeys| Should -Contain $LocalizedKey-Because 'the key exists in the localized string resource file so it should also exist in the code'
1399
+
}
1400
+
1401
+
# If there are no test cases built, skip this test.
It 'Should not be missing the localized string key <LocalizedKey> from the localization resource file'-TestCases $testCases_UsedLocalizedKeys-Skip:$skipTest_UsedLocalizedKeys {
1405
+
param
1406
+
(
1407
+
[Parameter()]
1408
+
[System.String]
1409
+
$LocalizedKey
1410
+
)
1411
+
1412
+
$englishLocalizedStrings.Keys| Should -Contain $LocalizedKey-Because 'the key is used in the resource/module script file so it should also exist in the localized string resource files'
1413
+
}
1414
+
}
1415
+
}
1416
+
}
1417
+
1418
+
Context 'When a resource or module is localized to other languages' {
# Only run these tests if there are test cases to be tested.
1445
+
$skipTests=-not$otherLanguagesToTest
1446
+
1447
+
It 'Should have a localization string resource file for the resource/module <Folder> and localization folder <LocalizationFolder>'-TestCases $otherLanguagesToTest-Skip:$skipTests {
Test-Path-Path $localizationResourceFilePath| Should -BeTrue -Because ('there must exist a string resource file in the localization folder {0}'-f$LocalizationFolder)
1466
+
}
1467
+
1468
+
It 'Should have a localization folder with the correct casing for the resource/module <Folder> and localization folder <LocalizationFolder>'-TestCases $otherLanguagesToTest-Skip:$skipTests {
It "Should have the english localization string key <LocalizedKey> in the localization resource file '<LocalizationFolder>\<Folder>.strings.psd1' for the resource/module <Folder>"-TestCases $testCases_CompareAgainstEnglishLocalizedKeys {
1527
+
param
1528
+
(
1529
+
[Parameter()]
1530
+
[System.String]
1531
+
$LocalizedKey,
1532
+
1533
+
[Parameter()]
1534
+
[System.String]
1535
+
$Folder,
1536
+
1537
+
[Parameter()]
1538
+
[System.String]
1539
+
$LocalizationFolder
1540
+
)
1541
+
1542
+
$localizedStrings.Keys| Should -Contain $LocalizedKey-Because 'the key exists in the en-US localization resource file so the key should also exist in this language file'
1543
+
} -ErrorVariable itBlockError
1544
+
1545
+
<#
1546
+
If the It-block did not pass the test, output the a text
1547
+
explaining how to resolve the issue.
1548
+
#>
1549
+
if ($itBlockError.Count-ne0)
1550
+
{
1551
+
$message=@"
1552
+
If you cannot translate the english string in the localized file,
1553
+
then please just add the en-US localization string key together
1554
+
with the en-US text string.
1555
+
"@
1556
+
1557
+
Write-Host-BackgroundColor Yellow -ForegroundColor Black -Object $message
1558
+
Write-Host-ForegroundColor White -Object ''
1559
+
}
1560
+
1561
+
It "Should not be missing the localization string key <LocalizedKey> from the english resource file for the resource/module <Folder>"-TestCases $testCases_MissingEnglishLocalizedKeys {
1562
+
param
1563
+
(
1564
+
[Parameter()]
1565
+
[System.String]
1566
+
$LocalizedKey,
1567
+
1568
+
[Parameter()]
1569
+
[System.String]
1570
+
$Folder,
1571
+
1572
+
[Parameter()]
1573
+
[System.String]
1574
+
$LocalizationFolder
1575
+
)
1576
+
1577
+
$englishLocalizedStrings.Keys| Should -Contain $LocalizedKey-Because ('the key exists in the resource file for the location folder {0} so it should also exist in the en-US string resource file'-f$LocalizationFolder)
0 commit comments