[SOLVED]: how to print our language direction
-
Hello guys,
i want to print the writing direction associated to a given language as a string
Case 1: workings well
This code outputs the direction =1 for language arabic associated to country Egypt
@
QLocale x(QLocale::Arabic, QLocale::Egypt);
qDebug() << xy << x.textDirection();
@Case 2: if GuiLanguage="Arabic", code outputs 0 .. where is my mistake?
@
QString xy= "QLocale::" + GuiLanguage + ", QLocale::Egypt";
QLocale x(qPrintable(xy));
qDebug() << xy << x.textDirection();
@ -
Please read "the documentation":http://qt-project.org/doc/qt-4.8/qlocale.html#QLocale-2. You are using the QLocale's QString constructor as if it was the same one you have used in the first example. This is wrong. C++ is not an interpreted meta-language ;) You could do the second thing with macros, though. Or, in a more decent way, construct the locale name by QString so that it conforms to the format that QLocale expects.
-
it is not clear to me, could you please give me an example how you would do it?
I know this way, but i want to change the word "Arabic" into "ar_ar" and can not do it@
QString ab="Ar_ar";
QLocale x(ab);
qDebug() << "direction" << x.textDirection();
@Solved it using this method ..
-
Hi,
This
@
"QLocale::" + GuiLanguage + ", QLocale::Egypt"
@
in your case 2 is not the same as:
@
QLocale::Arabic, QLocale::Egypt
@
It might read the same for you, but the compiler sees first a constructor to create a QLocal with the Language/Country enums set, The second one tries to create a QLocal with a given string. So the string should match the thing you need. So the Ar_ar will be Arabic indeed.
Place [SOLVED] at your first post to stop us from reading please.