Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-30471

Inconsistent translation when using disambiguation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • 5.4.0 RC
    • 4.8.4, 5.0.1
    • Core: Locales (i18n)
    • None
    • Windows

    Description

      The documentation of QTranslator::translate() says that it first tries to find the translation with the disambiguation and if it’s not found then the translator tries to find one with the disambiguation of “”.

      Having a source text that is not translated with disambiguation and the same text that is translated with different disambiguation will result the translated text to be used in both cases. Adding the same text translated with again different disambiguation will result inconsistent translation. So if these are defined in the code:

      ui->label_3->setText(tr("label", "don't use this!"));
      ui->label->setText(tr("label", "first label"));
      ui->label_2->setText(tr("label", "second label"));
      

      And the text for label_3 and label is translated. Then checking with QApplication::translate() we have inconsistent translation:

      const char *name("MainWindow");
      const char *text("label");
      const char *disambiguation("second label");
      qDebug() << qApp->translate(name, text, disambiguation);
      const char *no_disambiguation("");
      qDebug() << qApp->translate(name, text, no_disambiguation);
      

      The first debug will output the translation for ‘label’ and the second debug will output the translation for ‘label_3’. Based on the documentation these should be the same (http://qt-project.org/doc/qt-5.0/qtcore/qtranslator.html#translate).

      On the other hand if there is a text that isn’t translated without the disambiguation and that is used with the same text that isn’t translated but has disambiguation and then there is the same text with translation and disambiguation, then you will have the translation right for one text and others will have the source text. Which based on the documentation sounds right.

      Attached also an application that shows all the above cases.

      Attachments

        For Gerrit Dashboard: QTBUG-30471
        # Subject Branch Project Status CR V

        Activity

          People

            kkohne Kai Köhne
            qtcomsupport Qt Support
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes