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().toString in french canadian
Forum Updated to NodeBB v4.3 + New Features

QLocale().toString in french canadian

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.6k 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.
  • M Offline
    M Offline
    Mwoua
    wrote on last edited by
    #1

    Hello,
    i'm translating my app and trying to display number in the locale of the user. So I use

    QLocale().toString( aValue, 'f', mDecimals )

    If the locale is
    QLocale( QLocale::French, QLocale::France ) the numbers are displayed correctly ( colon before the decimals), however, its the locale is QLocale( QLocale::French, QLocale::Canada), the numbers are displayed using english settings. Is this a bug or am I misusing the toString function?

    Thanks

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

      Hi,

      Can you show how you create the QLocale object and use the numbers with 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
      • M Offline
        M Offline
        Mwoua
        wrote on last edited by Mwoua
        #3

        Hi, I keep the default locale, so its just like the example in my previous post (aValue is a float or a double) :

        QLocale().toString( aValue, 'f', mDecimals )
        

        or

        QLocale().toString( aValue )
        

        Right now, i'm using this as a workaround :

        if( QLocale().language() == QLocale::French )
        {
            QLocale lLocale = QLocale( QLocale::French, QLocale::France ) ;
            QLocale::setDefault( lLocale );
        }
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I have twice the same result when doing:

          qDebug() << QLocale(QLocale::French, QLocale::France).toString(12.21, 'f', 3);
          qDebug() << QLocale(QLocale::French, QLocale::Canada).toString(12.21, 'f', 3);
          

          return the same output.

          What exact version of Qt, OS and compiler are you using ?

          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
          • M Offline
            M Offline
            Mwoua
            wrote on last edited by Mwoua
            #5

            Sorry for the delay, I was in hollyday.

            Qt5.7, windows 7, msvc 2013

            EDIT :
            I did a bit more testing.

            qDebug() << QLocale(QLocale::French, QLocale::France).toString(12.21, 'f', 3);
            qDebug() << QLocale(QLocale::French, QLocale::Canada).toString(12.21, 'f', 3);

            Works fine.

            However,

            auto a = QLocale().countryToString( QLocale().country() ); //Canada
            auto b = QLocale().languageToString( QLocale().language() ); //French
            QLocale().toString( 6.3, 'f', 1 ); // => 6.3
            

            Doesnt work and

            auto a = QLocale().countryToString( QLocale().country() ); //France
            auto b = QLocale().languageToString( QLocale().language() ); //French
            QLocale().toString( 6.3, 'f', 1 ); // => 6,3
            

            works correctly

            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