Skip to content

Portable Tool for an Ideal Windows Setup

upd. integration and localization correction (zh_tw)

Greedeksd7a4ed0559e6
diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csproj
index f41b50d4..7b67e78c 100644
--- a/.Source/GTweak/GTweak.csproj
+++ b/.Source/GTweak/GTweak.csproj
@@ -287,6 +287,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
+ <Page Include="Languages\zh-tw\Localize.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="Styles\Buttons\Buttons.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
diff --git a/.Source/GTweak/Languages/LanguageCatalog.xaml b/.Source/GTweak/Languages/LanguageCatalog.xaml
index 2f29a6a8..dbc50405 100644
--- a/.Source/GTweak/Languages/LanguageCatalog.xaml
+++ b/.Source/GTweak/Languages/LanguageCatalog.xaml
@@ -18,6 +18,6 @@
<v:String x:Key="pt_br">Português (BR)</v:String>
<v:String x:Key="ru">Русский (RU)</v:String>
<v:String x:Key="uk">Українська (UK)</v:String>
- <v:String x:Key="zh-TW">繁體中文 (TW)</v:String>
+ <v:String x:Key="zh_tw">繁體中文 (TW)</v:String>
</ResourceDictionary>
diff --git a/.Source/GTweak/Languages/zh-TW/Localize.xaml b/.Source/GTweak/Languages/zh-TW/Localize.xaml
index bf8297bb..9823cf14 100644
--- a/.Source/GTweak/Languages/zh-TW/Localize.xaml
+++ b/.Source/GTweak/Languages/zh-TW/Localize.xaml
@@ -386,9 +386,9 @@
<!--#endregion-->
<!--#region System Page -->
- <v:String x:Key="slider1_系統">滑鼠游標速度:</v:String>
- <v:String x:Key="slider2_系統">鍵盤重複延遲:</v:String>
- <v:String x:Key="slider3_系統">鍵盤重複頻率:</v:String>
+ <v:String x:Key="slider1_sys">滑鼠游標速度:</v:String>
+ <v:String x:Key="slider2_sys">鍵盤重複延遲:</v:String>
+ <v:String x:Key="slider3_sys">鍵盤重複頻率:</v:String>
<v:String x:Key="text_sys">在此輸入文字以測試鍵盤設定</v:String>
<v:String x:Key="tgl1_sys">提升游標精準度</v:String>
<v:String x:Key="tgl2_sys">黏著鍵與篩選鍵功能</v:String>
@@ -480,6 +480,11 @@
<!--#endregion-->
<!--#region Addons Page -->
+ <v:String x:Key="btn_open_dir">Select folder</v:String>
+ <v:String x:Key="btn_run">Run</v:String>
+ <v:String x:Key="chk_run_ti_adds">Run as TrustedInstaller</v:String>
+ <v:String x:Key="text_info_adds">Select a directory or make sure it is not empty</v:String>
+ <v:String x:Key="scripts_info_adds">After that, you will be able to run scripts (.ps1, .cmd, .bat, .reg) on this page</v:String>
<!--#endregion-->
-</ResourceDictionary>
\ No newline at end of file
+</ResourceDictionary>
diff --git a/Tools/LocalizeSync.ps1 b/Tools/LocalizeSync.ps1
index 573bef06..ca18be5d 100644
--- a/Tools/LocalizeSync.ps1
+++ b/Tools/LocalizeSync.ps1
@@ -11,6 +11,7 @@
function Info([string]$s) { Write-Host $s -ForegroundColor Cyan }
function Ok([string]$s) { Write-Host $s -ForegroundColor Green }
function Warn([string]$s) { Write-Host $s -ForegroundColor Yellow }
+function Update([string]$s) { Write-Host $s -ForegroundColor Blue }
# detect script directory
$scriptDir = if ($PSScriptRoot) { $PSScriptRoot } else { Split-Path -Parent $MyInvocation.MyCommand.Definition }
@@ -53,6 +54,59 @@ $elementRegex = '(<v:String\b[^>]*\bx:Key\s*=\s*"[^\"]+"[^>]*?(?:\/>|>.*?<\/v:St
$keyAttrRegex = 'x:Key\s*=\s*"([^"]+)"'
$regionStartRegex = '<!--\#region\s*(.*?)\s*-->'
+
+# Collect the `LanguageCatalog.xaml` and ensure key formatting
+function ProcessLanguageCatalog([string]$catalogFile) {
+ if (-not (Test-Path -LiteralPath $catalogFile)) {
+ Write-Host "LanguageCatalog file not found: $catalogFile"
+ return
+ }
+
+ Info "Processing LanguageCatalog: $catalogFile"
+
+ $catalogText = Get-Content -Raw -LiteralPath $catalogFile
+ $catalogKeys = [regex]::Matches($catalogText, $keyAttrRegex)
+
+ $updatedCatalogText = $catalogText
+
+ foreach ($match in $catalogKeys) {
+ $key = $match.Groups[1].Value
+
+ $newKey = $key.ToLower().Replace('-', '_')
+
+ if ($newKey -ne $key) {
+ Update " Key '$key' updated to '$newKey'"
+ $updatedCatalogText = $updatedCatalogText -replace ("x:Key=`"$key`""), "x:Key=`"$newKey`""
+ }
+ }
+
+ $endTag = "</ResourceDictionary>"
+ $idxEnd = $updatedCatalogText.LastIndexOf($endTag, [System.StringComparison]::OrdinalIgnoreCase)
+
+ if ($idxEnd -ge 0) {
+ $beforeEnd = $updatedCatalogText.Substring(0, $idxEnd + $endTag.Length)
+ $afterEnd = $updatedCatalogText.Substring($idxEnd + $endTag.Length)
+ $cleanedAfterEnd = $afterEnd.TrimEnd()
+ $updatedCatalogText = $beforeEnd + $cleanedAfterEnd
+ }
+
+ if ($updatedCatalogText -ne $catalogText) {
+ if ($DryRun) {
+ Write-Host " (DryRun) LanguageCatalog would be changed."
+ } else {
+ if ($Backup) { Copy-Item -LiteralPath $catalogFile -Destination ($catalogFile + ".bak") -Force }
+ Set-Content -LiteralPath $catalogFile -Value $updatedCatalogText -Force
+ Ok " Updated: $catalogFile"
+ }
+ } else {
+ Ok " No changes: $catalogFile"
+ }
+}
+
+$languageCatalogFile = Join-Path $BasePath "LanguageCatalog.xaml"
+ProcessLanguageCatalog $languageCatalogFile
+Write-Host ""
+
# collect reference elements and key list
$refElements = @()
foreach ($m in [regex]::Matches($refText, $elementRegex, [System.Text.RegularExpressions.RegexOptions]::Singleline)) {