diff --git a/.github/workflows/translate.yml b/.github/workflows/translate.yml new file mode 100644 index 0000000..459d177 --- /dev/null +++ b/.github/workflows/translate.yml @@ -0,0 +1,49 @@ +name: Translate +on: + push: + workflow_dispatch: + schedule: + - cron: '0 17 * * *' + +jobs: + update: + runs-on: windows-latest + permissions: + contents: write + steps: + - name: Checkout (main branch) + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Generate template + run: | + git clone --depth 1 https://github.com/x64dbg/x64dbg + cd x64dbg + mkdir bin\translations + git ls-files *.java *.jui *.ui *.c *.c++ *.cc *.cpp *.cxx *.ch *.h *.h++ *.hh *.hpp *.hxx *.js *.qs *.qml *.qrc > bin\translations\files.lst + ..\lupdate.exe @bin\translations\files.lst -locations absolute -ts x64dbg.ts + Copy-Item ".\x64dbg.ts" -Destination "..\x64dbg.ts" -Force + + - name: Crowdin sync + env: + CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }} + run: | + .\crowdin-sync.bat + + - name: Checkout (translations branch) + uses: actions/checkout@v4 + with: + ssh-key: ${{ secrets.UPDATE_SSH_KEY }} + ref: translations + path: translations_repo + + - name: Update translations + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: ./update-translations.sh diff --git a/.gitignore b/.gitignore index d5737c0..bf50bf3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.ts *.qm -*.jar *.zip *.log translations/ +translations_repo/ +x64dbg/ diff --git a/Qt5Core.dll b/Qt5Core.dll new file mode 100644 index 0000000..514d20e Binary files /dev/null and b/Qt5Core.dll differ diff --git a/Qt5Xml.dll b/Qt5Xml.dll new file mode 100644 index 0000000..482d2b9 Binary files /dev/null and b/Qt5Xml.dll differ diff --git a/TranslationChecker.exe b/TranslationChecker.exe index ba0bd25..b8ca7bc 100644 Binary files a/TranslationChecker.exe and b/TranslationChecker.exe differ diff --git a/TranslationChecker/TranslationChecker/Program.cs b/TranslationChecker/TranslationChecker/Program.cs index 13baa40..0ac3d66 100644 --- a/TranslationChecker/TranslationChecker/Program.cs +++ b/TranslationChecker/TranslationChecker/Program.cs @@ -95,7 +95,20 @@ namespace TranslationChecker XmlSerializer serializer = new XmlSerializer(typeof(QtTranslations)); using (var reader = new StringReader(xml)) { - var test = (QtTranslations)serializer.Deserialize(reader); + QtTranslations test = null; + try + { + test = (QtTranslations)serializer.Deserialize(reader); + } + catch (Exception x) + { + // NOTE: This can happen if there is a \r in the string to translate, like this: + // Trace recording has stopped unexpectedly because WriteFile() failed. GetLastError() = %s. + // + Console.WriteLine($"Deserialization error with file: {tsFile}"); + Console.WriteLine(x); + return false; + } using (var writer = new Utf8StringWriter()) using (var xw = XmlWriter.Create(writer, new XmlWriterSettings { diff --git a/crowdin-cli.jar b/crowdin-cli.jar new file mode 100644 index 0000000..fc99e8d Binary files /dev/null and b/crowdin-cli.jar differ diff --git a/crowdin-sync.bat b/crowdin-sync.bat index d69f401..67416d9 100644 --- a/crowdin-sync.bat +++ b/crowdin-sync.bat @@ -1,22 +1,20 @@ @echo off echo Uploading English sources to Crowdin... -java -jar crowdin-cli.jar upload sources --no-colors --no-progress > upload.log 2>&1 +java -jar crowdin-cli.jar upload sources --no-colors --no-progress if not %ERRORLEVEL%==0 ( - type upload.log exit /b 1 ) echo Downloading translations from Crowdin... rmdir /S /Q translations >nul 2>&1 -java -jar crowdin-cli.jar download --no-colors --no-progress > download.log 2>&1 +java -jar crowdin-cli.jar download --no-colors --no-progress if not %ERRORLEVEL%==0 ( - type download.log exit /b 1 ) echo Checking translations... -TranslationChecker.exe translations --fix +TranslationChecker.exe translations set CHECKER_ERRORLEVEL=%ERRORLEVEL% echo Generating Qt translations... diff --git a/lrelease.exe b/lrelease.exe new file mode 100644 index 0000000..c486a16 Binary files /dev/null and b/lrelease.exe differ diff --git a/lupdate.exe b/lupdate.exe new file mode 100644 index 0000000..cc23b92 Binary files /dev/null and b/lupdate.exe differ diff --git a/update-translations.sh b/update-translations.sh new file mode 100644 index 0000000..8621a5b --- /dev/null +++ b/update-translations.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +cp x64dbg.ts translations/ +7z a qm.zip translations/*.qm +7z a ts.zip translations/*.ts + +cp translations/*.ts translations_repo/ +cd translations_repo + +if [ $(git status --porcelain | wc -l) -eq 0 ]; then + echo "No translation changes" + exit 0 +fi + +git status + +git config user.email "41898282+github-actions[bot]@users.noreply.github.com" +git config user.name "github-actions[bot]" + +git add . +git commit -m "Translation update ($(date +'%Y-%m-%dT%H:%M:%S%z'))" +git push + +gh config set prompt disabled +gh release delete -y translations +gh release create --title translations --notes translations translations ../qm.zip ../ts.zip \ No newline at end of file