mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: move translations to their own module
This commit is contained in:
parent
0335f20362
commit
f37813ff88
|
@ -169,54 +169,8 @@ qt5_wrap_ui(${PROJECT_NAME}_FORMS
|
||||||
src/widget/form/settings/privacysettings.ui
|
src/widget/form/settings/privacysettings.ui
|
||||||
src/widget/form/settings/userinterfacesettings.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
|
set(${PROJECT_NAME}_RESOURCES
|
||||||
res.qrc
|
res.qrc
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/translations.qrc
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT SMILEYS)
|
if(NOT SMILEYS)
|
||||||
|
@ -236,25 +190,6 @@ if(NOT "${SMILEYS}" STREQUAL "DISABLED")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in"
|
|
||||||
"<!DOCTYPE RCC>
|
|
||||||
<RCC version=\"1.0\">
|
|
||||||
<qresource prefix=\"/translations\">
|
|
||||||
")
|
|
||||||
foreach(qm ${${PROJECT_NAME}_QM_FILES})
|
|
||||||
get_filename_component(qm_name ${qm} NAME)
|
|
||||||
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in"
|
|
||||||
" <file alias=\"${qm_name}\">${qm}</file>\n")
|
|
||||||
endforeach(qm)
|
|
||||||
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in"
|
|
||||||
" </qresource>
|
|
||||||
</RCC>
|
|
||||||
")
|
|
||||||
|
|
||||||
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
|
set(${PROJECT_NAME}_SOURCES
|
||||||
src/chatlog/chatlinecontent.cpp
|
src/chatlog/chatlinecontent.cpp
|
||||||
src/chatlog/chatlinecontent.h
|
src/chatlog/chatlinecontent.h
|
||||||
|
@ -647,18 +582,19 @@ MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} )
|
||||||
|
|
||||||
add_subdirectory(util)
|
add_subdirectory(util)
|
||||||
add_subdirectory(audio)
|
add_subdirectory(audio)
|
||||||
|
add_subdirectory(translations)
|
||||||
|
|
||||||
add_library(${PROJECT_NAME}_static
|
add_library(${PROJECT_NAME}_static
|
||||||
STATIC
|
STATIC
|
||||||
${${PROJECT_NAME}_FORMS}
|
${${PROJECT_NAME}_FORMS}
|
||||||
${${PROJECT_NAME}_SOURCES}
|
${${PROJECT_NAME}_SOURCES})
|
||||||
${${PROJECT_NAME}_QM_FILES})
|
|
||||||
target_link_libraries(${PROJECT_NAME}_static
|
target_link_libraries(${PROJECT_NAME}_static
|
||||||
${CMAKE_REQUIRED_LIBRARIES}
|
${CMAKE_REQUIRED_LIBRARIES}
|
||||||
${ALL_LIBRARIES})
|
${ALL_LIBRARIES})
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}_static util_library)
|
target_link_libraries(${PROJECT_NAME}_static util_library)
|
||||||
target_link_libraries(${PROJECT_NAME}_static audio_library)
|
target_link_libraries(${PROJECT_NAME}_static audio_library)
|
||||||
|
target_link_libraries(${PROJECT_NAME}_static translations_library)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}
|
add_executable(${PROJECT_NAME}
|
||||||
WIN32
|
WIN32
|
||||||
|
|
|
@ -171,7 +171,7 @@ To get translations into qTox:
|
||||||
3. To update translated strings from Weblate, in the root of the qTox
|
3. To update translated strings from Weblate, in the root of the qTox
|
||||||
repository execute the script `tools/update-weblate.sh`
|
repository execute the script `tools/update-weblate.sh`
|
||||||
4. If a new translation language has been added, update the following files:
|
4. If a new translation language has been added, update the following files:
|
||||||
- `CMakeLists.txt`
|
- `translations/CMakeLists.txt`
|
||||||
- `src/widget/form/settings/generalform.cpp`
|
- `src/widget/form/settings/generalform.cpp`
|
||||||
- `translations/README.md`
|
- `translations/README.md`
|
||||||
- `translations/i18n.pri`
|
- `translations/i18n.pri`
|
||||||
|
|
|
@ -229,6 +229,9 @@ int main(int argc, char* argv[])
|
||||||
#endif
|
#endif
|
||||||
Settings& settings = Settings::getInstance();
|
Settings& settings = Settings::getInstance();
|
||||||
QString locale = settings.getTranslation();
|
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);
|
Translator::translate(locale);
|
||||||
|
|
||||||
// Process arguments
|
// Process arguments
|
||||||
|
|
82
translations/CMakeLists.txt
vendored
Normal file
82
translations/CMakeLists.txt
vendored
Normal file
|
@ -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 <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
"<!DOCTYPE RCC>
|
||||||
|
<RCC version=\"1.0\">
|
||||||
|
<qresource prefix=\"/translations\">
|
||||||
|
")
|
||||||
|
foreach(qm ${translations_FILES})
|
||||||
|
get_filename_component(qm_name ${qm} NAME)
|
||||||
|
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in"
|
||||||
|
" <file alias=\"${qm_name}\">${qm}</file>\n")
|
||||||
|
endforeach(qm)
|
||||||
|
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc.in"
|
||||||
|
" </qresource>
|
||||||
|
</RCC>
|
||||||
|
")
|
||||||
|
|
||||||
|
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)
|
Loading…
Reference in New Issue
Block a user