Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/System.Management.Automation/help/UpdateHelpCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Help;
using System.Management.Automation.Internal;
Expand Down Expand Up @@ -181,6 +182,16 @@ protected override void ProcessRecord()

_isInitialized = true;
}

// check if there is an UI, if not Throw out terminating error.
var cultures = _language ?? _helpSystem.GetCurrentUICulture();
if (!cultures.Any())
{
string cultureString = string.IsNullOrEmpty(CultureInfo.CurrentCulture.Name) ? CultureInfo.CurrentCulture.DisplayName : CultureInfo.CurrentCulture.Name;
string errMsg = StringUtil.Format(HelpDisplayStrings.FailedToUpdateHelpWithLocaleNoUICulture, cultureString);
ErrorRecord error = new ErrorRecord(new InvalidOperationException(errMsg), "FailedToUpdateHelpWithLocaleNoUICulture", ErrorCategory.InvalidOperation, targetObject: null);
ThrowTerminatingError(error);
}

base.Process(_module, FullyQualifiedModule);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ English-US help content is available and can be saved using: Save-Help -UICultur
<value>Failed to update Help for the module(s) '{0}' with UI culture(s) {{{1}}} : {2}.
English-US help content is available and can be installed using: Update-Help -UICulture en-US.</value>
</data>
<data name="FailedToUpdateHelpWithLocaleNoUICulture" xml:space="preserve">
<value>Your current culture is ({0}), which is not associated with any language, consider changing your system culture or install the English-US help content using: Update-Help -UICulture en-US.</value>
</data>
<data name="FalseShort" xml:space="preserve">
<value>false</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ Describe "Validate 'Update-Help' shows 'HelpCultureNotSupported' when thrown" -T
@{ 'name' = 'explicit culture de-DE'; 'culture' = 'de-DE' }
) {
param ($name, $culture)

# if running in Linux as an invariant culture => force Spanish
if ($IsLinux && $culture -eq $null && (Get-Culture).LCID -eq 127 ){
$culture = 'es-ES'
}

# Cannot pass null, have to splat to skip argument entirely
$cultureArg = $culture ? @{ 'UICulture' = $culture } : @{}
$cultureUsed = $culture ?? (Get-Culture)
Expand Down