mirror of
https://github.com/PabloMK7/citra
synced 2024-11-15 05:08:23 +00:00
cmake: generate translation file and add to resource for citra_qt
This commit is contained in:
parent
62890b253e
commit
500a7f07c2
5 changed files with 53 additions and 0 deletions
|
@ -10,10 +10,12 @@ option(ENABLE_SDL2 "Enable the SDL2 frontend" ON)
|
|||
option(CITRA_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" OFF)
|
||||
|
||||
option(ENABLE_QT "Enable the Qt frontend" ON)
|
||||
option(ENABLE_QT_TRANSLATION "Enable translations for the Qt frontend" OFF)
|
||||
option(CITRA_USE_BUNDLED_QT "Download bundled Qt binaries" OFF)
|
||||
|
||||
option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON)
|
||||
option(CITRA_USE_BUNDLED_CURL "FOR MINGW ONLY: Download curl configured against winssl instead of openssl" OFF)
|
||||
|
||||
if (ENABLE_WEB_SERVICE AND CITRA_USE_BUNDLED_CURL AND WINDOWS AND MSVC)
|
||||
message("Turning off use bundled curl as msvc can compile curl on cpr")
|
||||
SET(CITRA_USE_BUNDLED_CURL OFF CACHE BOOL "" FORCE)
|
||||
|
@ -230,6 +232,10 @@ if (ENABLE_QT)
|
|||
endif()
|
||||
|
||||
find_package(Qt5 REQUIRED COMPONENTS Widgets OpenGL ${QT_PREFIX_HINT})
|
||||
|
||||
if (ENABLE_QT_TRANSLATION)
|
||||
find_package(Qt5 REQUIRED COMPONENTS LinguistTools ${QT_PREFIX_HINT})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
|
|
3
dist/languages/.gitignore
vendored
Normal file
3
dist/languages/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Ignore the source language file
|
||||
en.ts
|
||||
|
9
dist/languages/.tx/config
vendored
Normal file
9
dist/languages/.tx/config
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
[main]
|
||||
host = https://www.transifex.com
|
||||
|
||||
[citra.emulator]
|
||||
file_filter = <lang>.ts
|
||||
source_file = en.ts
|
||||
source_lang = en
|
||||
type = QT
|
||||
|
1
dist/languages/README.md
vendored
Normal file
1
dist/languages/README.md
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
This directory stores translation patches (TS files) for citra Qt frontend. This directory is linked with [citra project on transifex](https://www.transifex.com/citra/citra), so you can update the translation by executing `tx pull -a`. If you want to contribute to the translation, please go the transifex link and submit your translation there. This directory on the main repo will be synchronized with transifex periodically. Do not directly open PRs on github to modify the translation.
|
|
@ -87,12 +87,46 @@ file(GLOB_RECURSE THEMES ${CMAKE_SOURCE_DIR}/dist/qt_themes/*)
|
|||
|
||||
qt5_wrap_ui(UI_HDRS ${UIS})
|
||||
|
||||
if (ENABLE_QT_TRANSLATION)
|
||||
set(CITRA_QT_LANGUAGES "${CMAKE_SOURCE_DIR}/dist/languages" CACHE PATH "Path to the translation bundle for the Qt frontend")
|
||||
option(GENERATE_QT_TRANSLATION "Generate en.ts as the translation source file" OFF)
|
||||
|
||||
# Update source TS file if enabled
|
||||
if (GENERATE_QT_TRANSLATION)
|
||||
get_target_property(SRCS citra-qt SOURCES)
|
||||
qt5_create_translation(QM_FILES ${SRCS} ${UIS} ${CITRA_QT_LANGUAGES}/en.ts)
|
||||
add_custom_target(translation ALL DEPENDS ${CITRA_QT_LANGUAGES}/en.ts)
|
||||
endif()
|
||||
|
||||
# Find all TS files except en.ts
|
||||
file(GLOB_RECURSE LANGUAGES_TS ${CITRA_QT_LANGUAGES}/*.ts)
|
||||
list(REMOVE_ITEM LANGUAGES_TS ${CITRA_QT_LANGUAGES}/en.ts)
|
||||
|
||||
# Compile TS files to QM files
|
||||
qt5_add_translation(LANGUAGES_QM ${LANGUAGES_TS})
|
||||
|
||||
# Build a QRC file from the QM file list
|
||||
set(LANGUAGES_QRC ${CMAKE_CURRENT_BINARY_DIR}/languages.qrc)
|
||||
file(WRITE ${LANGUAGES_QRC} "<RCC><qresource prefix=\"languages\">\n")
|
||||
foreach (QM ${LANGUAGES_QM})
|
||||
get_filename_component(QM_FILE ${QM} NAME)
|
||||
file(APPEND ${LANGUAGES_QRC} "<file>${QM_FILE}</file>\n")
|
||||
endforeach (QM)
|
||||
file(APPEND ${LANGUAGES_QRC} "</qresource></RCC>")
|
||||
|
||||
# Add the QRC file to package in all QM files
|
||||
qt5_add_resources(LANGUAGES ${LANGUAGES_QRC})
|
||||
else()
|
||||
set(LANGUAGES)
|
||||
endif()
|
||||
|
||||
target_sources(citra-qt
|
||||
PRIVATE
|
||||
${ICONS}
|
||||
${THEMES}
|
||||
${UI_HDRS}
|
||||
${UIS}
|
||||
${LANGUAGES}
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
|
|
Loading…
Reference in a new issue