TS File

Qt uses TS files for automatic translations​.

Qt TS (Translation Source) files are XML files which are used by the Qt Linguist application. They also get used to provide automatic translations for Qt applications.

This format behaves slightly differently from most other formats to ensure compatibility with GL Strings.

  1. IDs

    When importing a TS file, IDs will be automatically generated following this pattern:
    contextName$@SourceHash{$@CommentHash}[pluralisationType]

    Note:

    • CommentHash is only present if there are 2 or more messages in the same context with the same source field attribute.
    • pluralisationType is only included for plural messages.
    • $@ is used as a delimiter in generated IDs. To prevent errors, avoid including $@ in your contextName values.
    • If you change the Source/Comment value in your application and import the TS file again, it will create a new entry on the dashboard because the SourceHash/CommentHash will have changed.
  2. Pluralisation

    All supported pluralisation types can be included in the Qt TS export, but some may not be present in your export file, since Qt files apply special pluralisation rules for many languages.

    Example:

    • For Arabic (ar) export, all pluralisations are present in the file [zero,one,two,few,many,other].
    • For Japanese (ja) export, only one pluralisation type is present [other].

    Qt uses 17 pluralisation styles, most of which are documented here.

  3. Meta Attributes

    After you import a TS file, your Project will have the following meta attributes:

    • ApplangaIDContext
    • ApplangaIDSource

    Don't manually edit these atrributes or the strings IDs.

You can either import and export your TS files manually on the dashboard or you can automate your TS file translation process with the GL Strings Localization CLI.

Specification Value
File Extension .ts
CLI Format Key qt_ts
CLI Supported true
SDK Supported false
String Description Supported true
Pluralization Supported true

Example:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="de">
<context>
    <name>UiContext</name>
    <message>
        <source>Name</source>
        <comment>An example entry for Name</comment>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <source>This is just a Sample</source>
        <translation>Dies ist nur ein Beispiel</translation>
    </message>
</context>
<context>
    <name>CodeContext</name>
    <message>
        <source>I am a message in which was written in Code</source>
        <translation type="unfinished"></translation>
    </message>
</context>
</TS>