mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-10-08 22:46:50 +00:00
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:
@@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user