# Requires PowerShell 5+ # Scans all .ui files under src/ and runs pyside6-lupdate to generate/update .ts files next to them. # Usage: Run from repository root: `pwsh dev/update_translations.ps1` or `powershell -ExecutionPolicy Bypass -File dev/update_translations.ps1` $ErrorActionPreference = 'Stop' # Use current working directory (CWD) for relative paths $cwd = Get-Location $lupdate = Join-Path $cwd '.venv\Scripts\pyside6-lupdate.exe' if (-not (Test-Path $lupdate)) { Write-Error "Qt for Python lupdate not found at '$lupdate'. Ensure venv is created and PySide6 tools installed." } $uiFiles = Get-ChildItem -Path (Join-Path $cwd 'src') -Filter '*.ui' -Recurse -File if ($uiFiles.Count -eq 0) { Write-Host 'No .ui files found under src/. Nothing to update.' exit 0 } foreach ($ui in $uiFiles) { # Compute .ts path next to the .ui file $tsPath = [System.IO.Path]::ChangeExtension($ui.FullName, '.ts') # Ensure target directory exists $tsDir = Split-Path -Parent $tsPath if (-not (Test-Path $tsDir)) { New-Item -ItemType Directory -Path $tsDir | Out-Null } # Use absolute paths to avoid path resolution issues $uiAbs = $ui.FullName $tsAbs = $tsPath Write-Host "Updating translations: $uiAbs -> $tsAbs" & $lupdate $uiAbs '-ts' $tsAbs } Write-Host 'Translation update completed.'