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

32 lines
819 B
PowerShell
Raw Permalink 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
{
2023-09-15 14:38:54 +00:00
# Get OS locale
$OSLocale = (Get-UICulture).Parent
2023-09-15 14:38:54 +00:00
# Test if OS locale notif file exists
$TestOSLocalPath = ('{0}\locale\{1}.xml' -f $WorkingDir, $OSLocale.Name)
2023-09-15 14:38:54 +00:00
# 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)
}
2023-09-15 14:38:54 +00:00
# Get locale XML file content
[xml]$Script:NotifLocale = (Get-Content -Path $LocaleFile -Encoding UTF8 -ErrorAction SilentlyContinue)
2023-09-15 14:38:54 +00:00
# Rerturn langague display name
return $LocaleDisplayName
2022-10-26 22:49:10 +00:00
}