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

26 lines
802 B
PowerShell
Raw Normal View History

2022-04-13 16:50:06 +00:00
#Function to get locale file for Notification.
2022-03-14 13:55:02 +00:00
2022-04-13 16:50:06 +00:00
Function Get-NotifLocale {
2022-03-14 13:55:02 +00:00
#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
2022-04-24 08:51:51 +00:00
Write-Log "Notification Level: $NotificationLevel. Notification Language: $LocaleDisplayName" "Cyan"
2022-03-14 13:55:02 +00:00
[xml]$Script:NotifLocale = Get-Content $LocaleFile -Encoding UTF8 -ErrorAction SilentlyContinue
2022-04-13 16:50:06 +00:00
2022-03-14 13:55:02 +00:00
}