Unsolved i18n, translation failed, when use QObject::tr to global QString...
-
how to translate QString when it's global, eg.
const QString xxx[] =
{ QObject::tr("test"),
QObject::tr("test"),
}it did appears in Liguist and i did translate it, but not work in app.
thank you! -
@opengpu2
have you installed a translator loading your translation file? -
@raven-worx of course i did. the tr("") QString in a Class which is derived from QObject and have Q_OBJECT marco in the header works fine...
but the global did not work... -
@opengpu2
then the global variable gets initialized before you install the translator.
When a new translator gets installed all tr() calls need to be reevaluated, means need to get called again.
Actually you need to listen to a QEvent::LanguageChange event (on the QApplication itself IIRC) and then update the values again.It probably works in a QObject class because you instantiate the class after you installed the translator?