diff --git a/src/widget/translator.cpp b/src/widget/translator.cpp index 83125b674..8cf488f69 100644 --- a/src/widget/translator.cpp +++ b/src/widget/translator.cpp @@ -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(); } diff --git a/translations/ar.ts b/translations/ar.ts index 255a2f475..25558dcec 100644 --- a/translations/ar.ts +++ b/translations/ar.ts @@ -1934,6 +1934,14 @@ Share it with your friends to communicate. إسم الملف الشخصي "%1" موجود مسبقاً . هل تود إزاته؟ + + QApplication + + LTR + Translate this string to the string 'RTL' in right-to-left languages (for example Hebrew and Arabic) to get proper widget layout + RTL + + QObject diff --git a/translations/he.ts b/translations/he.ts index ab0d2ec7e..753f485b0 100644 --- a/translations/he.ts +++ b/translations/he.ts @@ -1929,6 +1929,14 @@ Share it with your friends to communicate. + + QApplication + + LTR + Translate this string to the string 'RTL' in right-to-left languages (for example Hebrew and Arabic) to get proper widget layout + RTL + + QObject diff --git a/translations/ug.ts b/translations/ug.ts index 4dd508f3d..4157409c1 100644 --- a/translations/ug.ts +++ b/translations/ug.ts @@ -1935,6 +1935,14 @@ Share it with your friends to communicate. + + QApplication + + LTR + Translate this string to the string 'RTL' in right-to-left languages (for example Hebrew and Arabic) to get proper widget layout + RTL + + QObject