Skip to content

Commit 850f911

Browse files
Adding localization test
1 parent 17601fd commit 850f911

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

PSModuleDevelopment/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- New: Export-PSMDString - Parses strings from modules using the PSFramework localization feature.
44
- Upd: Template PSFProject - Adding `-IncludAZ` switch parameter to `vsts-packageFunction.ps1`, making the template include the AZ module as managed dependency.
55
- Upd: Refactored module structure to comply with current Fred Reference Architecture
6+
- Upd: Template PSFTests - Added localization string tests
67
- Fix: Template PSFProject - Publish Folder created during build is created using `-Force`
78
- Fix: Template PSFProject - Cleaning up Azure Function conversion
89
- Fix: Template PSFTests - Encoding test no longer fails on core (#104)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
$exceptions = @{ }
2+
3+
<#
4+
A list of entries that MAY be in the language files, without causing the tests to fail.
5+
This is commonly used in modules that generate localized messages straight from C#.
6+
Specify the full key as it is written in the language files, do not prepend the modulename,
7+
as you would have to in C# code.
8+
9+
Example:
10+
$exceptions['LegalSurplus'] = @(
11+
'Exception.Streams.FailedCreate'
12+
'Exception.Streams.FailedDispose'
13+
)
14+
#>
15+
$exceptions['LegalSurplus'] = @(
16+
17+
)
18+
19+
$exceptions
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<#
2+
.DESCRIPTION
3+
This test verifies, that all strings that have been used,
4+
are listed in the language files and thus have a message being displayed.
5+
6+
It also checks, whether the language files have orphaned entries that need cleaning up.
7+
#>
8+
9+
$moduleRoot = (Get-Module þnameþ).ModuleBase
10+
$stringsResults = Export-PSMDString -ModuleRoot $moduleRoot
11+
$exceptions = & "$PSScriptRoot\strings.Exceptions.ps1"
12+
13+
Describe "Testing localization strings" {
14+
foreach ($stringEntry in $stringsResults) {
15+
It "Should be used & have text: $($stringEntry.String)" {
16+
if ($exceptions.LegalSurplus -notcontains $stringEntry.String) {
17+
$stringEntry.Surplus | Should -BeFalse
18+
}
19+
$stringEntry.Text | Should -Not -BeNullOrEmpty
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)