Skip to content

Localize debug messages in Get-LocalizedDataForInvariantCulture.ps1 #169

@coderabbitai

Description

@coderabbitai

Problem

The function Get-LocalizedDataForInvariantCulture.ps1 contains hardcoded debug messages that violate the project's localization guidelines. Per the coding guidelines, all Write-Debug, Write-Verbose, Write-Error, and Write-Warning messages must be localized using $script:localizedData.

Current Issues

The following debug messages are hardcoded:

  • Line 106: 'Found an extension to the file name to search. Stripping...'
  • Line 122: "Found '$filePath'."
  • Line 129: "File '$filePath' not found."
  • Line 139: 'Getting file {0}' (modified in PR Change verbose messages to debug messages #163)

Solution

  1. Add localized string keys to the appropriate strings PSD1 file:
ConvertFrom-StringData @'
    GetLocalizedDataForInvariantCulture_GettingFile = Getting file {0}. (GLDFIC0001)
    GetLocalizedDataForInvariantCulture_FoundExtension = Found an extension to the file name to search. Stripping... (GLDFIC0002)
    GetLocalizedDataForInvariantCulture_FoundFile = Found '{0}'. (GLDFIC0003)
    GetLocalizedDataForInvariantCulture_FileNotFound = File '{0}' not found. (GLDFIC0004)
'@
  1. Replace hardcoded strings with localized versions:
Write-Debug -Message ($script:localizedData.GetLocalizedDataForInvariantCulture_GettingFile -f $languageFile)
Write-Debug -Message $script:localizedData.GetLocalizedDataForInvariantCulture_FoundExtension
Write-Debug -Message ($script:localizedData.GetLocalizedDataForInvariantCulture_FoundFile -f $filePath)
Write-Debug -Message ($script:localizedData.GetLocalizedDataForInvariantCulture_FileNotFound -f $filePath)

Context

This issue was identified during review of PR #163: #163 (comment)

References

Requested by: @dan-hughes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions