Has anyone managed to determine the correct direction of the location (from left to right and from right to left) from the user's language settings?
I'm having trouble localizing the app in Arabic (Saudi Arabia). Detecting the current locale, downloading and installing the appropriate QTranslators works fine. (The text looks great on Linux!) I have a problem in that the direction of the global layout is not determined from the locale of the system.
Documentation for QApplication :: layoutDirection states (with my main points):
This property contains the default layout direction for this application. When the system starts, the default layout direction depends on the language of the application.
However, this does not happen: the layout is set to Qt :: LeftToRight regardless of the locale's system standard. I made a test program that displays the problem. Its main function:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTranslator translator;
translator.load(":/layoutDirection.qm");
a.installTranslator(&translator);
Window w;
w.show();
return a.exec();
}
There is also a resource file containing the necessary images and translation files. This is defined as follows:
<RCC>
<qresource prefix="/" lang="ar">
<file alias="arrow.png">images/arrow-rtl.png</file>
<file alias="layoutDirection.qm">translations/layoutDirection_ar.qm</file>
</qresource>
<qresource prefix="/" lang="en">
<file alias="arrow.png">images/arrow-ltr.png</file>
<file alias="layoutDirection.qm">translations/layoutDirection_en.qm</file>
</qresource>
</RCC>
The source code for the Window class is trivial, and the corresponding .ui file does not set layoutDirection for any widget. When launched in English (USA), the window looks like this:

and when launched in Arabic (Saudi Arabia) it looks like this:

, , , , . : .
. , Google. , .
, QApplication. Qt :
Qt , , . qttranslations.
QApplication :
static bool qt_detectRTLLanguage()
{
return force_reverse ^
(QGuiApplication::tr("QT_LAYOUT_DIRECTION",
"Translate this string to the string 'LTR' in left-to-right"
" languages or to 'RTL' in right-to-left languages (such as Hebrew"
" and Arabic) to get proper widget layout.") == QLatin1String("RTL"));
}
"QT_LAYOUT_DIRECTION" , , :
