Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]: how to print our language direction
QtWS25 Last Chance

[SOLVED]: how to print our language direction

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SherifOmran
    wrote on last edited by
    #1

    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();
    @

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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.

      (Z(:^

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SherifOmran
        wrote on last edited by
        #3

        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 ..

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

          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.

          Greetz, Jeroen

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved