feat: add parameter to make the translation dynamic or not
This commit is contained in:
parent
0d4916d033
commit
1c3bbe1b8e
|
@ -172,7 +172,8 @@ DOS_API void DOS_CALL dos_qqmlapplicationengine_load_data(DosQQmlApplicationEngi
|
||||||
/// \brief Calls the load and install function for translations and calls retranslate on QQmlApplicationEngine
|
/// \brief Calls the load and install function for translations and calls retranslate on QQmlApplicationEngine
|
||||||
/// \param vptr The QQmlApplicationEngine
|
/// \param vptr The QQmlApplicationEngine
|
||||||
/// \param data The UTF-8 string of the path to the translation file (.qm)
|
/// \param data The UTF-8 string of the path to the translation file (.qm)
|
||||||
DOS_API void DOS_CALL dos_qapplication_load_translation(DosQQmlApplicationEngine *vptr, const char* translationPackage);
|
/// \param shouldRetranslate Should retranslate() be called after loading a translation
|
||||||
|
DOS_API void DOS_CALL dos_qapplication_load_translation(DosQQmlApplicationEngine *vptr, const char* translationPackage, bool shouldRetranslate);
|
||||||
|
|
||||||
/// \brief Calls the QQmlApplicationEngine::addImportPath function
|
/// \brief Calls the QQmlApplicationEngine::addImportPath function
|
||||||
/// \param vptr The QQmlApplicationEngine
|
/// \param vptr The QQmlApplicationEngine
|
||||||
|
|
|
@ -259,7 +259,7 @@ void dos_qqmlapplicationengine_load_data(::DosQQmlApplicationEngine *vptr, const
|
||||||
engine->loadData(data);
|
engine->loadData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dos_qapplication_load_translation(::DosQQmlApplicationEngine *vptr, const char* translationPackage)
|
void dos_qapplication_load_translation(::DosQQmlApplicationEngine *vptr, const char* translationPackage, bool shouldRetranslate)
|
||||||
{
|
{
|
||||||
if (!m_translator->isEmpty()) {
|
if (!m_translator->isEmpty()) {
|
||||||
QCoreApplication::removeTranslator(m_translator);
|
QCoreApplication::removeTranslator(m_translator);
|
||||||
|
@ -267,7 +267,7 @@ void dos_qapplication_load_translation(::DosQQmlApplicationEngine *vptr, const c
|
||||||
if (m_translator->load(translationPackage)) {
|
if (m_translator->load(translationPackage)) {
|
||||||
bool success = QCoreApplication::installTranslator(m_translator);
|
bool success = QCoreApplication::installTranslator(m_translator);
|
||||||
auto engine = static_cast<QQmlApplicationEngine *>(vptr);
|
auto engine = static_cast<QQmlApplicationEngine *>(vptr);
|
||||||
engine->retranslate();
|
if (shouldRetranslate) engine->retranslate();
|
||||||
} else {
|
} else {
|
||||||
printf("Failed to load translation file %s\n", translationPackage);
|
printf("Failed to load translation file %s\n", translationPackage);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue