Add localization framework for the GUI (en-US baseline) (#764)

Credit to @jmolinap2 for their work in #643, which was used as inspiration.
This commit is contained in:
Sashank
2026-09-10 17:48:43 +02:00
committed by GitHub
parent 6012b02ea2
commit 32024662f3
62 changed files with 2947 additions and 742 deletions
+33 -9
View File
@@ -96,6 +96,17 @@ function Get-PendingTweakActions {
return @($actions.ToArray())
}
<#
.SYNOPSIS
Builds the plain-text list of pending changes: apps to remove and tweaks to apply or undo.
.PARAMETER ShowCurrentlyAppliedTweaksCheckBox
When checked, pending tweak actions are computed against the system's live applied
state instead of the controls' initial values.
.OUTPUTS
System.String[]. One line per pending change, or an empty array if nothing is selected.
#>
function New-Overview {
param(
[System.Windows.Window]$Window,
@@ -114,12 +125,12 @@ function New-Overview {
}
}
if ($selectedAppsCount -gt 0) {
$changesList += "Remove $selectedAppsCount application(s)"
$changesList += Get-Translation -Key 'DeployChangeRemoveApps' -Count $selectedAppsCount -FormatArgs @($selectedAppsCount)
}
foreach ($tweakAction in @(Get-PendingTweakActions -Window $Window -ShowAppliedTweaksMode:$showAppliedTweaksMode)) {
if ($tweakAction.Action -eq 'Undo') {
$changesList += "Undo: $($tweakAction.Label)"
$changesList += Get-Translation -Key 'DeployChangeUndoPrefix' -FormatArgs @($tweakAction.Label)
}
else {
$changesList += $tweakAction.Label
@@ -129,6 +140,11 @@ function New-Overview {
return $changesList
}
<#
.SYNOPSIS
Shows the pending-changes list from New-Overview in a message box, or a
"no changes selected" message when there's nothing to show.
#>
function Invoke-ShowChangesOverview {
param(
[System.Windows.Window]$Window,
@@ -139,12 +155,12 @@ function Invoke-ShowChangesOverview {
$changesList = New-Overview -Window $Window -AppsPanel $AppsPanel -ShowCurrentlyAppliedTweaksCheckBox $ShowCurrentlyAppliedTweaksCheckBox
if ($changesList.Count -eq 0) {
Show-MessageBox -Message 'No changes have been selected.' -Title 'Selected Changes' -Button 'OK' -Icon 'Information'
Show-MessageBox -Message (Get-Translation -Key 'DeployNoChangesSelectedMessage') -Title (Get-Translation -Key 'DeploySelectedChangesTitle') -Button 'OK' -Icon 'Information'
return
}
$message = ($changesList | ForEach-Object { "$([char]0x2022) $_" }) -join "`n"
Show-MessageBox -Message $message -Title 'Selected Changes' -Button 'OK' -Icon 'None' -Width 600
Show-MessageBox -Message $message -Title (Get-Translation -Key 'DeploySelectedChangesTitle') -Button 'OK' -Icon 'None' -Width 600
}
<#
@@ -437,6 +453,14 @@ function Update-AppliedTweaksUserModeState {
}
}
<#
.SYNOPSIS
Updates the deployment-target description text to match the selected user option.
.DESCRIPTION
Falls back to a generic description (current user, other user, or Sysprep default
profile) when a username can't be resolved yet, and to a specific one once it can.
#>
function Update-UserSelectionDescription {
param(
[System.Windows.Window]$Window,
@@ -449,23 +473,23 @@ function Update-UserSelectionDescription {
0 {
$currentUserName = Get-UserName
if ([string]::IsNullOrWhiteSpace($currentUserName)) {
$UserSelectionDescription.Text = "The currently logged-in user profile"
$UserSelectionDescription.Text = Get-Translation -Key 'DeployUserDescriptionCurrentUser'
}
else {
$UserSelectionDescription.Text = "The currently logged-in user profile: $currentUserName"
$UserSelectionDescription.Text = Get-Translation -Key 'DeployUserDescriptionCurrentUserNamed' -FormatArgs @($currentUserName)
}
}
1 {
$targetUserName = $OtherUsernameTextBox.Text.Trim()
if ([string]::IsNullOrWhiteSpace($targetUserName)) {
$UserSelectionDescription.Text = "A different user profile on this system"
$UserSelectionDescription.Text = Get-Translation -Key 'DeployUserDescriptionOtherUser'
}
else {
$UserSelectionDescription.Text = "A different user profile on this system: $targetUserName"
$UserSelectionDescription.Text = Get-Translation -Key 'DeployUserDescriptionOtherUserNamed' -FormatArgs @($targetUserName)
}
}
default {
$UserSelectionDescription.Text = "The default user template, affecting all new users created after this point. Useful for Sysprep deployment."
$UserSelectionDescription.Text = Get-Translation -Key 'DeployUserDescriptionSysprep'
}
}