QT Linguist (.ts) file format is an XML-based format used by the Qt framework to manage and store translations for internationalization (i18n) and localization (l10n) of applications. It allows developers to easily translate application strings into multiple languages, making software globally accessible. The .ts files can be edited with Qt Linguist, a tool that simplifies the process of translation. By utilizing the .ts format, developers can ensure efficient management of multilingual content, localization workflows, and improve the user experience across different regions and languages.
File format example
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="pl">
<context>
<name>AboutPage</name>
<message>
<source>Author</source>
<translation>Autor</translation>
</message>
<message>
<source>Website</source>
<translation>Strona WWW</translation>
</message>
<message>
<source>Version</source>
<translation>Wersja</translation>
</message>
<message>
<source>Found %n files</source>
<translation>
<numerusform>Znaleziono %n plik</numerusform>
<numerusform>Znaleziono %n pliki</numerusform>
<numerusform>Znaleziono %n plików</numerusform>
</translation>
</message>
</context>
</TS>
Contexts
Contexts are used to group translations that are related to a specific part of the application.
They help translators understand the context in which the translation will be used, making it easier to provide accurate translations.
In the example above, the context is AboutPage
, which groups translations related to the about page of the application.
In SimpleLocalize, contexts are represented as namespaces, which allow you to organize translations into logical groups.
Pluralization and variables
QT Linguist supports pluralization and variables in translations, allowing developers to create dynamic and context-aware translations. SimpleLocalize supports these features, making it easy to manage and translate complex strings.
<message>
<source>Found %n files</source>
<translation>
<numerusform>Znaleziono %n plik</numerusform>
<numerusform>Znaleziono %n pliki</numerusform>
<numerusform>Znaleziono %n plików</numerusform>
</translation>
</message>
In the example above, the %n
variable is used to represent the number of files found.
The translation contains three different forms based on the value of %n
, allowing for accurate pluralization in different languages.
SimpleLocalize will automatically create one translation key with multiple plural forms based on the ICU message syntax.
Learn more about ICU message syntax or use our ICU syntax playground to learn how to create complex pluralization and variable translations.
Upload and download translation files
Use the SimpleLocalize CLI to upload and download translations in the QT Linguist format.
Use qt-linguist
as the format argument, provide the path to the translation file and the language key for upload.
Upload source translations in QT Linguist format
simplelocalize upload --apiKey <PROJECT_KEY> \
--format qt-linguist \
--languageKey en \
--path ./translations.ts
Learn more about uploading translations with CLI.
Download translations to QT Linguist format
simplelocalize download --apiKey <PROJECT_KEY> \
--format qt-linguist \
--path ./translations_{lang}.ts
Learn more about downloading translations with CLI.