51 lines
1.2 KiB
PowerShell
51 lines
1.2 KiB
PowerShell
function Resolve-ConfigurationDataLocalizedText {
|
|
[CmdletBinding()]
|
|
Param(
|
|
[AllowNull()]
|
|
$Value,
|
|
|
|
[AllowNull()]
|
|
[string]
|
|
$DefaultValue
|
|
)
|
|
|
|
if($null -eq $Value){
|
|
return $DefaultValue
|
|
}
|
|
|
|
if($Value -is [string]){
|
|
if([string]::IsNullOrWhiteSpace($Value)){
|
|
return $DefaultValue
|
|
}
|
|
|
|
return $Value
|
|
}
|
|
|
|
if(-not (Test-ConfigurationDataMap -Value $Value)){
|
|
return [string]$Value
|
|
}
|
|
|
|
$CultureNames = @(
|
|
[System.Globalization.CultureInfo]::CurrentUICulture.Name,
|
|
[System.Globalization.CultureInfo]::CurrentCulture.Name,
|
|
"en-US",
|
|
"de-DE",
|
|
"en",
|
|
"de"
|
|
) | Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | Select-Object -Unique
|
|
|
|
foreach($CultureName in $CultureNames){
|
|
if(Test-ConfigurationDataMapContainsKey -Map $Value -Key $CultureName){
|
|
return [string](Get-ConfigurationDataMapValue -Map $Value -Key $CultureName)
|
|
}
|
|
}
|
|
|
|
foreach($Entry in $Value.GetEnumerator()){
|
|
if($null -ne $Entry.Value -and -not [string]::IsNullOrWhiteSpace([string]$Entry.Value)){
|
|
return [string]$Entry.Value
|
|
}
|
|
}
|
|
|
|
return $DefaultValue
|
|
}
|