fix(translator): Added layout direction reset on translation.

Fix #3542.
reviewable/pr3551/r1
Diadlo 2016-07-25 11:51:57 +03:00
parent 1c8a7e49c1
commit 927d512fa2
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
4 changed files with 36 additions and 1 deletions

View File

@ -55,7 +55,8 @@ void Translator::translate()
// system menu translation
QTranslator *qtTranslator = new QTranslator();
QString s_locale = "qt_"+locale;
if (qtTranslator->load(s_locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
QString location = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
if (qtTranslator->load(s_locale, location))
{
QApplication::installTranslator(qtTranslator);
qDebug() << "System translation loaded" << locale;
@ -72,6 +73,16 @@ void Translator::translate()
QCoreApplication::installTranslator(translator);
}
// After the language is changed from RTL to LTR, the layout direction isn't
// always restored
const QString direction = QApplication::tr("LTR",
"Translate this string to the string 'RTL' in"
" right-to-left languages (for example Hebrew and"
" Arabic) to get proper widget layout");
QGuiApplication::setLayoutDirection(
direction == "RTL" ? Qt::RightToLeft : Qt::LeftToRight);
for (auto pair : callbacks)
pair.second();
}

8
translations/ar.ts vendored
View File

@ -1934,6 +1934,14 @@ Share it with your friends to communicate.</source>
<translation>إسم الملف الشخصي &quot;%1&quot; موجود مسبقاً . هل تود إزاته؟</translation>
</message>
</context>
<context>
<name>QApplication</name>
<message>
<source>LTR</source>
<comment>Translate this string to the string &apos;RTL&apos; in right-to-left languages (for example Hebrew and Arabic) to get proper widget layout</comment>
<translation>RTL</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>

8
translations/he.ts vendored
View File

@ -1929,6 +1929,14 @@ Share it with your friends to communicate.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QApplication</name>
<message>
<source>LTR</source>
<comment>Translate this string to the string &apos;RTL&apos; in right-to-left languages (for example Hebrew and Arabic) to get proper widget layout</comment>
<translation>RTL</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>

8
translations/ug.ts vendored
View File

@ -1935,6 +1935,14 @@ Share it with your friends to communicate.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QApplication</name>
<message>
<source>LTR</source>
<comment>Translate this string to the string &apos;RTL&apos; in right-to-left languages (for example Hebrew and Arabic) to get proper widget layout</comment>
<translation>RTL</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>