diff --git a/src/Transform/TransformBase.cs b/src/Transform/TransformBase.cs index e1fa9b78..84d778ad 100644 --- a/src/Transform/TransformBase.cs +++ b/src/Transform/TransformBase.cs @@ -55,8 +55,8 @@ protected CommandHelp ConvertCmdletInfo(CommandInfo? commandInfo) } CommandHelp cmdHelp = new(commandInfo.Name, commandInfo.ModuleName, Settings.Locale); - cmdHelp.Metadata = MetadataUtils.GetCommandHelpBaseMetadataFromCommandInfo(commandInfo); - cmdHelp.ExternalHelpFile = cmdHelp.Metadata["external help file"].ToString() ?? string.Empty; + cmdHelp.Metadata = MetadataUtils.GetCommandHelpBaseMetadata(cmdHelp); + cmdHelp.ExternalHelpFile = cmdHelp.Metadata["external help file"] as string ?? string.Empty; cmdHelp.OnlineVersionUrl = Settings.OnlineVersionUrl ?? cmdHelp.Metadata["HelpUri"] as string; cmdHelp.SchemaVersion = cmdHelp.Metadata["PlatyPS schema version"] as string ?? string.Empty; cmdHelp.Synopsis = GetSynopsis(helpItem, addDefaultStrings); diff --git a/test/Pester/NewMarkdownHelp.Tests.ps1 b/test/Pester/NewMarkdownHelp.Tests.ps1 index cf5bb195..0fcff0bd 100644 --- a/test/Pester/NewMarkdownHelp.Tests.ps1 +++ b/test/Pester/NewMarkdownHelp.Tests.ps1 @@ -657,4 +657,31 @@ Write-Host 'Hello World!' $file | Should -FileContentMatch 'Runs the command in a mode that only reports what would happen without performing the actions.' } } + + Context 'Locale parameter' { + BeforeAll { + function global:Test-Locale { + [CmdletBinding()] + param() + } + } + + It 'No Locale parameter' { + $file = New-MarkdownCommandHelp -Command (Get-Command 'Test-Locale') -OutputFolder "$TestDrive/NewMarkdownHelp" -Force + + Get-Content -Path $file -First 10 | Where-Object { $_ -match "^Locale" } | Should -Be "Locale: en-US" + } + + It 'Invariant Locale parameter' { + $file = New-MarkdownCommandHelp -Command (Get-Command 'Test-Locale') -OutputFolder "$TestDrive/NewMarkdownHelp" -Force -Locale C + + Get-Content -Path $file -First 10 | Where-Object { $_ -match "^Locale" } | Should -Be "Locale: en-US" + } + + It 'ja-JP Locale parameter' { + $file = New-MarkdownCommandHelp -Command (Get-Command 'Test-Locale') -OutputFolder "$TestDrive/NewMarkdownHelp" -Force -Locale ja-JP + + Get-Content -Path $file -First 10 | Where-Object { $_ -match "^Locale" } | Should -Be "Locale: ja-JP" + } + } }