[Development] Grouping Support for ID-Based Translations in Qt Linguis

Masoud Jami masoud.jami at qt.io
Thu Mar 27 16:24:51 CET 2025


Hi,

As we're seeing interest from users in using ID-based translation in their 
projects, we’re discussing ways to enhance ID-based translation support in 
Qt Linguist. In particular, how translations are presented and managed in large 
projects.
Currently, when a translation file with ID-based translations is opened in 
Qt Linguist, all entries appear as a single long list under <unnamed context>. 
If a project is large enough and contains many translations, it becomes 
difficult to navigate and organize them effectively. In this regard, there has 
also been a suggestion/discussion under QTBUG-43540.

To address this, we are working on a feature that brings grouping capability 
for ID-based translations.
Here’s the idea we’re working on:

- Users can assign a translation to a group as follows:

    //% "source text"
    //@ group1
    qtTrId("msgid");

- When lupdate is called on the source code, the following message is
  written to the TS file:

    <message id="msgid">
        <source>source text</source>
        <group>group1</group>
        <translation type="unfinished"></translation>
    </message>

- Now, when the TS file is opened in Qt Linguist, the ID-based translations
  are grouped according to their group names (similar to how text-based
  translations are grouped by contexts).

- Messages without a group will be listed under <unnamed group>.

Note: IDs remain unique project-wide, and ID-based messages can still be 
uniquely addressed using only their IDs, and they do not require a group name 
for this purpose. Group names are solely for presentation in Qt Linguist. This 
is different from text-based translation, where a translation needs both a 
context and source text (and sometimes also a disambiguating comment) to be 
uniquely identified.

There are still some open questions, and I would welcome any
suggestions to refine the idea:

- Should a message be allowed to have multiple groups? Or should each
  message be assigned only one group? If multiple groups are allowed,
  how should they be represented in Qt Linguist? Would such messages
  appear multiple times (once under each group), all pointing to the
  same translation?
- Thoughout this email, I have used the term "group" to explain this feature, 
  but we are considering different alternative terms that might describe 
  the feature:
  1. group
  2. label
  3. tag
  4. Other suggestions?

We also plan to discuss this further at the Qt Contributor Summit, but
I would appreciate any opinions or suggestions before then.

Best regards,
Masoud



More information about the Development mailing list