DSCResources/CommonResourceHelper.psm1
<#
.SYNOPSIS Retrieves the localized string data based on the machine's culture. Falls back to en-US strings if the machine's culture is not supported. .PARAMETER ResourceName The name of the resource as it appears before '.strings.psd1' of the localized string file. For example: xSQLServerEndpoint: MSFT_xSQLServerEndpoint xSQLServerConfiguration: MSFT_xSQLServerConfiguration xSQLServerRole: MSFT_xSQLServerRole #> function Get-LocalizedData { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [String] $ResourceName ) $resourceDirectory = Join-Path -Path $PSScriptRoot -ChildPath $ResourceName $localizedStringFileLocation = Join-Path -Path $resourceDirectory -ChildPath $PSUICulture if (-not (Test-Path -Path $localizedStringFileLocation)) { # Fallback to en-US $localizedStringFileLocation = Join-Path -Path $resourceDirectory -ChildPath 'en-US' } Import-LocalizedData ` -BindingVariable 'localizedData' ` -FileName "$ResourceName.strings.psd1" ` -BaseDirectory $localizedStringFileLocation return $localizedData } Export-ModuleMember -Function @( 'Get-LocalizedData' ) |