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's bcp47Name() behavior
Qt 6.11 is out! See what's new in the release blog

QLocale's bcp47Name() behavior

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 3.5k 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.
  • P Offline
    P Offline
    panosk
    wrote on last edited by
    #1

    Hello,

    I'm trying to use "QLocale::bcp47Name()":http://qt-project.org/doc/qt-5.0/qtcore/qlocale.html#bcp47Name in order to get the dash separated codes for language and country, for example "en-US". No matter how I construct the locale, I always get only the language code:

    @
    QLocale locale(QLocale::English,QLocale::UnitedStates);
    qDebug() << locale.bcp47Name(); //prints "en"
    @

    Am I missing something?

    Thanks.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What version of Qt are you using ?
      What OS are you running ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        Linux 64-bit
        Qt 4.8.5 (self-built) outputs "en-US"
        Qt 5.1.0 or 5.1.1 (official binaries) outputs "en"

        However, if I substitute QLocale::Australia or QLocale::Jamaica then the Qt5 output becomes "en-AU" or "en-JM" as expected. Perhaps there is some (annoying) default to US English going on here.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          IIRC, there's ICU that is used in Qt 5 that can explain this

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P Offline
            P Offline
            panosk
            wrote on last edited by
            #5

            Right now I'm using Qt5.2 beta on OS X 10.9, but soon I'll have access to other OS /Qt combinations.

            @ChrisW67: This weird behavior is the same for all languages with default country. Try Spanish with Unites States and then with Spain, or Greek with Greece and then with Cyprus.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ChrisW67
              wrote on last edited by
              #6

              The United States is hardly the home country of English ;)

              1 Reply Last reply
              0
              • P Offline
                P Offline
                panosk
                wrote on last edited by
                #7

                [quote author="ChrisW67" date="1384490196"]The United States is hardly the home country of English ;)[/quote]

                Very true, but still Qt thinks different :-) QLocale::UnitedKingdom outputs "en-GB".

                So, should I report this as a bug?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  I think you can yes, don't forget to post the link to the report here so others may follow it :-)

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    panosk
                    wrote on last edited by
                    #9

                    Done :-)

                    "https://bugreports.qt-project.org/browse/QTBUG-34872":https://bugreports.qt-project.org/browse/QTBUG-34872

                    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