mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-11-26 07:26:18 +01:00
Refactor feature label handling to utilize language catalogs (#890)
This commit is contained in:
+4
-18
@@ -303,14 +303,9 @@ Add your feature to the `"Features"` array in `Config/Features.json`:
|
||||
```json
|
||||
{
|
||||
"FeatureId": "YourFeatureId",
|
||||
"Label": "Short label describing the feature",
|
||||
"ToolTip": "Detailed explanation of what this feature does and its impact.",
|
||||
"Category": "Privacy & Suggested Content",
|
||||
"Priority": 1,
|
||||
"RegistryKey": "Disable_YourFeature.reg",
|
||||
"ApplyText": "Disabling your feature",
|
||||
"UndoLabel": "Short description for the undo",
|
||||
"ApplyUndoText": "Enabling your feature",
|
||||
"RegistryUndoKey": "Enable_YourFeature.reg",
|
||||
"RequiresReboot": false,
|
||||
"DisableWhenApplied": false,
|
||||
@@ -322,14 +317,9 @@ Add your feature to the `"Features"` array in `Config/Features.json`:
|
||||
**Field Descriptions**:
|
||||
|
||||
- `FeatureId`: Unique identifier, this must match parameter name in the Win11Debloat.ps1 and Get.ps1 files.
|
||||
- `Label`: Short description shown in the UI and wiki documentation.
|
||||
- `ToolTip`: Detailed explanation of what the feature does, used for tooltips in the GUI.
|
||||
- `Category`: One of the predefined categories (see Categories array in Features.json), features without a category won't be loaded into the GUI.
|
||||
- `Priority`: Optional. The priority value (int) is used to sort features within a category. If this field is omitted the feature will be sorted based on the order in the Features.json file.
|
||||
- `RegistryKey`: Filename of the registry file to apply (in Regfiles/ directory) or null if feature does not require registry changes.
|
||||
- `ApplyText`: Message shown when applying the feature.
|
||||
- `UndoLabel`: Short description for the undo shown in the UI.
|
||||
- `ApplyUndoText`: Message shown when undoing the feature.
|
||||
- `RegistryUndoKey`: Filename of the registry file to revert changes or null if feature does not require registry changes.
|
||||
- `RequiresReboot`: Optional boolean. Set to `true` if the feature requires a system reboot to take effect.
|
||||
- `DisableWhenApplied`: Optional boolean. Set to `true` if the feature has no supported undo method.
|
||||
@@ -346,7 +336,7 @@ Add a corresponding parameter to both `Win11Debloat.ps1` AND `Scripts/Get.ps1`,
|
||||
|
||||
#### 4. Add the English Translation Entry
|
||||
|
||||
Add a matching entry for your `FeatureId` to `Config/Languages/en-US/Features.json` (see [Localizing UI Text](#localizing-ui-text)) so the GUI shows your `Label`/`ToolTip`/etc. instead of the raw `FeatureId`.
|
||||
Add a matching entry for your `FeatureId` to `Config/Languages/en-US/Features.json` (see [Localizing UI Text](#localizing-ui-text)). Labels, tooltips, and apply/undo messages belong only in the language catalogs.
|
||||
|
||||
#### 5. Add or Update Tests
|
||||
|
||||
@@ -423,7 +413,7 @@ To add a new category for organizing features:
|
||||
}
|
||||
```
|
||||
|
||||
`CategoryId` is the stable identifier used for tweak presets, app-removal scope, and localization lookups. `Name` stays as the English display fallback. Skip `CategoryId` and the category falls back to using its `Name` as the ID, which breaks translation lookups, so always set one.
|
||||
`CategoryId` is required for tweak presets and localization. `Name` must match the `Category` value on features and groups. Add the display label to `Config/Languages/en-US/Categories.json`, keyed by `CategoryId`.
|
||||
|
||||
> [!TIP]
|
||||
> Use [Segoe Fluent Icon Assets](https://learn.microsoft.com/en-us/windows/apps/design/iconography/segoe-fluent-icons-font) for icon codes.
|
||||
@@ -437,17 +427,13 @@ UI Groups allow features to be grouped together in the GUI with a combobox
|
||||
```json
|
||||
{
|
||||
"GroupId": "UniqueGroupId",
|
||||
"Label": "Display label for the group",
|
||||
"ToolTip": "Explanation of what this group controls",
|
||||
"Category": "Category Name",
|
||||
"Priority": 1,
|
||||
"Values": [
|
||||
{
|
||||
"Label": "Option 1",
|
||||
"FeatureIds": ["FeatureId1"]
|
||||
},
|
||||
{
|
||||
"Label": "Option 2",
|
||||
"FeatureIds": ["FeatureId2"]
|
||||
}
|
||||
]
|
||||
@@ -461,9 +447,9 @@ Add a matching entry for your `GroupId` to `Config/Languages/en-US/Features.json
|
||||
|
||||
### Localizing UI Text
|
||||
|
||||
GUI text lives in `Config/Languages/en-US/`, not hardcoded in `Schemas/*.xaml` or `Scripts/GUI/*.ps1`. Adding or changing a Feature, Category, UI Group, or App means updating the matching English entry, or the GUI falls back to showing the raw ID.
|
||||
GUI text lives in `Config/Languages/en-US/`, not hardcoded in `Schemas/*.xaml`, `Scripts/GUI/*.ps1` or `Config/Features.json`. Adding or changing a Feature, Category, UI Group, or App means updating the matching English entry, or the GUI falls back to showing the raw ID.
|
||||
|
||||
- `Config/Languages/en-US/Features.json`, under `"Features"`, keyed by `FeatureId`. Add `Label`, `ToolTip`, `ApplyText`, `UndoLabel`, and `ApplyUndoText` to match whatever fields you set in `Config/Features.json`.
|
||||
- `Config/Languages/en-US/Features.json`, under `"Features"`, keyed by `FeatureId`: `Label` describes the feature, `ToolTip` explains its impact, and `ApplyText` is the operation message. For features supporting undo, also add `UndoLabel` and `ApplyUndoText`.
|
||||
- `Config/Languages/en-US/Features.json`, under `"UiGroups"`, keyed by `GroupId`. Add `Label`, `ToolTip`, and a `Values` map of `FeatureId: "Option label"` matching the group's `Values` array.
|
||||
- `Config/Languages/en-US/Categories.json`, keyed by `CategoryId`. Add a `Label` for every new category.
|
||||
- `Config/Languages/en-US/Apps.json`, keyed by `AppId`. Add `FriendlyName` and `Description` for every new app.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -252,7 +252,6 @@
|
||||
"TweaksAlreadyAppliedTooltip": "Diese Optimierung ist bereits angewendet und kann nicht automatisch rückgängig gemacht werden. Anweisungen zum manuellen Rückgängigmachen dieser Änderung finden Sie im Win11Debloat-Wiki.",
|
||||
"DeployChangeRemoveApps_one": "{0} Anwendung entfernen",
|
||||
"DeployChangeRemoveApps_other": "{0} Anwendungen entfernen",
|
||||
"DeployChangeUndoPrefix": "Rückgängig: {0}",
|
||||
"DeployNoChangesSelectedMessage": "Es wurden keine Änderungen ausgewählt.",
|
||||
"DeploySelectedChangesTitle": "Ausgewählte Änderungen",
|
||||
"DeployUserDescriptionCurrentUser": "Das aktuell angemeldete Benutzerprofil",
|
||||
|
||||
@@ -270,7 +270,6 @@
|
||||
|
||||
"DeployChangeRemoveApps_one": "Remove {0} application",
|
||||
"DeployChangeRemoveApps_other": "Remove {0} applications",
|
||||
"DeployChangeUndoPrefix": "Undo: {0}",
|
||||
"DeployNoChangesSelectedMessage": "No changes have been selected.",
|
||||
"DeploySelectedChangesTitle": "Selected Changes",
|
||||
"DeployUserDescriptionCurrentUser": "The currently logged-in user profile",
|
||||
|
||||
@@ -252,7 +252,6 @@
|
||||
"TweaksAlreadyAppliedTooltip": "Este ajuste ya está aplicado y no se puede deshacer automáticamente. Visite la wiki de Win11Debloat para obtener instrucciones sobre cómo revertir este cambio manualmente.",
|
||||
"DeployChangeRemoveApps_one": "Quitar {0} aplicación",
|
||||
"DeployChangeRemoveApps_other": "Quitar {0} aplicaciones",
|
||||
"DeployChangeUndoPrefix": "Deshacer: {0}",
|
||||
"DeployNoChangesSelectedMessage": "No se ha seleccionado ningún cambio.",
|
||||
"DeploySelectedChangesTitle": "Cambios seleccionados",
|
||||
"DeployUserDescriptionCurrentUser": "El perfil de usuario con la sesión iniciada actualmente",
|
||||
|
||||
@@ -252,7 +252,6 @@
|
||||
"TweaksAlreadyAppliedTooltip": "Cet ajustement est déjà appliqué et ne peut pas être annulé automatiquement. Consultez le wiki de Win11Debloat pour savoir comment rétablir manuellement cette modification.",
|
||||
"DeployChangeRemoveApps_one": "Supprimer {0} application",
|
||||
"DeployChangeRemoveApps_other": "Supprimer {0} applications",
|
||||
"DeployChangeUndoPrefix": "Rétablir : {0}",
|
||||
"DeployNoChangesSelectedMessage": "Aucune modification n'a été sélectionnée.",
|
||||
"DeploySelectedChangesTitle": "Modifications sélectionnées",
|
||||
"DeployUserDescriptionCurrentUser": "Le profil d'utilisateur actuellement connecté",
|
||||
|
||||
@@ -252,7 +252,6 @@
|
||||
"TweaksAlreadyAppliedTooltip": "Questa modifica è già applicata e non può essere annullata automaticamente. Visita la wiki di Win11Debloat per le istruzioni su come annullare manualmente questa modifica.",
|
||||
"DeployChangeRemoveApps_one": "Rimuovi {0} applicazione",
|
||||
"DeployChangeRemoveApps_other": "Rimuovi {0} applicazioni",
|
||||
"DeployChangeUndoPrefix": "Annulla: {0}",
|
||||
"DeployNoChangesSelectedMessage": "Non è stata selezionata alcuna modifica.",
|
||||
"DeploySelectedChangesTitle": "Modifiche selezionate",
|
||||
"DeployUserDescriptionCurrentUser": "Il profilo dell'utente attualmente connesso",
|
||||
|
||||
@@ -265,7 +265,6 @@
|
||||
"TweaksAlreadyAppliedTooltip": "この調整は既に適用されており、自動的に元に戻すことはできません。この変更を手動で元に戻す手順については、Win11Debloat の Wiki を参照してください。",
|
||||
|
||||
"DeployChangeRemoveApps_other": "{0} 個のアプリケーションを削除",
|
||||
"DeployChangeUndoPrefix": "元に戻す: {0}",
|
||||
"DeployNoChangesSelectedMessage": "変更が選択されていません。",
|
||||
"DeploySelectedChangesTitle": "選択された変更",
|
||||
"DeployUserDescriptionCurrentUser": "現在サインインしているユーザー プロファイル",
|
||||
|
||||
@@ -252,7 +252,6 @@
|
||||
"TweaksAlreadyAppliedTooltip": "이 조정 항목은 이미 적용되어 자동으로 실행 취소할 수 없습니다. 이 변경 사항을 수동으로 되돌리는 방법은 Win11Debloat 위키를 참조하세요.",
|
||||
"DeployChangeRemoveApps_one": "앱 {0}개 제거",
|
||||
"DeployChangeRemoveApps_other": "앱 {0}개 제거",
|
||||
"DeployChangeUndoPrefix": "실행 취소: {0}",
|
||||
"DeployNoChangesSelectedMessage": "선택된 변경 사항이 없습니다.",
|
||||
"DeploySelectedChangesTitle": "선택한 변경 사항",
|
||||
"DeployUserDescriptionCurrentUser": "현재 로그인한 사용자 프로필",
|
||||
|
||||
@@ -252,7 +252,6 @@
|
||||
"TweaksAlreadyAppliedTooltip": "Deze aanpassing is al toegepast en kan niet automatisch ongedaan worden gemaakt. Op de Win11Debloat-wiki lees je hoe je de wijziging zelf kunt terugdraaien.",
|
||||
"DeployChangeRemoveApps_one": "{0} app verwijderen",
|
||||
"DeployChangeRemoveApps_other": "{0} apps verwijderen",
|
||||
"DeployChangeUndoPrefix": "Ongedaan maken: {0}",
|
||||
"DeployNoChangesSelectedMessage": "Er zijn geen wijzigingen geselecteerd.",
|
||||
"DeploySelectedChangesTitle": "Geselecteerde wijzigingen",
|
||||
"DeployUserDescriptionCurrentUser": "Het gebruikersprofiel waarmee je nu bent aangemeld",
|
||||
|
||||
@@ -275,7 +275,6 @@
|
||||
"DeployChangeRemoveApps_one": "Remover {0} aplicativo",
|
||||
"DeployChangeRemoveApps_other": "Remover {0} aplicativos",
|
||||
"DeployChangeRemoveApps_many": "Remover {0} de aplicativos",
|
||||
"DeployChangeUndoPrefix": "Desfazer: {0}",
|
||||
"DeployNoChangesSelectedMessage": "Nenhuma alteração foi selecionada.",
|
||||
"DeploySelectedChangesTitle": "Alterações selecionadas",
|
||||
"DeployUserDescriptionCurrentUser": "O perfil do usuário atualmente conectado",
|
||||
|
||||
@@ -262,7 +262,6 @@
|
||||
"DeployChangeRemoveApps_few": "Удалить {0} приложения",
|
||||
"DeployChangeRemoveApps_many": "Удалить {0} приложений",
|
||||
"DeployChangeRemoveApps_other": "Удалить {0} приложений",
|
||||
"DeployChangeUndoPrefix": "Отменить: {0}",
|
||||
"DeployNoChangesSelectedMessage": "Изменения не выбраны.",
|
||||
"DeploySelectedChangesTitle": "Выбранные изменения",
|
||||
"DeployUserDescriptionCurrentUser": "Профиль пользователя, который сейчас вошел в систему",
|
||||
|
||||
@@ -270,7 +270,6 @@
|
||||
|
||||
"DeployChangeRemoveApps_one": "{0} uygulamayı kaldır",
|
||||
"DeployChangeRemoveApps_other": "{0} uygulamayı kaldır",
|
||||
"DeployChangeUndoPrefix": "Geri al: {0}",
|
||||
"DeployNoChangesSelectedMessage": "Seçili değişiklik yok.",
|
||||
"DeploySelectedChangesTitle": "Seçilen değişiklikler",
|
||||
"DeployUserDescriptionCurrentUser": "Şu anda oturum açmış kullanıcı profili",
|
||||
|
||||
@@ -252,7 +252,6 @@
|
||||
"TweaksAlreadyAppliedTooltip": "此项调整已应用,无法自动撤销。请访问 Win11Debloat Wiki,查看手动撤销此更改的说明。",
|
||||
"DeployChangeRemoveApps_one": "卸载 {0} 个应用",
|
||||
"DeployChangeRemoveApps_other": "卸载 {0} 个应用",
|
||||
"DeployChangeUndoPrefix": "撤销:{0}",
|
||||
"DeployNoChangesSelectedMessage": "未选择任何更改。",
|
||||
"DeploySelectedChangesTitle": "所选更改",
|
||||
"DeployUserDescriptionCurrentUser": "当前登录用户的配置文件",
|
||||
|
||||
@@ -252,7 +252,6 @@
|
||||
"TweaksAlreadyAppliedTooltip": "此微調已套用,且無法自動復原。請參閱 Win11Debloat Wiki 以了解如何手動還原此變更。",
|
||||
"DeployChangeRemoveApps_one": "移除 {0} 個應用程式",
|
||||
"DeployChangeRemoveApps_other": "移除 {0} 個應用程式",
|
||||
"DeployChangeUndoPrefix": "復原:{0}",
|
||||
"DeployNoChangesSelectedMessage": "未選取任何變更。",
|
||||
"DeploySelectedChangesTitle": "選取的變更",
|
||||
"DeployUserDescriptionCurrentUser": "目前登入的使用者設定檔",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
Iterates over every non-control parameter in $script:Params and emits a
|
||||
human-readable line for each change that will be applied. For the
|
||||
'RemoveApps' parameter the list of targeted app names is displayed
|
||||
inline. Feature labels are resolved from Features.json when available;
|
||||
inline. Feature labels are resolved from the language catalogs when available;
|
||||
otherwise the raw parameter name is used as a fallback.
|
||||
|
||||
After printing the summary the function pauses until the user presses
|
||||
@@ -16,7 +16,7 @@ function Write-PendingChanges {
|
||||
Write-Output "Win11Debloat will make the following changes:"
|
||||
|
||||
if ($script:Params['CreateRestorePoint']) {
|
||||
Write-Output "- $($script:Features['CreateRestorePoint'].Label)"
|
||||
Write-Output "- $(Get-Translation -Key 'CreateRestorePoint' -Field 'Label' -Section 'Features')"
|
||||
}
|
||||
foreach ($parameterName in $script:Params.Keys) {
|
||||
if ($script:ControlParams -contains $parameterName) {
|
||||
@@ -45,7 +45,7 @@ function Write-PendingChanges {
|
||||
continue
|
||||
}
|
||||
default {
|
||||
$message = $script:Features[$parameterName].Label
|
||||
$message = Get-Translation -Key $parameterName -Field 'Label' -Section 'Features'
|
||||
Write-Output "- $message"
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ function Invoke-FeatureApply {
|
||||
try {
|
||||
# Resolve feature metadata from Features.json
|
||||
$feature = $script:Features[$FeatureId]
|
||||
$applyText = $feature.ApplyText
|
||||
$applyText = Get-Translation -Key $FeatureId -Field 'ApplyText' -Section 'Features'
|
||||
|
||||
# ---- Registry-backed features: import .reg file, then handle additional tasks ----
|
||||
if ($feature.RegistryKey) {
|
||||
@@ -162,7 +162,7 @@ function Invoke-FeatureUndo {
|
||||
return $false
|
||||
}
|
||||
|
||||
$undoText = if ($feature.ApplyUndoText) { $feature.ApplyUndoText } elseif ($feature.UndoLabel) { $feature.UndoLabel } else { $FeatureId }
|
||||
$undoText = Get-Translation -Key $FeatureId -Field 'ApplyUndoText' -Section 'Features'
|
||||
|
||||
try {
|
||||
# ---- Registry-backed features: import undo data, then handle additional tasks ----
|
||||
@@ -308,9 +308,7 @@ function Invoke-UndoFeatures {
|
||||
foreach ($featureId in $FeatureIds) {
|
||||
if ($script:CancelRequested) { return }
|
||||
|
||||
$f = if ($script:Features.ContainsKey($featureId)) { $script:Features[$featureId] } else { $null }
|
||||
$undoLabel = if ($f -and $f.UndoLabel) { Get-Translation -Key $featureId -Field 'UndoLabel' -Section 'Features' } else { $featureId }
|
||||
$undoText = if ($f -and $f.ApplyUndoText) { Get-Translation -Key $featureId -Field 'ApplyUndoText' -Section 'Features' } else { $undoLabel }
|
||||
$undoText = Get-Translation -Key $featureId -Field 'ApplyUndoText' -Section 'Features'
|
||||
|
||||
if ($script:ApplyProgressCallback) {
|
||||
& $script:ApplyProgressCallback $step $TotalSteps $undoText
|
||||
|
||||
@@ -323,7 +323,7 @@ function Get-Translation {
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Looks up a translated label for one value of a UiGroup, falling back to en-US, then to the raw label.
|
||||
Looks up a translated label for one value of a UiGroup, falling back to en-US, then to the feature ID.
|
||||
|
||||
.DESCRIPTION
|
||||
UiGroups[GroupId].Values in the language files is a FeatureId -> Label map, one level deeper
|
||||
@@ -336,13 +336,11 @@ function Get-GroupValueTranslation {
|
||||
[string]$GroupId,
|
||||
[Parameter(Mandatory)]
|
||||
[string]$FeatureId,
|
||||
[Parameter(Mandatory)]
|
||||
[string]$FallbackLabel,
|
||||
[object]$Lang = $script:Lang
|
||||
)
|
||||
|
||||
if (-not $Lang) {
|
||||
return $FallbackLabel
|
||||
return $FeatureId
|
||||
}
|
||||
|
||||
foreach ($candidateLang in (Get-LanguageFallbackChain -Lang $Lang)) {
|
||||
@@ -357,7 +355,7 @@ function Get-GroupValueTranslation {
|
||||
}
|
||||
}
|
||||
|
||||
return $FallbackLabel
|
||||
return $FeatureId
|
||||
}
|
||||
|
||||
<#
|
||||
|
||||
@@ -1,18 +1,6 @@
|
||||
# MainWindow-Deployment.ps1
|
||||
# Overview generation, pending tweak actions, feature labels, tweak preset maps, apply logic, user mode state, user selection, and validation.
|
||||
|
||||
function Get-UndoFeatureLabel {
|
||||
param([string]$FeatureId)
|
||||
|
||||
$undoLabel = $script:UndoFeatureLabelLookup[$FeatureId]
|
||||
if (-not [string]::IsNullOrWhiteSpace([string]$undoLabel)) {
|
||||
return [string]$undoLabel
|
||||
}
|
||||
|
||||
# Fall back to the regular label (prefixed for undo context)
|
||||
return [string]$script:FeatureLabelLookup[$FeatureId]
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Returns the tweak actions that are pending based on the current UI state.
|
||||
@@ -61,7 +49,7 @@ function Get-PendingTweakActions {
|
||||
$actions.Add([PSCustomObject]@{
|
||||
Action = 'Undo'
|
||||
FeatureId = [string]$mapping.FeatureId
|
||||
Label = [string](Get-UndoFeatureLabel -FeatureId $mapping.FeatureId)
|
||||
Label = [string]$script:UndoFeatureLabelLookup[$mapping.FeatureId]
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -129,12 +117,7 @@ function New-Overview {
|
||||
}
|
||||
|
||||
foreach ($tweakAction in @(Get-PendingTweakActions -Window $Window -ShowAppliedTweaksMode:$showAppliedTweaksMode)) {
|
||||
if ($tweakAction.Action -eq 'Undo') {
|
||||
$changesList += Get-Translation -Key 'DeployChangeUndoPrefix' -FormatArgs @($tweakAction.Label)
|
||||
}
|
||||
else {
|
||||
$changesList += $tweakAction.Label
|
||||
}
|
||||
$changesList += $tweakAction.Label
|
||||
}
|
||||
|
||||
return $changesList
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
.PARAMETER Mapping
|
||||
A control mapping with Type and either FeatureId or GroupId and Values. Group values
|
||||
contain FeatureIds and fallback Label text.
|
||||
contain FeatureIds.
|
||||
|
||||
.PARAMETER Features
|
||||
The feature definitions keyed by FeatureId. Defaults to $script:Features.
|
||||
@@ -30,7 +30,7 @@ function Get-TweakControlText {
|
||||
$label = Get-Translation -Key $Mapping.GroupId -Field 'Label' -Section 'UiGroups'
|
||||
$tooltip = Get-Translation -Key $Mapping.GroupId -Field 'ToolTip' -Section 'UiGroups'
|
||||
$options += @($Mapping.Values | ForEach-Object {
|
||||
Get-GroupValueTranslation -GroupId $Mapping.GroupId -FeatureId $_.FeatureIds[0] -FallbackLabel $_.Label
|
||||
Get-GroupValueTranslation -GroupId $Mapping.GroupId -FeatureId $_.FeatureIds[0]
|
||||
})
|
||||
}
|
||||
else {
|
||||
@@ -66,9 +66,7 @@ function Update-FeatureLabelLookup {
|
||||
$script:UndoFeatureLabelLookup = @{}
|
||||
foreach ($feature in $Features) {
|
||||
$script:FeatureLabelLookup[$feature.FeatureId] = Get-Translation -Key $feature.FeatureId -Field 'Label' -Section 'Features'
|
||||
if ($feature.UndoLabel) {
|
||||
$script:UndoFeatureLabelLookup[$feature.FeatureId] = Get-Translation -Key $feature.FeatureId -Field 'UndoLabel' -Section 'Features'
|
||||
}
|
||||
$script:UndoFeatureLabelLookup[$feature.FeatureId] = Get-Translation -Key $feature.FeatureId -Field 'UndoLabel' -Section 'Features'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +242,7 @@ function New-DynamicTweakControls {
|
||||
$text = Get-TweakControlText -Mapping $mapping -Features $featureMap
|
||||
$controlName = ("Feature_{0}_Combo" -f $feature.FeatureId) -replace '[^a-zA-Z0-9_]', ''
|
||||
$control = New-LabeledCombo -parent $parent -labelText $text.Label -comboName $controlName -items $text.Options
|
||||
if ($feature.ToolTip -or $feature.DisableWhenApplied -eq $true) {
|
||||
if ($text.ToolTip -and $text.ToolTip -ne $feature.FeatureId) {
|
||||
Set-TweakControlToolTip -control $control -tooltipText $text.ToolTip -ShowOnDisabled
|
||||
}
|
||||
$script:UiControlMappings[$controlName] = $mapping
|
||||
@@ -353,33 +351,10 @@ function New-DynamicTweakControls {
|
||||
}
|
||||
foreach ($f in $featuresJson.Features) { if ($f.Category) { $categoriesPresent[$f.Category] = $true } }
|
||||
|
||||
# Create cards in the order defined in Features.json Categories (if present)
|
||||
$orderedCategories = @()
|
||||
if ($featuresJson.Categories) {
|
||||
foreach ($c in $featuresJson.Categories) {
|
||||
$categoryName = if ($c -is [string]) { $c } else { $c.Name }
|
||||
if ($categoriesPresent.ContainsKey($categoryName)) {
|
||||
# Store the full category object (or create one with default icon for string categories).
|
||||
# A category without its own CategoryId falls back to its Name, same as before CategoryId existed.
|
||||
$categoryObj = if ($c -is [string]) {
|
||||
@{Name = $c; CategoryId = $c; Icon = '' }
|
||||
}
|
||||
elseif (-not $c.CategoryId) {
|
||||
@{Name = $c.Name; CategoryId = $c.Name; Icon = $c.Icon }
|
||||
}
|
||||
else {
|
||||
$c
|
||||
}
|
||||
$orderedCategories += $categoryObj
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
# For backward compatibility, create category objects from keys
|
||||
foreach ($catName in $categoriesPresent.Keys) {
|
||||
$orderedCategories += @{Name = $catName; CategoryId = $catName; Icon = '' }
|
||||
}
|
||||
}
|
||||
# Create cards in the order defined in Features.json Categories.
|
||||
$orderedCategories = @($featuresJson.Categories | Where-Object {
|
||||
$categoriesPresent.ContainsKey($_.Name)
|
||||
})
|
||||
|
||||
# Build a FeatureId -> feature lookup for version filtering in groups
|
||||
$featureMap = @{}
|
||||
@@ -482,7 +457,7 @@ function New-DynamicTweakControls {
|
||||
$comboName = 'Group_{0}Combo' -f $group.GroupId
|
||||
if (-not $panel) { $panel = Get-OrCreateCategoryCard -categoryObj $categoryObj }
|
||||
$combo = New-LabeledCombo -parent $panel -labelText $text.Label -comboName $comboName -items $text.Options
|
||||
if ($group.ToolTip) {
|
||||
if ($text.ToolTip -and $text.ToolTip -ne $group.GroupId) {
|
||||
Set-TweakControlToolTip -control $combo -tooltipText $text.ToolTip
|
||||
}
|
||||
$script:UiControlMappings[$comboName] = $mapping
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
.DESCRIPTION
|
||||
Combines parameter keys from both forward and undo selections, removes duplicates,
|
||||
and returns the feature label that should be shown to users. Undo selections use
|
||||
UndoLabel when available.
|
||||
UndoLabel.
|
||||
#>
|
||||
function Get-RebootFeatureLabels {
|
||||
$rebootFeatureLabels = [System.Collections.Generic.List[string]]::new()
|
||||
@@ -13,9 +13,9 @@ function Get-RebootFeatureLabels {
|
||||
|
||||
foreach ($paramKey in $candidateParamKeys) {
|
||||
if ($script:Features.ContainsKey($paramKey) -and $script:Features[$paramKey].RequiresReboot -eq $true) {
|
||||
$feature = $script:Features[$paramKey]
|
||||
$isUndo = $script:UndoParams.ContainsKey($paramKey)
|
||||
$displayLabel = if ($isUndo -and $feature.UndoLabel) { Get-Translation -Key $paramKey -Field 'UndoLabel' -Section 'Features' } else { Get-Translation -Key $paramKey -Field 'Label' -Section 'Features' }
|
||||
$labelField = if ($isUndo) { 'UndoLabel' } else { 'Label' }
|
||||
$displayLabel = Get-Translation -Key $paramKey -Field $labelField -Section 'Features'
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace([string]$displayLabel)) {
|
||||
[void]$rebootFeatureLabels.Add([string]$displayLabel)
|
||||
|
||||
@@ -23,6 +23,40 @@ BeforeAll {
|
||||
}
|
||||
|
||||
Describe 'FeatureId parameter contracts' {
|
||||
It 'keeps localized text out of feature definitions and uses category names for membership' {
|
||||
$config = Get-Content -LiteralPath $script:FeaturesPath -Raw | ConvertFrom-Json
|
||||
$objects = @($config.Categories) + @($config.Features) + @($config.UiGroups) + @($config.UiGroups.Values)
|
||||
foreach ($item in $objects) {
|
||||
foreach ($field in 'Label', 'ToolTip', 'ApplyText', 'UndoLabel', 'ApplyUndoText') {
|
||||
$item.PSObject.Properties.Name | Should -Not -Contain $field
|
||||
}
|
||||
}
|
||||
foreach ($item in (@($config.Features) + @($config.UiGroups) | Where-Object { $_.Category })) {
|
||||
$config.Categories.Name | Should -Contain $item.Category
|
||||
}
|
||||
}
|
||||
|
||||
It 'has English text for feature operations, groups, options, and categories directly in the language catalogs' {
|
||||
$config = Get-Content -LiteralPath $script:FeaturesPath -Raw | ConvertFrom-Json
|
||||
$catalog = Get-Content -LiteralPath (Join-Path $script:RepoRoot 'Config\Languages\en-US\Features.json') -Raw | ConvertFrom-Json
|
||||
$categories = Get-Content -LiteralPath (Join-Path $script:RepoRoot 'Config\Languages\en-US\Categories.json') -Raw | ConvertFrom-Json
|
||||
foreach ($feature in $config.Features) {
|
||||
$entry = $catalog.Features.($feature.FeatureId)
|
||||
$entry.ApplyText | Should -Not -BeNullOrEmpty -Because $feature.FeatureId
|
||||
if ($feature.RegistryUndoKey -or $feature.FeatureId -in @('EnableWindowsSandbox', 'EnableWindowsSubsystemForLinux', 'DisableStoreSearchSuggestions')) {
|
||||
$entry.UndoLabel | Should -Not -BeNullOrEmpty -Because $feature.FeatureId
|
||||
$entry.ApplyUndoText | Should -Not -BeNullOrEmpty -Because $feature.FeatureId
|
||||
}
|
||||
}
|
||||
foreach ($group in $config.UiGroups) {
|
||||
$entry = $catalog.UiGroups.($group.GroupId)
|
||||
$entry.Label | Should -Not -BeNullOrEmpty
|
||||
$entry.ToolTip | Should -Not -BeNullOrEmpty
|
||||
foreach ($value in $group.Values) { $entry.Values.($value.FeatureIds[0]) | Should -Not -BeNullOrEmpty }
|
||||
}
|
||||
foreach ($category in $config.Categories) { $categories.($category.CategoryId).Label | Should -Not -BeNullOrEmpty }
|
||||
}
|
||||
|
||||
It 'declares every FeatureId as a parameter on Win11Debloat.ps1' {
|
||||
$parameterNames = Get-ScriptParameterNames -Path $script:Win11DebloatPath
|
||||
$missing = @($script:Features.FeatureId | Where-Object { $parameterNames -notcontains $_ })
|
||||
|
||||
@@ -100,6 +100,10 @@ Describe 'Get-RebootFeatureLabels' {
|
||||
}
|
||||
|
||||
It 'includes reboot-required selections once and uses undo labels for undo operations' {
|
||||
foreach ($feature in $script:Features.Values) {
|
||||
$feature.PSObject.Properties.Remove('Label')
|
||||
$feature.PSObject.Properties.Remove('UndoLabel')
|
||||
}
|
||||
$result = @(Get-RebootFeatureLabels)
|
||||
|
||||
$result | Should -HaveCount 2
|
||||
@@ -118,7 +122,7 @@ Describe 'Get-RebootFeatureLabels' {
|
||||
$result | Should -Contain 'Apply feature'
|
||||
}
|
||||
|
||||
It 'falls back to the regular label when an undo selection has no undo label' {
|
||||
It 'uses the translation key when an undo selection has no undo label' {
|
||||
$script:Params = @{}
|
||||
$script:UndoParams = @{ ApplyFeature = $true }
|
||||
$script:Features.ApplyFeature.UndoLabel = $null
|
||||
@@ -127,10 +131,10 @@ Describe 'Get-RebootFeatureLabels' {
|
||||
$result = @(Get-RebootFeatureLabels)
|
||||
|
||||
$result | Should -HaveCount 1
|
||||
$result | Should -Contain 'Apply feature'
|
||||
$result | Should -Contain 'ApplyFeature'
|
||||
}
|
||||
|
||||
It 'falls back to the regular label when the feature has no UndoLabel property' {
|
||||
It 'uses the translation key when the feature has no UndoLabel property' {
|
||||
$script:Params = @{}
|
||||
$script:UndoParams = @{ MissingUndoLabelFeature = $true }
|
||||
$script:Features.MissingUndoLabelFeature = [PSCustomObject]@{
|
||||
@@ -142,7 +146,7 @@ Describe 'Get-RebootFeatureLabels' {
|
||||
$result = @(Get-RebootFeatureLabels)
|
||||
|
||||
$result | Should -HaveCount 1
|
||||
$result | Should -Contain 'Feature without undo label'
|
||||
$result | Should -Contain 'MissingUndoLabelFeature'
|
||||
}
|
||||
|
||||
It 'returns no labels when there are no selected parameters' {
|
||||
|
||||
@@ -35,6 +35,7 @@ BeforeAll {
|
||||
$entry = @{}
|
||||
foreach ($field in 'ApplyText', 'UndoLabel', 'ApplyUndoText') {
|
||||
if ($null -ne $feature.$field) { $entry[$field] = [string]$feature.$field }
|
||||
$feature.PSObject.Properties.Remove($field)
|
||||
}
|
||||
$langFeatures[$featureId] = [PSCustomObject]$entry
|
||||
}
|
||||
@@ -112,7 +113,7 @@ Describe 'Invoke-FeatureApply' {
|
||||
It 'imports a registry-backed feature' {
|
||||
Invoke-FeatureApply -FeatureId 'RegistryFeature'
|
||||
|
||||
Should -Invoke Import-RegistryFile -Times 1 -Exactly -ParameterFilter { $path -eq 'feature.reg' }
|
||||
Should -Invoke Import-RegistryFile -Times 1 -Exactly -ParameterFilter { $path -eq 'feature.reg' -and $Message -eq '> Apply registry feature...' }
|
||||
Should -Invoke Remove-SelectedApps -Times 0 -Exactly
|
||||
}
|
||||
|
||||
@@ -352,6 +353,7 @@ Describe 'Invoke-FeatureUndo' {
|
||||
DisableTelemetry = [PSCustomObject]@{}
|
||||
DisableStoreSearchSuggestions = [PSCustomObject]@{}
|
||||
}
|
||||
Sync-TestLangFeatures
|
||||
Mock Set-StoreSearchSuggestionsEnabledForAllUsers { $true }
|
||||
Mock Set-StoreSearchSuggestionsEnabled { $true }
|
||||
Mock Get-StoreAppsDatabasePathForUser { 'store.db' }
|
||||
@@ -380,6 +382,12 @@ Describe 'Invoke-FeatureUndo' {
|
||||
$script:disabledFeatures | Should -Be @('Microsoft-Windows-Subsystem-Linux', 'VirtualMachinePlatform')
|
||||
}
|
||||
|
||||
It 'uses the language catalog for undo messages without display metadata' {
|
||||
Invoke-FeatureUndo -FeatureId 'EnableWindowsSandbox' | Should -BeTrue
|
||||
|
||||
Should -Invoke Write-Host -Times 1 -Exactly -ParameterFilter { $Object -eq '> Disable Sandbox...' }
|
||||
}
|
||||
|
||||
It 'disables Sandbox and re-enables telemetry tasks' {
|
||||
$script:Features.DisableTelemetry = [PSCustomObject]@{ ApplyUndoText = 'Enable telemetry'; RegistryUndoKey = 'enable-telemetry.reg' }
|
||||
Invoke-FeatureUndo -FeatureId 'EnableWindowsSandbox'
|
||||
|
||||
@@ -37,17 +37,7 @@ BeforeAll {
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Get-UndoFeatureLabel' {
|
||||
BeforeEach {
|
||||
$script:UndoFeatureLabelLookup = @{ DisableTelemetry = 'Enable telemetry' }
|
||||
$script:FeatureLabelLookup = @{ DisableTelemetry = 'Disable telemetry'; DisableWidgets = 'Disable widgets' }
|
||||
}
|
||||
|
||||
It 'prefers undo labels and falls back to feature labels' {
|
||||
Get-UndoFeatureLabel -FeatureId 'DisableTelemetry' | Should -Be 'Enable telemetry'
|
||||
Get-UndoFeatureLabel -FeatureId 'DisableWidgets' | Should -Be 'Disable widgets'
|
||||
}
|
||||
|
||||
Describe 'Main window helpers' {
|
||||
It 'reads selected app IDs from string or array settings and removes blanks' {
|
||||
$stringSettings = [PSCustomObject]@{ Settings = @([PSCustomObject]@{ Name = 'Apps'; Value = ' One.App, ,Two.App ' }) }
|
||||
$arraySettings = [PSCustomObject]@{ Settings = @([PSCustomObject]@{ Name = 'Apps'; Value = @(' One.App ', '', 'Two.App') }) }
|
||||
|
||||
@@ -43,13 +43,13 @@ BeforeAll {
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Legacy tweak categories' {
|
||||
It 'uses the category Name as CategoryId when building controls without a CategoryId' {
|
||||
Describe 'Tweak category identifiers' {
|
||||
It 'uses the defined CategoryId for controls and presets when it differs from Name' {
|
||||
$script:Lang = Import-LanguageFile -LanguageCode 'en-US'
|
||||
$feature = $script:Features['DisableTelemetry'] | Select-Object *
|
||||
$feature.Category = 'Legacy Category'
|
||||
$legacyCatalog = [PSCustomObject]@{
|
||||
Categories = @([PSCustomObject]@{ Name = 'Legacy Category'; Icon = '' })
|
||||
Categories = @([PSCustomObject]@{ Name = 'Legacy Category'; CategoryId = 'PrivacySuggestedContent'; Icon = '' })
|
||||
Features = @($feature)
|
||||
}
|
||||
Mock Import-JsonFile { $legacyCatalog } -ParameterFilter { $filePath -eq $script:FeaturesFilePath }
|
||||
@@ -59,8 +59,8 @@ Describe 'Legacy tweak categories' {
|
||||
|
||||
$controlName = 'Feature_DisableTelemetry_Combo'
|
||||
$script:UiControlMappings.Count | Should -Be 1
|
||||
$script:UiControlMappings[$controlName].CategoryId | Should -Be 'Legacy Category'
|
||||
$map = Get-CategoryTweakPresetMap -Window $window -CategoryId 'Legacy Category'
|
||||
$script:UiControlMappings[$controlName].CategoryId | Should -Be 'PrivacySuggestedContent'
|
||||
$map = Get-CategoryTweakPresetMap -Window $window -CategoryId 'PrivacySuggestedContent'
|
||||
$map.Count | Should -Be 1
|
||||
$map[$controlName].Control | Should -Be ($window.FindName($controlName))
|
||||
$map[$controlName].DesiredValue | Should -BeTrue
|
||||
@@ -175,7 +175,7 @@ Describe 'Language changes on existing controls' {
|
||||
$disabled.ToolTip.Text | Should -Be (Get-Translation -Key 'TweaksAlreadyAppliedTooltip')
|
||||
[object]::ReferenceEquals($group.SelectedItem, $selectedItem) | Should -BeTrue
|
||||
$group.SelectedIndex | Should -Be 2
|
||||
$selectedItem.Content | Should -Be (Get-GroupValueTranslation -GroupId 'SearchIcon' -FeatureId $script:UiControlMappings['Group_SearchIconCombo'].Values[1].FeatureIds[0] -FallbackLabel 'fallback')
|
||||
$selectedItem.Content | Should -Be (Get-GroupValueTranslation -GroupId 'SearchIcon' -FeatureId $script:UiControlMappings['Group_SearchIconCombo'].Values[1].FeatureIds[0])
|
||||
@(Get-PendingTweakActions -Window $window -ShowAppliedTweaksMode $true | ForEach-Object { "$($_.Action):$($_.FeatureId)" } | Sort-Object) | Should -Be $before
|
||||
$script:FeatureLabelLookup['DisableTelemetry'] | Should -Be $checkbox.Content
|
||||
foreach ($category in $script:CategoryLanguageControls) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
BeforeAll {
|
||||
. (Join-Path $PSScriptRoot '..\Scripts\FileIO\Import-JsonFile.ps1')
|
||||
. (Join-Path $PSScriptRoot '..\Scripts\FileIO\Import-LanguageFile.ps1')
|
||||
function Get-UserName { 'Alice' }
|
||||
function Generate-AppsList { @() }
|
||||
function Add-Parameter { param($Name, $Value) }
|
||||
@@ -20,7 +22,7 @@ Describe 'Show-CliMenuOptions' {
|
||||
BeforeEach {
|
||||
$script:Params = @{}
|
||||
$script:ControlParams = @('WhatIf', 'Silent')
|
||||
$script:Features = @{ DisableTelemetry = [PSCustomObject]@{ Label = 'Disable telemetry' }; CreateRestorePoint = [PSCustomObject]@{ Label = 'Create restore point' } }
|
||||
$script:Lang = Import-LanguageFile -LanguageCode 'en-US' -LanguagesPath (Join-Path $PSScriptRoot '..\Config\Languages')
|
||||
$script:SelectedApps = @('One.App', 'Two.App')
|
||||
$script:SavedSettingsFilePath = 'C:\Settings\LastUsedSettings.json'
|
||||
$script:DefaultSettingsFilePath = 'C:\Settings\DefaultSettings.json'
|
||||
@@ -53,7 +55,7 @@ Describe 'Show-CliMenuOptions' {
|
||||
}
|
||||
|
||||
It 'summarizes selected features and app removal before confirmation' {
|
||||
$script:Params = @{ DisableTelemetry = $true; RemoveApps = $true; Apps = 'Default' }
|
||||
$script:Params = @{ DisableTelemetry = $true; CreateRestorePoint = $true; RemoveApps = $true; Apps = 'Default' }
|
||||
$script:ControlParams = @('WhatIf', 'Silent', 'Apps')
|
||||
$script:InputQueue = @('')
|
||||
|
||||
@@ -61,7 +63,13 @@ Describe 'Show-CliMenuOptions' {
|
||||
|
||||
Should -Invoke Generate-AppsList -Times 1 -Exactly
|
||||
Should -Invoke Read-Host -Times 1 -Exactly
|
||||
Should -Invoke Write-Output -Times 2 -ParameterFilter { $InputObject -like '- *' }
|
||||
Should -Invoke Write-Output -Times 3 -ParameterFilter { $InputObject -like '- *' }
|
||||
Should -Invoke Write-Output -Times 1 -Exactly -ParameterFilter {
|
||||
$InputObject -eq "- $(Get-Translation -Key 'CreateRestorePoint' -Field 'Label' -Section 'Features')"
|
||||
}
|
||||
Should -Invoke Write-Output -Times 1 -Exactly -ParameterFilter {
|
||||
$InputObject -eq "- $(Get-Translation -Key 'DisableTelemetry' -Field 'Label' -Section 'Features')"
|
||||
}
|
||||
}
|
||||
|
||||
It 'returns the saved-settings menu option only when the file is available' {
|
||||
|
||||
@@ -7,6 +7,75 @@ BeforeAll {
|
||||
$script:LanguagesPath = Join-Path $script:RepoRoot 'Config/Languages'
|
||||
}
|
||||
|
||||
Describe 'CLI language routing' {
|
||||
BeforeAll {
|
||||
function Show-CliMenuOptions { '0' }
|
||||
function Show-MainWindow {}
|
||||
$tokens = $null
|
||||
$parseErrors = $null
|
||||
$ast = [System.Management.Automation.Language.Parser]::ParseFile(
|
||||
"$script:RepoRoot/Win11Debloat.ps1", [ref]$tokens, [ref]$parseErrors)
|
||||
$parseErrors | Should -BeNullOrEmpty
|
||||
# Execute only language initialization and mode routing, avoiding Windows startup/mutations.
|
||||
$initialization = $ast.EndBlock.Statements | Where-Object {
|
||||
$_ -is [System.Management.Automation.Language.AssignmentStatementAst] -and
|
||||
$_.Left.Extent.Text -in @('$script:UiPreferences', '$script:Lang')
|
||||
}
|
||||
$script:LanguageStartup = [scriptblock]::Create(($initialization.Extent.Text -join "`n"))
|
||||
$routing = $ast.EndBlock.Statements | Where-Object {
|
||||
$_ -is [System.Management.Automation.Language.IfStatementAst] -and
|
||||
$_.Extent.Text -match '\$result = Show-MainWindow'
|
||||
}
|
||||
$script:LanguageRouting = [scriptblock]::Create($routing.Extent.Text)
|
||||
}
|
||||
|
||||
BeforeEach {
|
||||
$script:UiPreferencesFilePath = "$TestDrive/preferences.json"
|
||||
Save-UiPreferences -Preferences @{ Theme = 'Dark'; Language = 'nl-NL' }
|
||||
$script:Params = @{ CLI = $true }
|
||||
$controlParamsCount = 1
|
||||
$launchInCLI = $true
|
||||
$CLI = $true
|
||||
$Silent = $true
|
||||
$Language = 'pt-BR'
|
||||
$RunDefaults = $false
|
||||
$RunDefaultsLite = $false
|
||||
$RunSavedSettings = $false
|
||||
$Config = $null
|
||||
$script:MenuLanguage = $null
|
||||
$script:GuiLanguage = $null
|
||||
Mock Show-CliMenuOptions { $script:MenuLanguage = $script:Lang.LanguageCode; '0' }
|
||||
Mock Show-MainWindow { throw 'Simulated GUI startup failure' }
|
||||
Mock Write-Warning {}
|
||||
}
|
||||
|
||||
It 'uses English in CLI despite saved and explicit GUI languages' {
|
||||
& $script:LanguageStartup
|
||||
& $script:LanguageRouting
|
||||
|
||||
$script:MenuLanguage | Should -Be 'en-US'
|
||||
$script:UiPreferences.Theme | Should -Be 'Dark'
|
||||
(Get-UiPreferences).Language | Should -Be 'nl-NL'
|
||||
Should -Invoke Show-MainWindow -Times 0 -Exactly
|
||||
}
|
||||
|
||||
It 'restores English before falling back from the selected GUI language to CLI' {
|
||||
$launchInCLI = $false
|
||||
$CLI = $false
|
||||
Mock Show-MainWindow {
|
||||
$script:GuiLanguage = $script:Lang.LanguageCode
|
||||
throw 'Simulated GUI startup failure'
|
||||
}
|
||||
& $script:LanguageStartup
|
||||
& $script:LanguageRouting
|
||||
|
||||
Should -Invoke Show-MainWindow -Times 1 -Exactly
|
||||
$script:GuiLanguage | Should -Be 'pt-BR'
|
||||
$script:MenuLanguage | Should -Be 'en-US'
|
||||
(Get-UiPreferences).Language | Should -Be 'nl-NL'
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'UI preference initialization' {
|
||||
BeforeEach {
|
||||
$script:UiPreferencesFilePath = "$TestDrive/preferences.json"
|
||||
|
||||
+8
-4
@@ -322,8 +322,8 @@ $script:Features = @{}
|
||||
try {
|
||||
$featuresData = Get-Content -Path $script:FeaturesFilePath -Raw | ConvertFrom-Json
|
||||
foreach ($feature in $featuresData.Features) {
|
||||
if ([string]::IsNullOrWhiteSpace([string]$feature.FeatureId) -or [string]::IsNullOrWhiteSpace([string]$feature.Label) -or [string]::IsNullOrWhiteSpace([string]$feature.ApplyText)) {
|
||||
Write-Warning "Feature '$($feature.FeatureId)' is missing a FeatureId, Label, or ApplyText in Features.json and will be skipped."
|
||||
if ([string]::IsNullOrWhiteSpace([string]$feature.FeatureId)) {
|
||||
Write-Warning "A feature is missing a FeatureId in Features.json and will be skipped."
|
||||
continue
|
||||
}
|
||||
$script:Features[$feature.FeatureId] = $feature
|
||||
@@ -476,8 +476,9 @@ $WinVersion = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\Current
|
||||
# Check if the machine supports Modern Standby, this is used to determine if the DisableModernStandbyNetworking option can be used
|
||||
$script:ModernStandbySupported = Test-ModernStandbySupport
|
||||
|
||||
# Explicit -Language takes precedence over saved UI preferences and the system culture.
|
||||
Initialize-UiPreferences -Language $Language
|
||||
# CLI menus, operation messages, and app selection always use English.
|
||||
$script:UiPreferences = Get-UiPreferences
|
||||
$script:Lang = Import-LanguageFile -LanguageCode 'en-US'
|
||||
|
||||
$script:Params = $PSBoundParameters
|
||||
$script:UndoParams = @{}
|
||||
@@ -574,6 +575,8 @@ if ((-not $script:Params.Count) -or $RunDefaults -or $RunDefaultsLite -or $RunSa
|
||||
}
|
||||
else {
|
||||
try {
|
||||
# Explicit -Language takes precedence over saved UI preferences and the system culture.
|
||||
Initialize-UiPreferences -Language $Language
|
||||
$result = Show-MainWindow
|
||||
|
||||
try {
|
||||
@@ -584,6 +587,7 @@ if ((-not $script:Params.Count) -or $RunDefaults -or $RunDefaultsLite -or $RunSa
|
||||
Exit
|
||||
}
|
||||
catch {
|
||||
$script:Lang = Import-LanguageFile -LanguageCode 'en-US'
|
||||
Write-Warning "The graphical interface could not start: $($_.Exception.Message)"
|
||||
Write-Verbose "GUI Failure details: $($_.Exception.ToString())"
|
||||
if (-not $Silent) {
|
||||
|
||||
Reference in New Issue
Block a user