in my app I need internationalization. Say I have created several .ts file for different languages e.g., German, French, etc. - together with translated phrases.
Now, say the user wants to change the language at run time. Will it not be possible using Qt approach?
The function QQmlEngine::retranslate introduced in Qt 5.10 simply reevaluates all property bindings. This includes all the bindings with a call to qsTr() on the right-hand side.
void Settings::switchToLanguage(const QString &language)
{
if (!m_translator.isEmpty())
QCoreApplication::removeTranslator(&m_translator);
m_translator.load(QStringLiteral(":/language_") + language));
QCoreApplication::installTranslator(&m_translator));
m_engine->retranslate();
}
For more detail you can check this post too.