RTL menu support
Open, NormalPublic

Description

Hello,

It seems RTL does not work as far as menu goes in many KDE applications. It appears for this to work, qtbase_ar.qm needs to be available which does not exist right now. The qtbase_qr.am file contains QT_LAYOUT_DIRECTION string which if translated to "RTL" then the application will automatically set that as the current layout. For now, I added a specific hack to KStars to make RTL layout direction work for Arabic. i.e.:

if (i18n("Sky") == "السماء")

qApp->setLayoutDirection(Qt::RightToLeft);

What's the long term solution for this? I tried with Kate, and its menu are still LTR when Arabic is selected.

Sorry but I don't get what you mean.
Are you talking about Windows version, or Linux version?
Everything works as it should here on ArchLinux, with Qt5.9 translations installed.
I didn't try KStars, but it should work correctly as other Qt and KF5 applications.

On Linux, MacOS, and Windows. I just installed the qttranslations5-l10n from Ubuntu (I'm on KDE Neon) and it's missing qtbase_ar.qm file, but I also checked Qt itself (http://l10n-files.qt.io/l10n-files/) and there is no translations for qtbase_ar in 5.9. If you check the 5.6 version here:

http://l10n-files.qt.io/l10n-files/qt5-old/qtbase_ar.ts

Even though it's not translated at all, but it has this:

<context>

<name>QGuiApplication</name>
<message>
    <location filename="../../qtbase/src/gui/kernel/qguiapplication.cpp" line="+206"/>
    <source>QT_LAYOUT_DIRECTION</source>
    <comment>Translate this string to the string &apos;LTR&apos; in left-to-right languages or to &apos;RTL&apos; in right-to-left languages (such as Hebrew and Arabic) to get proper widget layout.</comment>
    <translation type="unfinished">RTL</translation>
</message>

</context>

And this is what Qt application uses to detect the the layout, it's set for RTL above which would work for Qt 5.6, but this file is missing for Qt 5.9

Just to re-iterate. I am talking about MENUs (and the whole app) being Right-To-Left. Currently, the translations work fine, but RTL is not applied. Check attached image for Kate.

Yes I know it's missing qtbase_ar, but it has qt_ar, which (if you notice) is bigger than the other qt_* files, because it is still in the old structure.
If you check the file in Qt translations repo, you'll see that special string used for mirroring, and it's "finished" so is being used.

Maybe it's a diffrent problem, because it is working correctly here, and in Ubuntu and Fedora as well.

P.S.: I did finish translating qtbase file, but still waiting for reviewing, and noticed that the mirroring stopped working, even though that string is there and translated correctly.

safaalfulaij added a comment.EditedSep 22 2017, 11:02 AM

KDE Frameworks 5.37.0
Qt 5.9.1 (built against 5.9.1)
The xcb windowing system

And here we can make sure that Qt translations are being used (some of the keyboard keys are translated, fixed in the new translation I sent, but it's a good way to test these stuff now):

Well, it's definitely not working on KDE Neon, which is essentially Ubuntu 16.04 with all the latest bleeding-edge KDE packages. The hack I added now works fine, but I'd like to remove it once this gets sorted out.

Are you using a LTR locale, and the application is RTL?
If that's the case, then it's not a bug we can fix, since all Qt apps behave this way, and should be fixed upstream.

Oh yeah that's what I'm doing.. so this is why! Ok, is there any bug upstream you're aware of that I can follow with?

I don't think there is, but there is one review that had this sort of talk, here, and this for Qt5 not mirroring the layout.

Hi Mutlaq,
Can you use this function instead of the one you used? I think it's more general and should allow other locales (like Persian or Hebrew) to have a correct layout in system with a LTR layout.

Did you file a bug in Qt? :)

yaron added a subscriber: yaron.Oct 11 2021, 9:07 AM