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. Date formatting with Translations.

Date formatting with Translations.

Scheduled Pinned Locked Moved Unsolved General and Desktop
javascriptqdatei18n
1 Posts 1 Posters 1.1k Views
  • 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
    EStudley
    wrote on last edited by
    #1

    I'm trying to make a translatable date string. In "en" languages the date will be displayed "MM/dd/yyyy" and in others it will be displayed as "dd/MM/yyyy".

    I currently use this to translate the date string:

    dateTime.toLocaleDateString(Qt.locale("en_EN"), "MM/dd/yyyy").
    

    I've added it to the translations by turning it into this:

    qsTr("%1").arg(dateTime.toLocaleDateString(Qt.locale()))
    

    How can I make it show as "dd/MM/yyyy"? If I specify

    qsTr("%1").arg(dateTime.toLocaleDateString(Qt.locale(), "MM/dd/yyyy"))
    

    The output is always in that format, even in English. How can I get simply MM/dd/yyyy while being translatable?

    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