1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 10:42:29 +01:00

Update translations via cmake automatically

This commit is contained in:
Elias Steurer 2021-08-21 12:11:31 +02:00
parent 022c553d35
commit 662a0934e9
23 changed files with 47 additions and 20571 deletions

10
CMake/CMakeLists.txt Normal file
View File

@ -0,0 +1,10 @@
project(CMake)
set(FILES
# cmake-format: sortable
QtUpdateTranslations.cmake)
add_custom_target(
${PROJECT_NAME}
SOURCES ${FILES}
COMMENT "Dummy target to list these files in the IDE")

View File

@ -0,0 +1,17 @@
find_program(LUPDATE_EXECUTABLE lupdate)
find_program(LRELEASE_EXECUTABLE lrelease)
# Updates all ts files and generates .qm
# Absolute paths are needed!
# ibh_qt_update_translations("${CMAKE_CURRENT_SOURCE_DIR}/Src" "${CMAKE_CURRENT_SOURCE_DIR}/Translations")
# The second argument (array) __must__ be passed as string!
function(ibh_qt_update_translations SOURCE_PATH TS_FILES)
message(STATUS "Update Translation: ${SOURCE_PATH}")
foreach(_ts_file ${TS_FILES})
execute_process(COMMAND ${LUPDATE_EXECUTABLE} -noobsolete -recursive ${SOURCE_PATH} -ts ${_ts_file} OUTPUT_QUIET)
execute_process(COMMAND ${LRELEASE_EXECUTABLE} ${_ts_file} OUTPUT_QUIET)
endforeach()
endfunction()

View File

@ -11,6 +11,9 @@ option(SCREENPLAY_STEAM_DEPLOY OFF "Steam build settings. Disables steam_app.txt
option(SCREENPLAY_STEAM ON "For FOSS distribution so we do not bundle proprietary code.")
option(TESTS_ENABLED OFF)
# Add our *.cmake diretory to the CMAKE_MODULE_PATH, so that our includes are found
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/Cmake" ${CMAKE_MODULE_PATH})
file(MAKE_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
@ -70,6 +73,7 @@ add_subdirectory(ScreenPlayShader)
add_subdirectory(ScreenPlayWallpaper)
add_subdirectory(ScreenPlayWidget)
add_subdirectory(ScreenPlayUtil)
add_subdirectory(CMake)
if(${SCREENPLAY_STEAM})
add_subdirectory(ScreenPlayWorkshop)

View File

@ -50,23 +50,26 @@ set(headers
src/create.h
src/wizards.h)
set(l10n
translations/ScreenPlay_de.ts
translations/ScreenPlay_zh_cn.ts
translations/ScreenPlay_pt_br.ts
translations/ScreenPlay_en.ts
translations/ScreenPlay_es.ts
translations/ScreenPlay_fr.ts
translations/ScreenPlay_ko.ts
translations/ScreenPlay_ru.ts
translations/ScreenPlay_vi.ts)
list(
APPEND
L10N
# cmake-format: sortable
${CMAKE_CURRENT_SOURCE_DIR}/translations/ScreenPlay_de.ts
${CMAKE_CURRENT_SOURCE_DIR}/translations/ScreenPlay_zh_cn.ts
${CMAKE_CURRENT_SOURCE_DIR}/translations/ScreenPlay_pt_br.ts
${CMAKE_CURRENT_SOURCE_DIR}/translations/ScreenPlay_en.ts
${CMAKE_CURRENT_SOURCE_DIR}/translations/ScreenPlay_es.ts
${CMAKE_CURRENT_SOURCE_DIR}/translations/ScreenPlay_fr.ts
${CMAKE_CURRENT_SOURCE_DIR}/translations/ScreenPlay_ko.ts
${CMAKE_CURRENT_SOURCE_DIR}/translations/ScreenPlay_ru.ts
${CMAKE_CURRENT_SOURCE_DIR}/translations/ScreenPlay_vi.ts)
include(QtUpdateTranslations)
ibh_qt_update_translations("${CMAKE_CURRENT_SOURCE_DIR}/Src" "${L10N}")
# Needed on macos
find_package(Threads REQUIRED)
set_source_files_properties(${l10n} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/translations")
find_package(
Qt${QT_VERSION_MAJOR}
COMPONENTS Core

View File

@ -1,7 +0,0 @@
### How-to Update Translations?
1. Open PowerShell (in this Directory)
2. Check if you have execution policy set to bypass by executing `Get-ExecutionPolicy`
+ If you have "Bypass" or "Unrestricted" then you are good.
+ If not then execute **in Administrator PowerShell** `Set-ExecutionPolicy Bypass -Scope Process` to set current PowerShell session to Bypass or `Set-ExecutionPolicy Bypass` to set All PowerShell session to Bypass.
3. Execute `./UpdateTranslations.ps1` and follow the instruction printed on the screen.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +0,0 @@
Function Execute-Command ($commandTitle, $commandPath, $commandArguments)
{
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "$commandPath"
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.WorkingDirectory = "$PSScriptRoot"
$pinfo.Arguments = $commandArguments
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()
$exitcodestr = $p.ExitCode.ToString()
Write-Output $p.StandardOutput.ReadToEnd()
Write-Output $p.StandardError.ReadToEnd()
Write-Output "Exit code: $exitcodestr"
}
$MSVCPATH = Read-Host 'Type your ABSOLUTE Qt "bin" directory (default is C:\Qt\5.15.2\msvc2019_64\bin)'
if ($MSVCPATH -eq "") {
echo "Using default directory..."
$MSVCPATH = "C:\Qt\5.15.2\msvc2019_64\bin"
}
echo "Testing directory..."
if (((Test-Path -Path "$MSVCPATH\lupdate.exe") -eq $true) -and ((Test-Path -Path "$MSVCPATH\lrelease.exe") -eq $true)) {
echo "Begin update translations..."
$files = Get-ChildItem ".\*.ts"
foreach ($f in $files){
echo $PSScriptRoot
echo "Processing $f (1/2)"
Execute-Command -commandTitle "Update translation file: $f" -commandPath "$MSVCPATH\lupdate.exe" -commandArguments "-extensions qml ..\qml -ts ""$f"""
echo "Processing $f (2/2)"
Execute-Command -commandTitle "Compile translation file: $f" -commandPath "$MSVCPATH\lrelease.exe" -commandArguments """$f"""
echo "Done"
}
echo "Updated translations."
}
else
{
echo "lupdate or lrelease dosen't exist, failed to update translations..."
}
pause

View File

@ -1,28 +0,0 @@
#!/bin/bash
read -p 'Type your ABSOLUTE Qt "bin" directory (default is /usr/bin): ' path
if [ o$path == "o" ]
then
echo "Using default directory..."
path="/usr/bin"
fi
echo "Testing directory..."
if [[ -f "$path/lupdate" ]] && [[ -f "$path/lrelease" ]]
then
echo "Begin update translations..."
for f in ls *.ts
do
echo "Processing $f (1/2)"
$path/lupdate -extensions qml ../qml -ts $f
echo "Processing $f (2/2)"
$path/lrelease $f
echo "Done"
done
echo "Updated translations."
else
echo "lupdate or lrelease dosen't exist, failed to update translations..."
fi
echo Enter to exit.
read