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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Get-LocalizedDataForInvariantCulture`
- Changed file processing message from `Write-Verbose` to `Write-Debug`
for internal diagnostic information.
- Localized hardcoded `Write-Debug` messages to use localized strings
([#169](https://github.com/dsccommunity/DscResource.Common/issues/169)).

### Fixed

Expand Down
10 changes: 5 additions & 5 deletions source/Public/Get-LocalizedDataForInvariantCulture.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function Get-LocalizedDataForInvariantCulture
{
if ($FileName -match '\.psm1$|\.ps1$|\.psd1$')
{
Write-Debug -Message 'Found an extension to the file name to search. Stripping...'
Write-Debug -Message $script:localizedData.Get_LocalizedDataForInvariantCulture_FoundExtension
$FileName = $FileName -replace '\.psm1$|\.ps1$|\.psd1$'
}

Expand All @@ -119,24 +119,24 @@ function Get-LocalizedDataForInvariantCulture
$filePath = [System.IO.Path]::Combine($localizedFolder, $localizedFileName)
if (Test-Path -Path $filePath)
{
Write-Debug -Message "Found '$filePath'."
Write-Debug -Message ($script:localizedData.Get_LocalizedDataForInvariantCulture_FoundFile -f $filePath)
$languageFile = $filePath
# Exit loop as we found the first filename.
break
}
else
{
Write-Debug -Message "File '$filePath' not found."
Write-Debug -Message ($script:localizedData.Get_LocalizedDataForInvariantCulture_FileNotFound -f $filePath)
}
}

if ([string]::IsNullOrEmpty($languageFile))
{
throw ('File ''{0}'' not found in ''{1}''.' -f ($localizedFileNamesToTry -join ','),$localizedFolder)
throw ($script:localizedData.Get_LocalizedDataForInvariantCulture_FileNotFoundInFolder -f ($localizedFileNamesToTry -join ','), $localizedFolder)
}
else
{
Write-Debug -Message ('Getting file {0}' -f $languageFile)
Write-Debug -Message ($script:localizedData.Get_LocalizedDataForInvariantCulture_GettingFile -f $languageFile)
}

$constrainedState = [System.Management.Automation.Runspaces.InitialSessionState]::Create()
Expand Down
7 changes: 7 additions & 0 deletions source/en-US/DscResource.Common.strings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,11 @@ ConvertFrom-StringData @'
Test_ModuleExist_FilteringByPath = Filtering modules by path '{0}'. (DRC0056)
Test_ModuleExist_FilteringByVersion = Filtering modules by version '{0}'. (DRC0057)
Test_ModuleExist_FilteringByPrerelease = Filtering modules by prerelease '{0}'. (DRC0058)

## Get-LocalizedDataForInvariantCulture
Get_LocalizedDataForInvariantCulture_GettingFile = Getting file '{0}'. (GLDFIC0001)
Get_LocalizedDataForInvariantCulture_FoundExtension = Found an extension to the file name to search. Stripping... (GLDFIC0002)
Get_LocalizedDataForInvariantCulture_FoundFile = Found '{0}'. (GLDFIC0003)
Get_LocalizedDataForInvariantCulture_FileNotFound = File '{0}' not found. (GLDFIC0004)
Get_LocalizedDataForInvariantCulture_FileNotFoundInFolder = File '{0}' not found in '{1}'. (GLDFIC0005)
'@