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

All needed translation resources are merged in a single unnamed context

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P3: Somewhat important
    • None
    • 4.7.1
    • Tools: Linguist
    • None
    • Windows

    Description

      If you open an xlf file with multiple <file> entries in Qt Linguist, you'll get all needed translation resources merged in a single unnamed context. However each group of resources within the same <file> should be split into different named contexts (where each name equals value of "original" attribute of <file> entry).

      Example xliff file:

      <xliff version='1.2' xmlns='urn:oasis:names:tc:xliff:document:1.2'>
      <file original='first.txt' source-language='en' target-language='ru' datatype='plaintext'>
      <body>
      <trans-unit id="1" xml:space="preserve">
      <source xml:lang="en-us">First String</source>
      <target xml:lang="ru-ru"></target>
      </trans-unit>
      </body>
      </file>
      
      <file original='second.txt' source-language='en' target-language='ru' datatype='plaintext'>
      <body>
      <trans-unit id="2" xml:space="preserve">
      <source xml:lang="en-us">Second String</source>
      <target xml:lang="ru-ru"></target>
      </trans-unit>
      </body>
      </file>
      
      </xliff>
      

      The following patch fixes the problem:

      --- a/tools/linguist/shared/xliff.cpp
      +++ b/tools/linguist/shared/xliff.cpp
      @@ -700,11 +700,13 @@ bool XLIFFHandler::finalizeMessage(bool isPlural)
           if (m_type == TranslatorMessage::Obsolete && m_refs.size() == 1
               && m_refs.at(0).fileName() == QLatin1String(MAGIC_OBSOLETE_REFERENCE))
               m_refs.clear();
      -    TranslatorMessage msg(m_context, m_sources[0],
      +    QString msgContext = m_context.isEmpty() ? m_fileName : m_context;
      +    TranslatorMessage msg(msgContext, m_sources[0],
                                 m_comment, QString(), QString(), -1,
                                 m_translations, m_type, isPlural);
           msg.setId(m_id);
           msg.setReferences(m_refs);
           msg.setOldComment(m_oldComment);
           msg.setExtraComment(m_extraComment);
           msg.setTranslatorComment(m_translatorComment);
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            buddenha Oswald Buddenhagen
            naevdal Sigrid Fjell Nævdal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes