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. Extra characters from .toLocaleCurrencyString()
Qt 6.11 is out! See what's new in the release blog

Extra characters from .toLocaleCurrencyString()

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

    Hi,

    I'm working on a QML application that needs to display prices in various languages. When someone chooses a language, I use qsTr() to translate text strings, which works great. When I go to display prices, I want to use the .toLocaleCurrencyString() feature, but it's doing something confusing:

    If I want to display in US English, I can say:

    priceButton.text = qsTr("Regular (%1)").arg(Number(5.0).toLocaleCurrencyString(Qt.locale("en_US")))
    

    ... and I get a properly formatted "$5.00" ... so far so good. If I want to display in Greek, I can say

    priceButton.text = qsTr("Regular (%1)").arg(Number(5.0).toLocaleCurrencyString(Qt.locale("el_GR")))
    

    ... and I get "5,00 €" ... also good. Likewise French: with "fr_FR" I see the same "5,00 €". Now what about Canada? I say

    priceButton.text = qsTr("Regular (%1)").arg(Number(5.0).toLocaleCurrencyString(Qt.locale("fr_CA")))
    

    ... now I see "5,00 k$". Same with es_US: I get "5.00 K $" ... even es_MX gives me "5,00 k$" (same as fr_CA, not es_US)

    Does anyone know where this extra character might be coming from? Do I have the wrong language codes or 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 ?
      On what platform ?

      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
      • E Offline
        E Offline
        Elliott
        wrote on last edited by
        #3

        Hi, sorry, this should have been in the original post!

        The application is running on CentOS 7 Linux. The Qt version is 5.9.7 but I'm also playing with the 5.12.0 beta and the behavior is the same in both.

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

          Can you provide a complete minimal compilable example that shows that behaviour ?

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

          E 1 Reply Last reply
          0
          • SGaistS SGaist

            Can you provide a complete minimal compilable example that shows that behaviour ?

            E Offline
            E Offline
            Elliott
            wrote on last edited by
            #5

            @SGaist Hi, thanks for your response; I'm in the midst of a software release deadline at the moment but I will get back to this in a day or two! Thank you again

            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