1
0
mirror of https://github.com/altlinux/admc.git synced 2025-01-09 17:18:15 +03:00

improve translation build process

make it the same for admc and adldap
move admc translation files to admc dir
delete translations dir
move translations.qrc into admc.qrc
This commit is contained in:
Dmitry Degtyarev 2021-03-25 16:38:44 +04:00
parent 4c131e521e
commit 7899968b80
11 changed files with 492 additions and 525 deletions

View File

@ -25,7 +25,6 @@ set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
enable_testing() enable_testing()
add_subdirectory(translations)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(tests) add_subdirectory(tests)
add_subdirectory(doc) add_subdirectory(doc)

View File

@ -13,20 +13,6 @@ find_package(Resolv REQUIRED)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
set(TS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(TS_FILES
${TS_DIR}/adldap_ru.ts
${TS_DIR}/adldap_en.ts
)
set(QM_FILES
${TS_DIR}/adldap_ru.qm
${TS_DIR}/adldap_en.qm
)
add_library(adldap SHARED add_library(adldap SHARED
ad_interface.cpp ad_interface.cpp
ad_config.cpp ad_config.cpp
@ -51,20 +37,23 @@ target_link_libraries(adldap
Resolv::Resolv Resolv::Resolv
) )
# Generate translation binaries (.qm) from sources (.ts) set(TS_FILES
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${TS_DIR}) ${CMAKE_CURRENT_SOURCE_DIR}/adldap_ru.ts
qt5_add_translation(QM_FILES ${TS_FILES}) ${CMAKE_CURRENT_SOURCE_DIR}/adldap_en.ts
)
# NOTE: updating translations(.cpp -> .ts) is in a separate target so that it's not run every time source changes. When you do need to update translations, do `make update_translations`. *Generating* translations IS done every time (.ts -> .qm). # NOTE: custom target to update translation sources (.ts).
# By default, translation sources aren't updated so you have
add_custom_target(update_adldap_translations # to manually make this target to commit translation
# changes.
add_custom_target(adldap_ts
DEPENDS ${TS_FILES} DEPENDS ${TS_FILES}
COMMAND ${Qt5_LUPDATE_EXECUTABLE} -recursive ${CMAKE_CURRENT_SOURCE_DIR} -ts ${TS_FILES} -noobsolete COMMAND ${Qt5_LUPDATE_EXECUTABLE} -recursive ${CMAKE_CURRENT_SOURCE_DIR} -ts ${TS_FILES} -noobsolete
) )
add_custom_target(adldap_translations # Generate translation binaries (.qm) from sources (.ts)
ALL set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_SOURCE_DIR})
DEPENDS ${QM_FILES} qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
)
install(TARGETS adldap) install(TARGETS adldap)

View File

@ -3,6 +3,7 @@ find_package(Qt5 REQUIRED
Core Core
Widgets Widgets
Help Help
LinguistTools
) )
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
@ -96,7 +97,6 @@ add_executable(admc
console_widget/console_drag_model.cpp console_widget/console_drag_model.cpp
admc.qrc admc.qrc
${PROJECT_SOURCE_DIR}/translations/translations.qrc
) )
target_include_directories(admc target_include_directories(admc
@ -113,4 +113,22 @@ target_link_libraries(admc
adldap adldap
) )
set(TS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/admc_ru.ts
${CMAKE_CURRENT_SOURCE_DIR}/admc_en.ts
)
# NOTE: custom target to update translation sources (.ts).
# By default, translation sources aren't updated so you have
# to manually make this target to commit translation
# changes.
add_custom_target(admc_ts
DEPENDS ${TS_FILES}
COMMAND ${Qt5_LUPDATE_EXECUTABLE} -recursive ${CMAKE_CURRENT_SOURCE_DIR} -ts ${TS_FILES} -noobsolete
)
# Generate translation binaries (.qm) from sources (.ts)
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_SOURCE_DIR})
qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
install(TARGETS admc) install(TARGETS admc)

View File

@ -1,5 +1,7 @@
<!DOCTYPE RCC><RCC version="1.0"> <!DOCTYPE RCC><RCC version="1.0">
<qresource> <qresource prefix="/admc/">
<file alias="countries.csv">data/countries.csv</file> <file alias="countries.csv">data/countries.csv</file>
<file>admc_ru.qm</file>
<file>admc_en.qm</file>
</qresource> </qresource>
</RCC> </RCC>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -44,7 +44,7 @@ int main(int argc, char **argv) {
QTranslator translator; QTranslator translator;
const QLocale saved_locale = SETTINGS()->get_variant(VariantSetting_Locale).toLocale(); const QLocale saved_locale = SETTINGS()->get_variant(VariantSetting_Locale).toLocale();
translator.load(saved_locale, QString(), QString(), ":/translations"); translator.load(saved_locale, QString(), QString(), ":/admc");
load_adldap_translation(translator, saved_locale); load_adldap_translation(translator, saved_locale);
app.installTranslator(&translator); app.installTranslator(&translator);

View File

@ -43,7 +43,6 @@ add_executable(gpgui
gui/xml/xml_ubyte_edit.cpp gui/xml/xml_ubyte_edit.cpp
gpgui.qrc gpgui.qrc
${PROJECT_SOURCE_DIR}/translations/translations.qrc
) )
if(SYSTEM_NAME STREQUAL "FreeBSD") if(SYSTEM_NAME STREQUAL "FreeBSD")

View File

@ -89,7 +89,6 @@ set(TEST_SOURCES
${PROJECT_SOURCE_DIR}/src/admc/settings.cpp ${PROJECT_SOURCE_DIR}/src/admc/settings.cpp
${PROJECT_SOURCE_DIR}/src/admc/admc.qrc ${PROJECT_SOURCE_DIR}/src/admc/admc.qrc
${PROJECT_SOURCE_DIR}/translations/translations.qrc
) )
# NOTE: ADD ALL TESTS TO THIS LIST # NOTE: ADD ALL TESTS TO THIS LIST

View File

@ -1,33 +0,0 @@
find_package(Qt5 REQUIRED
COMPONENTS
Core # needed for some cmake macros
LinguistTools
)
set(TS_DIR ${PROJECT_SOURCE_DIR}/translations)
set(TS_FILES
${TS_DIR}/ru.ts
${TS_DIR}/en.ts
)
set(QM_FILES
${TS_DIR}/ru.qm
${TS_DIR}/en.qm
)
# Generate translation binaries (.qm) from sources (.ts)
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${TS_DIR})
qt5_add_translation(QM_FILES ${TS_FILES})
# NOTE: updating translations(.cpp -> .ts) is in a separate target so that it's not run every time source changes. When you do need to update translations, do `make update_translations`. *Generating* translations IS done every time (.ts -> .qm).
add_custom_target(update_translations
DEPENDS ${TS_FILES}
COMMAND ${Qt5_LUPDATE_EXECUTABLE} -recursive ${PROJECT_SOURCE_DIR}/src/admc -ts ${TS_FILES} -noobsolete
)
add_custom_target(translations
ALL
DEPENDS ${QM_FILES}
)

View File

@ -1,6 +0,0 @@
<RCC>
<qresource prefix="/translations/">
<file>ru.qm</file>
<file>en.qm</file>
</qresource>
</RCC>