Translating

Stefan Löffler edited this page Mar 11, 2016 · 3 revisions

Summary

TeXworks uses the standard Qt mechanisms to support translating the user interface into other languages than the default (built-in) English. This page is intended to help translators get started. For more details, see the Qt Linguist documentation (included in Qt Assistant), which you should have if you've installed a current version of Qt.

In brief, to provide a translation for a particular language, you need to

  • use the lupdate tool to create .ts files for TeXworks itself and the QtPDF library; .ts files are XML files containing all the text strings from the user interface;
  • use Linguist to edit these files, adding the translation for each string;
  • use Linguist or lrelease to compile the .ts files into .qm files that can be loaded at runtime; and
  • put the .qm files into the TeXworks translations folder.

A little more detail

Translation files are named with a two-letter language code such as "de" (German), "fr" (French), etc., following the conventions for locale names. A country code can be added where there are variations between different languages (e.g., "en_US" versus "en_GB"), but in most cases it should not be necessary to make such distinctions.

In the TeXworks source code, translations live in several directories:

  • trans contains the translations belonging to the core of TeXworks
  • modules/QtPDF/trans contains the translations belonging to QtPDF, the library responsible for handling .pdf files

In the following, we will describe how to deal with the TeXworks core translations. Translating other parts should work analogously.

To create a new .ts file for a particular language, run lupdate on the TeXworks_trans.pro file (in the trans directory), and specify the .ts file to be created. We'll use German as an example:

    cd trans
    lupdate TeXworks_trans.pro -ts TeXworks_de.ts

The same command is used to update the .ts file when there are changes in the TeXworks source. This allows you to keep all your existing translation work, and just add or modify strings for any changed parts of the user interface.

Use Qt Linguist to edit the .ts file, adding translations. Note that Linguist can show the source code where the string is used, which may be helpful in understanding the context if it is not immediately clear. It also "remembers" your translations, so that if the same string occurs again, it can suggest the same translation.

Finally, use the File/Release command within Linguist to generate a compiled .qm file (or use the lrelease command-line tool). Note that you can do this at any stage; if you have not translated all the strings, the original English will be used for those that are missing. So you can try out your work before finishing it all.

For your translation to be loaded by TeXworks, you need to put the .qm file in the translations folder (in the TeXworks resources folder, alongside others such as templates and completion files); then re-start the TeXworks application.

Once you are satisfied with your work we'd be happy to include it in TeXworks. You can create a pull request on GitHub, link the .ts file to a new issue, or send it to the mailing list to let us know of your contribution.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.