diff --git a/CMakeLists.txt b/CMakeLists.txt index 551644d0b..89ed123fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,54 +169,8 @@ qt5_wrap_ui(${PROJECT_NAME}_FORMS src/widget/form/settings/privacysettings.ui src/widget/form/settings/userinterfacesettings.ui) -qt5_add_translation(${PROJECT_NAME}_QM_FILES - translations/ar.ts - translations/be.ts - translations/bg.ts - translations/cs.ts - translations/da.ts - translations/de.ts - translations/el.ts - translations/eo.ts - translations/es.ts - translations/et.ts - translations/fa.ts - translations/fi.ts - translations/fr.ts - translations/he.ts - translations/hr.ts - translations/hu.ts - translations/it.ts - translations/ja.ts - translations/jbo.ts - translations/ko.ts - translations/lt.ts - translations/mk.ts - translations/nl.ts - translations/no_nb.ts - translations/pl.ts - translations/pr.ts - translations/pt.ts - translations/pt_BR.ts - translations/ro.ts - translations/ru.ts - translations/sk.ts - translations/sl.ts - translations/sr.ts - translations/sr_Latn.ts - translations/sv.ts - translations/sw.ts - translations/ta.ts - translations/tr.ts - translations/ug.ts - translations/uk.ts - translations/zh_CN.ts - translations/zh_TW.ts -) - set(${PROJECT_NAME}_RESOURCES res.qrc - ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc ) if(NOT SMILEYS) @@ -236,25 +190,6 @@ if(NOT "${SMILEYS}" STREQUAL "DISABLED") endif() -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in" -" - - -") -foreach(qm ${${PROJECT_NAME}_QM_FILES}) - get_filename_component(qm_name ${qm} NAME) - file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in" - " ${qm}\n") -endforeach(qm) -file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in" -" - -") - -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in - ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc) - set(${PROJECT_NAME}_SOURCES src/chatlog/chatlinecontent.cpp src/chatlog/chatlinecontent.h @@ -647,18 +582,19 @@ MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} ) add_subdirectory(util) add_subdirectory(audio) +add_subdirectory(translations) add_library(${PROJECT_NAME}_static STATIC ${${PROJECT_NAME}_FORMS} - ${${PROJECT_NAME}_SOURCES} - ${${PROJECT_NAME}_QM_FILES}) + ${${PROJECT_NAME}_SOURCES}) target_link_libraries(${PROJECT_NAME}_static ${CMAKE_REQUIRED_LIBRARIES} ${ALL_LIBRARIES}) target_link_libraries(${PROJECT_NAME}_static util_library) target_link_libraries(${PROJECT_NAME}_static audio_library) +target_link_libraries(${PROJECT_NAME}_static translations_library) add_executable(${PROJECT_NAME} WIN32 diff --git a/MAINTAINING.md b/MAINTAINING.md index 92b80cff3..46adec9b0 100644 --- a/MAINTAINING.md +++ b/MAINTAINING.md @@ -171,7 +171,7 @@ To get translations into qTox: 3. To update translated strings from Weblate, in the root of the qTox repository execute the script `tools/update-weblate.sh` 4. If a new translation language has been added, update the following files: - - `CMakeLists.txt` + - `translations/CMakeLists.txt` - `src/widget/form/settings/generalform.cpp` - `translations/README.md` - `translations/i18n.pri` diff --git a/src/main.cpp b/src/main.cpp index 552d16b05..26e3b97d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -229,6 +229,9 @@ int main(int argc, char* argv[]) #endif Settings& settings = Settings::getInstance(); QString locale = settings.getTranslation(); + // We need to init the resources in the translations_library explicitely. + // See https://doc.qt.io/qt-5/resources.html#using-resources-in-a-library + Q_INIT_RESOURCE(translations); Translator::translate(locale); // Process arguments diff --git a/translations/CMakeLists.txt b/translations/CMakeLists.txt new file mode 100644 index 000000000..f2b48831e --- /dev/null +++ b/translations/CMakeLists.txt @@ -0,0 +1,82 @@ +# Copyright © 2020 by The qTox Project Contributors +# +# This file is part of qTox, a Qt-based graphical interface for Tox. +# qTox is libre software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qTox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qTox. If not, see + +# Edit this list if translations are added +qt5_add_translation(translations_FILES + ar.ts + be.ts + bg.ts + cs.ts + da.ts + de.ts + el.ts + eo.ts + es.ts + et.ts + fa.ts + fi.ts + fr.ts + he.ts + hr.ts + hu.ts + it.ts + ja.ts + jbo.ts + ko.ts + lt.ts + mk.ts + nl.ts + no_nb.ts + pl.ts + pr.ts + pt.ts + pt_BR.ts + ro.ts + ru.ts + sk.ts + sl.ts + sr.ts + sr_Latn.ts + sv.ts + sw.ts + ta.ts + tr.ts + ug.ts + uk.ts + zh_CN.ts + zh_TW.ts +) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in" +" + + +") +foreach(qm ${translations_FILES}) + get_filename_component(qm_name ${qm} NAME) + file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in" + " ${qm}\n") +endforeach(qm) +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in" +" + +") + +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in + ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc) + +add_library(translations_library ${translations_FILES} ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)