platyPS icon indicating copy to clipboard operation
platyPS copied to clipboard

New-MarkdownCommandHelp doesn't respect -Locale

Open Gijsreyn opened this issue 5 months ago • 3 comments

Prerequisites

  • [x] Write a descriptive title.
  • [x] Make sure you are able to repro it on the latest version
  • [x] Search the existing issues.

Steps to reproduce

When using the New-MarkdownCommandHelp, the docs state the following:

This parameter allows you to specify the language locale for the help files. By default, the cmdlet uses the current CultureInfo.

When I now create a new Markdown file using the command and specify the -Locale different from the default, it is not being respected.

Expected behavior

Locale metadata is added with the specified `-Locale`

Actual behavior

It always grabs the default

Error details


Environment data

Name                           Value
----                           -----
PSVersion                      7.5.1
PSEdition                      Core
GitCommitId                    7.5.1
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

1.0.0-preview5

Visuals

No response

Gijsreyn avatar Jul 12 '25 10:07 Gijsreyn

This is a bug that we need to fix post GA. This needs more investigation.

sdwheeler avatar Jul 16 '25 15:07 sdwheeler

It's seems CommandHelp is create with the locale, but the locale is not reflected into the Metadata and is fixed to "en-US" or the locale of the execution environment.

https://github.com/PowerShell/platyPS/blob/7234f18090d39fd24c1266d08f2d66965e71e565/src/Transform/TransformBase.cs#L57-L58

https://github.com/PowerShell/platyPS/blob/7234f18090d39fd24c1266d08f2d66965e71e565/src/Common/MetadataUtils.cs#L45-L59

I think the specified locale will be reflected with MetadataUtils.GetCommandHelpBaseMetadata(cmdHelp) instead of MetadataUtils.GetCommandHelpBaseMetadataFromCommandInfo(commandInfo)

teramako avatar Sep 07 '25 13:09 teramako

Had this problem occur as well.

Current workaround seems to just be setting/unsetting culture:

try {
    $originalCulture = [System.Globalization.CultureInfo]::CurrentCulture
    [System.Globalization.CultureInfo]::CurrentCulture = 'en-US'
    New-MarkdownCommandHelp -Command $command -OutputFolder $DocsPath -Force | Out-Null
}
finally {
    [System.Globalization.CultureInfo]::CurrentCulture = $originalCulture
}

ArmaanMcleod avatar Dec 08 '25 08:12 ArmaanMcleod