Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. tr() not working only for three strings
Forum Updated to NodeBB v4.3 + New Features

tr() not working only for three strings

Scheduled Pinned Locked Moved Unsolved Qt 6
3 Posts 2 Posters 528 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.
  • jager012J Offline
    jager012J Offline
    jager012
    wrote on last edited by
    #1

    I am adding localization support to my application (QtWidgets). Everything is working out of the box, except for these three lines. This snippet is from my dialog constructor and all the other lines in the dialog are being translated correctly.

    // WORKING
        ui->minimizeAction->addItem(tr("Minimize to system tray"), QVariant::fromValue(Settings::Action::MinimizeToSystemTray));
        ui->minimizeAction->addItem(tr("Minimize to taskbar"), QVariant::fromValue(Settings::Action::MinimizeToTaskbar));
    
    // NOT WORKING
        ui->downloadLocation->addItem(tr("Default (%1)").arg(QWebEngineProfile::defaultProfile()->downloadPath()));
        ui->downloadLocation->addItem(tr("Ask everytime"));
        ui->downloadLocation->addItem(tr("Custom"));
    

    There are also another tr("Custom (%1)") that isn't getting translated. It's like every string that goes inside the downloadLocation combobox isn't getting translated, despite it being no different than the other comboboxes in the app. I've tried cleaning, rebuilding, verifying the .ts file manually, but with no results. Could someone please help me?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Are you sure you don't fill the combobox somewhere else again or calling a retranslateUi somewhere? Strip down your code until they get translated.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      jager012J 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        Are you sure you don't fill the combobox somewhere else again or calling a retranslateUi somewhere? Strip down your code until they get translated.

        jager012J Offline
        jager012J Offline
        jager012
        wrote on last edited by jager012
        #3

        @Christian-Ehrlicher The combobox is updated by some signal handlers, but not without user interaction, and even there the strings should be localized.
        However, I've noticed that the issue happens on Manjaro Linux with Qt6.4.0 installed from the repos. Tried building on macOS with manually downloaded Qt6.4.1 and the strings are being translated correctly. Will try on Windows as soon as I can. Could it be some oscure bug of 6.4.0 or Linux platform? There don't seem to be differences between the compiled .qm files on both platforms

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved