mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
35 lines
814 B
PowerShell
35 lines
814 B
PowerShell
|
|
function ConvertTo-IcingaPluginOutputTranslation()
|
||
|
|
{
|
||
|
|
param (
|
||
|
|
$Value = $null,
|
||
|
|
[hashtable]$Translation = @{ }
|
||
|
|
);
|
||
|
|
|
||
|
|
if ($null -eq $Value) {
|
||
|
|
return 'Nothing';
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($null -eq $Translation -Or $Translation.Count -eq 0) {
|
||
|
|
return $Value;
|
||
|
|
}
|
||
|
|
|
||
|
|
[array]$TranslationKeys = $Translation.Keys;
|
||
|
|
[array]$TranslationValues = $Translation.Values;
|
||
|
|
[int]$Index = 0;
|
||
|
|
[bool]$FoundTranslation = $FALSE;
|
||
|
|
|
||
|
|
foreach ($entry in $TranslationKeys) {
|
||
|
|
if (([string]($Value)).ToLower() -eq ([string]($entry)).ToLower()) {
|
||
|
|
$FoundTranslation = $TRUE;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
$Index += 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($FoundTranslation -eq $FALSE) {
|
||
|
|
return $Value;
|
||
|
|
}
|
||
|
|
|
||
|
|
return $TranslationValues[$Index];
|
||
|
|
}
|