embedded qm files into qrc file
This commit is contained in:
parent
68095700a2
commit
5535b6a6e3
5 changed files with 32 additions and 24 deletions
|
@ -50,29 +50,31 @@ endif()
|
||||||
|
|
||||||
qt6_add_resources(QRC ${QRC} ${CMAKE_CURRENT_LIST_DIR}/resources.qrc)
|
qt6_add_resources(QRC ${QRC} ${CMAKE_CURRENT_LIST_DIR}/resources.qrc)
|
||||||
|
|
||||||
set(AMNEZIAVPN_TR_FILES
|
# -- i18n begin
|
||||||
|
set(CMAKE_AUTORCC ON)
|
||||||
|
|
||||||
|
set(AMNEZIAVPN_TS_FILES
|
||||||
${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_ru.ts
|
${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_ru.ts
|
||||||
${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_zh_CN.ts
|
${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_zh_CN.ts
|
||||||
)
|
)
|
||||||
|
|
||||||
file(GLOB_RECURSE AMNEZIAVPN_TR_SOURCES *.qrc *.cpp *.h *.ui)
|
file(GLOB_RECURSE AMNEZIAVPN_TS_SOURCES *.qrc *.cpp *.h *.ui)
|
||||||
if ( BUILD_TRANSLATIONS )
|
|
||||||
qt_create_translation(AMNEZIAVPN_MESSAGES ${AMNEZIAVPN_TR_SOURCES} ${AMNEZIAVPN_TR_FILES})
|
|
||||||
qt_add_translation(AMNEZIAVPN_QM_FILES ${AMNEZIAVPN_TR_FILES})
|
|
||||||
add_custom_target(amnezia_messages DEPENDS ${AMNEZIAVPN_MESSAGES})
|
|
||||||
add_custom_target(amnezia_translations DEPENDS ${AMNEZIAVPN_QM_FILES} amnezia_messages)
|
|
||||||
add_dependencies(${PROJECT} amnezia_translations)
|
|
||||||
|
|
||||||
if (BUILD_TRANSLATIONS_AS_RESOURCES)
|
qt_create_translation(AMNEZIAVPN_QM_FILES ${AMNEZIAVPN_TS_SOURCES} ${AMNEZIAVPN_TS_FILES})
|
||||||
set(QM_FILE_LIST "")
|
#add_custom_target(amnezia_messages DEPENDS ${AMNEZIAVPN_MESSAGES})
|
||||||
foreach(FILE ${AMNEZIAVPN_QM_FILES})
|
#add_custom_target(amnezia_translations DEPENDS ${AMNEZIAVPN_QM_FILES} amnezia_messages)
|
||||||
list(APPEND QM_FILE_LIST "<file>${FILE}</file>")
|
#add_dependencies(${PROJECT} amnezia_translations)
|
||||||
endforeach()
|
|
||||||
string(REPLACE ";" "" QM_FILE_LIST ${QM_FILE_LIST})
|
set(QM_FILE_LIST "")
|
||||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/translations/translations.qrc ${CMAKE_CURRENT_LIST_DIR}/translations.qrc)
|
foreach(FILE ${AMNEZIAVPN_QM_FILES})
|
||||||
target_sources(${PROJECT} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/translations.qrc)
|
get_filename_component(QM_FILE_NAME ${FILE} NAME)
|
||||||
endif()
|
list(APPEND QM_FILE_LIST "<file>${QM_FILE_NAME}</file>")
|
||||||
endif( BUILD_TRANSLATIONS )
|
endforeach()
|
||||||
|
string(REPLACE ";" "" QM_FILE_LIST ${QM_FILE_LIST})
|
||||||
|
|
||||||
|
configure_file(${CMAKE_CURRENT_LIST_DIR}/translations/translations.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
||||||
|
qt6_add_resources(QRC ${I18NQRC} ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
||||||
|
# -- i18n end
|
||||||
|
|
||||||
if(IOS)
|
if(IOS)
|
||||||
#execute_process(COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/scripts/run-build-cloak.sh)
|
#execute_process(COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/scripts/run-build-cloak.sh)
|
||||||
|
@ -342,5 +344,5 @@ if(NOT IOS AND NOT ANDROID)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_sources(${PROJECT} PRIVATE ${SOURCES} ${HEADERS} ${RESOURCES} ${QRC})
|
target_sources(${PROJECT} PRIVATE ${SOURCES} ${HEADERS} ${RESOURCES} ${QRC} ${I18NQRC})
|
||||||
qt_finalize_target(${PROJECT})
|
qt_finalize_target(${PROJECT})
|
||||||
|
|
|
@ -227,15 +227,16 @@ void AmneziaApplication::loadTranslator()
|
||||||
|
|
||||||
void AmneziaApplication::updateTranslator(const QLocale &locale)
|
void AmneziaApplication::updateTranslator(const QLocale &locale)
|
||||||
{
|
{
|
||||||
QResource::registerResource(":/translations.qrc");
|
|
||||||
if (!m_translator->isEmpty()) {
|
if (!m_translator->isEmpty()) {
|
||||||
QCoreApplication::removeTranslator(m_translator.get());
|
QCoreApplication::removeTranslator(m_translator.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_settings->setAppLanguage(locale);
|
m_settings->setAppLanguage(locale);
|
||||||
|
|
||||||
QString strFileName = QString("amneziavpn")+QLatin1String("_")+locale.name()+".qm";
|
QString strFileName = QString(":/translations/amneziavpn")+QLatin1String("_")+locale.name()+".qm";
|
||||||
if (m_translator->load(strFileName, "../../../")) {
|
|
||||||
|
if (m_translator->load(strFileName)) {
|
||||||
|
qDebug() << "yyyyyyxxxxxxxx--------------" <<strFileName;
|
||||||
if (QCoreApplication::installTranslator(m_translator.get())) {
|
if (QCoreApplication::installTranslator(m_translator.get())) {
|
||||||
m_settings->setAppLanguage(locale);
|
m_settings->setAppLanguage(locale);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<context>
|
<context>
|
||||||
<name>AmneziaApplication</name>
|
<name>AmneziaApplication</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../amnezia_application.cpp" line="299"/>
|
<location filename="../amnezia_application.cpp" line="300"/>
|
||||||
<source>Split tunneling for WireGuard is not implemented, the option was disabled</source>
|
<source>Split tunneling for WireGuard is not implemented, the option was disabled</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<context>
|
<context>
|
||||||
<name>AmneziaApplication</name>
|
<name>AmneziaApplication</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../amnezia_application.cpp" line="299"/>
|
<location filename="../amnezia_application.cpp" line="300"/>
|
||||||
<source>Split tunneling for WireGuard is not implemented, the option was disabled</source>
|
<source>Split tunneling for WireGuard is not implemented, the option was disabled</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
5
client/translations/translations.qrc.in
Normal file
5
client/translations/translations.qrc.in
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<RCC>
|
||||||
|
<qresource prefix="/translations">
|
||||||
|
@QM_FILE_LIST@
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
Loading…
Add table
Add a link
Reference in a new issue