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. QLocale::system()
Forum Updated to NodeBB v4.3 + New Features

QLocale::system()

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 565 Views 1 Watching
  • 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.
  • G Offline
    G Offline
    Gayatri Kulkarni
    wrote on last edited by
    #1

    Hello,
    I am using following piese of code to read the system locale language and country
    QStringList list = QLocale::system().name.split("_");

    foreach(QString language, list)
    cout << language << endl;

    If I set the system language, Norwegian or Serbian, I get the locale as en_US only.
    For all other languages, it works well, I get correct output. For example, for German I get de_DE.

    What might be the reason for this?

    Pl45m4P 1 Reply Last reply
    0
    • G Gayatri Kulkarni

      Hello,
      I am using following piese of code to read the system locale language and country
      QStringList list = QLocale::system().name.split("_");

      foreach(QString language, list)
      cout << language << endl;

      If I set the system language, Norwegian or Serbian, I get the locale as en_US only.
      For all other languages, it works well, I get correct output. For example, for German I get de_DE.

      What might be the reason for this?

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @Gayatri-Kulkarni said in QLocale::system():

      QStringList list = QLocale::system().name.split("_");
      foreach(QString language, list)
      cout << language << endl;

      There is no need to do that. You can get the country from QLocale by using this:
      https://doc.qt.io/qt-5/qlocale.html#countryToString

      @Gayatri-Kulkarni said in QLocale::system():

      If I set the system language, Norwegian or Serbian, I get the locale as en_US only.

      Check how Norwegian is detected in your app

      If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()).
      (https://doc.qt.io/qt-5/qlocale.html#details)

      This is what probably happens


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      G 1 Reply Last reply
      4
      • Pl45m4P Pl45m4

        @Gayatri-Kulkarni said in QLocale::system():

        QStringList list = QLocale::system().name.split("_");
        foreach(QString language, list)
        cout << language << endl;

        There is no need to do that. You can get the country from QLocale by using this:
        https://doc.qt.io/qt-5/qlocale.html#countryToString

        @Gayatri-Kulkarni said in QLocale::system():

        If I set the system language, Norwegian or Serbian, I get the locale as en_US only.

        Check how Norwegian is detected in your app

        If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()).
        (https://doc.qt.io/qt-5/qlocale.html#details)

        This is what probably happens

        G Offline
        G Offline
        Gayatri Kulkarni
        wrote on last edited by
        #3

        @Pl45m4 said in QLocale::system():

        Check how Norwegian is detected in your app

        Sorry, I do not understand:
        Check how Norwegian is detected in your app

        Could you please elaborate?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          Gayatri Kulkarni
          wrote on last edited by
          #4

          @dheerendra , could you please provide your feedback on this issue?

          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