Skip to content

Commit c8a66e6

Browse files
authored
little changes
1 parent ac5859b commit c8a66e6

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

winget-update/winget-upgrade.ps1

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818

1919
#Get locale file for Notification
2020
#Default en-US
21-
$DefaultLocal = "$WorkingDir\locale\en-US.xml"
21+
$DefaultLocale = "$WorkingDir\locale\en-US.xml"
2222
#Get OS locale
2323
$Locale = Get-WinSystemLocale
2424
#Test if OS locale config file exists
25-
$LocalFile = "$WorkingDir\locale\$($locale.Name).xml"
26-
if(Test-Path $LocalFile){
27-
[xml]$Script:NotifLocal = Get-Content $LocalFile -Encoding UTF8 -ErrorAction SilentlyContinue
28-
Write-Log "Local : $($locale.Name)"
25+
$LocaleFile = "$WorkingDir\locale\$($locale.Name).xml"
26+
if(Test-Path $LocaleFile){
27+
[xml]$Script:NotifLocale = Get-Content $LocaleFile -Encoding UTF8 -ErrorAction SilentlyContinue
28+
Write-Log "Notification Langugage : $($locale.Name)"
2929
}
3030
else{
31-
[xml]$Script:NotifLocal = Get-Content $DefaultLocal -Encoding UTF8 -ErrorAction SilentlyContinue
32-
Write-Log "Local : en-US"
31+
[xml]$Script:NotifLocale = Get-Content $DefaultLocale -Encoding UTF8 -ErrorAction SilentlyContinue
32+
Write-Log "Notification Langugage : en-US"
3333
}
3434
}
3535

@@ -69,7 +69,7 @@ function Start-NotifTask ($Title,$Message,$MessageType,$Balise) {
6969
Get-ScheduledTask -TaskName "Winget Update Notify" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue
7070
#Wait for notification to display
7171
while ((Get-ScheduledTask -TaskName "Winget Update Notify").State -ne 'Ready') {
72-
Write-Output "Waiting on scheduled task..."
72+
Write-Output "Waiting for scheduled task..."
7373
Start-Sleep 3
7474
}
7575
}
@@ -81,7 +81,7 @@ function Test-Network {
8181
Write-Log "Checking internet connection..." "Yellow"
8282
while (!$ping -and $timeout -lt 1800){
8383
try{
84-
Invoke-RestMethod -Uri "https://ifconfig.me/"
84+
Invoke-RestMethod -Uri "https://api.github.com/zen"
8585
Write-Log "Coonected !" "Green"
8686
$ping = $true
8787
return
@@ -94,8 +94,8 @@ function Test-Network {
9494
if ($timeout -eq 300){
9595
#Send Notif if no connection for 5 min
9696
Write-Log "Notify 'No connection'" "Yellow"
97-
$Title = $NotifLocal.local.outputs.output[0].title
98-
$Message = $NotifLocal.local.outputs.output[0].message
97+
$Title = $NotifLocale.local.outputs.output[0].title
98+
$Message = $NotifLocale.local.outputs.output[0].message
9999
$MessageType = "warning"
100100
$Balise = "connection"
101101
Start-NotifTask $Title $Message $MessageType $Balise
@@ -227,8 +227,8 @@ if ($ping){
227227

228228
#Send available update notification
229229
Write-Log "Updating $($app.Name) from $($app.Version) to $($app.AvailableVersion)..." "Cyan"
230-
$Title = $NotifLocal.local.outputs.output[2].title -f $($app.Name)
231-
$Message = $NotifLocal.local.outputs.output[2].message -f $($app.Version), $($app.AvailableVersion)
230+
$Title = $NotifLocale.local.outputs.output[2].title -f $($app.Name)
231+
$Message = $NotifLocale.local.outputs.output[2].message -f $($app.Version), $($app.AvailableVersion)
232232
$MessageType = "info"
233233
$Balise = $($app.Name)
234234
Start-NotifTask $Title $Message $MessageType $Balise
@@ -261,8 +261,8 @@ if ($ping){
261261
Write-Log "$($app.Name) updated to $($app.AvailableVersion) !" "Green"
262262

263263
#Send Notif
264-
$Title = $NotifLocal.local.outputs.output[3].title -f $($app.Name)
265-
$Message = $NotifLocal.local.outputs.output[3].message -f $($app.AvailableVersion)
264+
$Title = $NotifLocale.local.outputs.output[3].title -f $($app.Name)
265+
$Message = $NotifLocale.local.outputs.output[3].message -f $($app.AvailableVersion)
266266
$MessageType = "success"
267267
$Balise = $($app.Name)
268268
Start-NotifTask $Title $Message $MessageType $Balise
@@ -274,8 +274,8 @@ if ($ping){
274274
Write-Log "$($app.Name) update failed." "Red"
275275

276276
#Send Notif
277-
$Title = $NotifLocal.local.outputs.output[4].title -f $($app.Name)
278-
$Message = $NotifLocal.local.outputs.output[4].message
277+
$Title = $NotifLocale.local.outputs.output[4].title -f $($app.Name)
278+
$Message = $NotifLocale.local.outputs.output[4].message
279279
$MessageType = "error"
280280
$Balise = $($app.Name)
281281
Start-NotifTask $Title $Message $MessageType $Balise
@@ -296,8 +296,8 @@ if ($ping){
296296
else{
297297
Write-Log "Timeout. No internet connection !" "Red"
298298
#Send Notif
299-
$Title = $NotifLocal.local.outputs.output[1].title
300-
$Message = $NotifLocal.local.outputs.output[1].message
299+
$Title = $NotifLocale.local.outputs.output[1].title
300+
$Message = $NotifLocale.local.outputs.output[1].message
301301
$MessageType = "error"
302302
$Balise = "connection"
303303
Start-NotifTask $Title $Message $MessageType $Balise

0 commit comments

Comments
 (0)