Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================
- # 1. Poprawka dźwięków w katalogu Sounds
- # =============================
- Copy-Item Sounds\AllDialog.pol_uax Sounds\AllDialog.ger_uax
- # =============================
- # 2. Poprawka napisów w katalogu system
- # =============================
- # Funkcja do odczytu pliku z wykrywaniem BOM (UTF-16 LE lub UTF-8)
- function Read-FileDetectEncoding($path) {
- $bytes = [System.IO.File]::ReadAllBytes($path)
- if ($bytes.Length -ge 2 -and $bytes[0] -eq 0xFF -and $bytes[1] -eq 0xFE) {
- # UTF-16 LE BOM
- return [System.IO.File]::ReadAllText($path, [System.Text.Encoding]::Unicode)
- } elseif ($bytes.Length -ge 3 -and $bytes[0] -eq 0xEF -and $bytes[1] -eq 0xBB -and $bytes[2] -eq 0xBF) {
- # UTF-8 BOM
- return [System.IO.File]::ReadAllText($path, [System.Text.Encoding]::UTF8)
- } else {
- # Domyślnie UTF-8
- return [System.IO.File]::ReadAllText($path, [System.Text.Encoding]::UTF8)
- }
- }
- # Katalog system względem miejsca uruchomienia skryptu
- $systemDir = Join-Path $PSScriptRoot 'system'
- if (-not (Test-Path $systemDir)) {
- Write-Host "❌ Nie znaleziono katalogu: $systemDir"
- exit 1
- }
- # Pobranie plików .pol
- $files = Get-ChildItem -Path $systemDir -Filter *.pol
- Write-Host "Znaleziono plików .pol w system:" $files.Count
- # Iteracja po każdym pliku
- $files | ForEach-Object {
- $sourceFile = $_.FullName
- $targetFile = [System.IO.Path]::ChangeExtension($sourceFile, ".ger")
- # Odczyt pliku z wykryciem kodowania
- $content = Read-FileDetectEncoding $sourceFile
- # Zamiana polskich znaków
- $content = $content `
- -replace 'ą','a' -replace 'ć','c' -replace 'ę','e' -replace 'ł','l' `
- -replace 'ń','n' -replace 'ó','o' -replace 'ś','s' -replace 'ż','z' -replace 'ź','z' `
- -replace 'Ą','A' -replace 'Ć','C' -replace 'Ę','E' -replace 'Ł','L' `
- -replace 'Ń','N' -replace 'Ó','O' -replace 'Ś','S' -replace 'Ż','Z' -replace 'Ź','Z'
- # Zapis UTF-16 LE z BOM
- [System.IO.File]::WriteAllText(
- $targetFile,
- $content,
- [System.Text.Encoding]::Unicode
- )
- Write-Host "✔ Utworzono:" $targetFile
- }
Advertisement
Add Comment
Please, Sign In to add comment