Qt Localization

Qt Linguist is a tool provided by Qt to support the i18n process for Qt based applications. Qt TS is the resource file format to externalize your translations.

Format

  • the file format is based on XML

  • the attribute “language” of the <TS> node has to be given and must specify the target locale used in this file using ISO 639-1 (it is allowed to use “_” as region separator, eg. “en_US”)

  • the “language” attribute will be used by LingoHub to determine the language of the translations in the file

  • if there is a locale in the filename, this information won’t be used

  • every message element will result in a segment in LingoHub

  • the <source> attribute will be used as translation title

  • if <message> is grouped inside <context>, the <name> element value will prefix the translation title. So a <source> value has to be unique in its context.

  • the <translation> element holds the content of the segment and is understood as translation for the language specified by the “language” attribute in the root node

  • the content of <comment> attributes will be imported as description for the translation

  • <location> elements will be stored by LingoHub and exported as imported

  • placeholders are specified by “%” followed by a number, eg.: “%1”

Example

Additional example files can be accessed here.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="de_DE">
<context>
    <name>Page</name>
    <message>
        <source>Translations Example</source>
        <translation>Beispiel für Übersetzungen</translation>
    </message>
    <message>
        <source>Hello %1</source>
        <translation>Hallo %1</translation>
    </message>
</context>
<context>
    <name>installscript</name>
    <message>
        <location filename="../views/public.ui" line="36"/>
        <source>This is a dynamically created page.</source>
        <translation>Diese Seite wurde dynamisch erzeugt.</translation>
    </message>
</context>
</TS>

References

Last updated