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
Details of the scenario you tried and the problem that is occurring
The issue is that the cmdlet defaults to the filename ModuleName.psd1 if the FIleName parameter is not set. When the default culture is set there are no evaluation which .psd1 name to import in the following code:
<# Regression test for issues loading the *.strings.psd1 from default culture when OS has different culture for which no localized strings exist.#>
Context "When the operating system UI culture does not exist and the default culture have a '.strings.psd1' file" {
BeforeAll {
New-Item-Force -Path 'TestDrive:\en-US'-ItemType Directory
# This content is written to the file 'en-US\Get-LocalizedData.Tests.strings.psd1'.$null="ConvertFrom-StringData @`'# sv-SE stringsStringKey = String value'@"|Out-File-Force -FilePath 'TestDrive:\en-US\Get-LocalizedData.Tests.strings.psd1'# Mocking German UICulture for which there are no localization strings.
Mock -CommandName Get-UICulture-MockWith {
return@{
Parent='de'LCID='1031'KeyboardLayoutId='1031'Name='de-DE'IetfLanguageTag='de-DE'DisplayName='Deutsch (Deutschland)'NativeName='Deutsch (Deutschland)'EnglishName='German (Germany)'TwoLetterISOLanguageName='de'ThreeLetterISOLanguageName='deu'ThreeLetterWindowsLanguageName='DEU'
}
}
}
It 'Should retrieve the data' {
{ Get-LocalizedData-DefaultUICulture 'en-US'-BaseDirectory 'TestDrive:\' } | Should -Not-Throw
}
}
Throws an error with the current code (added verbose messages to verify the mocks worked as expected):
Context When the operating system UI culture does not exist and the default culture have a '.strings.psd1' file
VERBOSE: DEBUG 5: UICulture de-DE
VERBOSE: DEBUG 10: $PSBoundParameters.UICulture: en-US
VERBOSE: DEBUG 10: $PSBoundParameters.FileName: Get-LocalizedData.Tests.ps1
Import-LocalizedData: C:\source\DscResource.Common\tests\Unit\Public\Get-LocalizedData.Tests.ps1:189
Line |
189 | … { Get-LocalizedData -DefaultUICulture 'en-US' -BaseDirector …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find the PowerShell data file 'Get-LocalizedData.Tests.psd1' in directory
| 'C:\Users\johan.ljunggren\AppData\Local\Temp\17a66d67-279a-456c-b20c-af4c5f313c7a\en-US', or in any parent culture directories.
Expected behavior
Should import the correct file in en en-US folder.
Current behavior
Fails with an error it cannot load '*.psd1' (because there are no such file, there do exist a `*.strings.psd1').
Suggested solution to the issue
When there are no parent culture ($null -eq $currentCulture.Parent) the default culture should be set and the loop that evaluates the localization filenames should run one more time for the default culture.
The operating system the target node is running
Any
Version and build of PowerShell the target node is running
Any
Version of the module that was used
latest release
The text was updated successfully, but these errors were encountered:
johlju
changed the title
Get-LocalizedData: Fails to import .strings.psd1 in 'en-US' folder on non-'en-US' operating system when default culture is 'en-US'
Get-LocalizedData: Fails to import .strings.psd1 in 'en-US' folder on 'de-DE' operating system when default culture is 'en-US'
Jul 20, 2020
Details of the scenario you tried and the problem that is occurring
The issue is that the cmdlet defaults to the filename
ModuleName.psd1
if the FIleName parameter is not set. When the default culture is set there are no evaluation which .psd1 name to import in the following code:DscResource.Common/source/Public/Get-LocalizedData.ps1
Lines 249 to 252 in 7ed9c78
Steps to reproduce the problem
This is a unit test that repro the issue:
Throws an error with the current code (added verbose messages to verify the mocks worked as expected):
Expected behavior
Should import the correct file in en en-US folder.
Current behavior
Fails with an error it cannot load '*.psd1' (because there are no such file, there do exist a `*.strings.psd1').
Suggested solution to the issue
When there are no parent culture (
$null -eq $currentCulture.Parent
) the default culture should be set and the loop that evaluates the localization filenames should run one more time for the default culture.The operating system the target node is running
Any
Version and build of PowerShell the target node is running
Any
Version of the module that was used
latest release
The text was updated successfully, but these errors were encountered: