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

32 lines
837 B
PowerShell
Raw Normal View History

2023-03-31 15:56:07 +00:00
#Function to get the locale file for notifications
2022-03-14 13:55:02 +00:00
2023-09-15 14:38:54 +00:00
function Get-NotifLocale
{
# Get OS locale
$OSLocale = (Get-UICulture).Parent
# Test if OS locale notif file exists
$TestOSLocalPath = ('{0}\locale\{1}.xml' -f $WorkingDir, $OSLocale.Name)
# Set OS Local if file exists
if (Test-Path -Path $TestOSLocalPath -ErrorAction SilentlyContinue)
{
$LocaleDisplayName = $OSLocale.DisplayName
$LocaleFile = $TestOSLocalPath
}
else
{
# Set English if file doesn't exist
$LocaleDisplayName = 'English'
$LocaleFile = ('{0}\locale\en.xml' -f $WorkingDir)
}
# Get locale XML file content
[xml]$Script:NotifLocale = (Get-Content -Path $LocaleFile -Encoding UTF8 -ErrorAction SilentlyContinue)
# Rerturn langague display name
return $LocaleDisplayName
2022-10-26 22:49:10 +00:00
}