Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

Extra characters from .toLocaleCurrencyString()



  • 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!


  • Lifetime Qt Champion

    Hi,

    What version of Qt are you using ?
    On what platform ?



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


  • Lifetime Qt Champion

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



  • @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


Log in to reply