wingetautoupdate/Winget-AutoUpdate/functions/Get-NotifLocale.ps1

35 lines
1.0 KiB
PowerShell

#Function to get locale file for Notification.
Function Get-NotifLocale {
#Get OS locale
$OSLocale = (Get-Culture).Parent
#Test if OS locale notif file exists
$TestOSLocalPath = "$WorkingDir\locale\$($OSLocale.Name).xml"
#Set OS Local if file exists
if (Test-Path $TestOSLocalPath) {
$LocaleDisplayName = $OSLocale.DisplayName
$LocaleFile = $TestOSLocalPath
}
#Set English if file doesn't exist
else {
$LocaleDisplayName = "English"
$LocaleFile = "$WorkingDir\locale\en.xml"
}
#Get locale XML file content
[xml]$Script:NotifLocale = Get-Content $LocaleFile -Encoding UTF8 -ErrorAction SilentlyContinue
#Test if new strings exist in $LocaleFile
if ($null -eq $NotifLocale.local.outputs.output[7].message){
$LocaleFile = "$WorkingDir\locale\en.xml"
#Get locale XML file content
[xml]$Script:NotifLocale = Get-Content $LocaleFile -Encoding UTF8 -ErrorAction SilentlyContinue
}
#Rerturn langague display name
Return $LocaleDisplayName
}