Localization Older Methods/pl

This is a collection of old localization techniques used by FreeCAD in the past. They show some of the internals of the processs, but the techniques on the Localisation page should be used from now on.

Translating with Qt-Linguist (old way)
The following information doesn't need to be used anymore and will likely become obsolete. It is being kept here so that programmers may familiarize themselves with how it works. -


 * Open all of the language folders of FreeCAD shown below
 * Verify that a .ts file with your language code doesn't exist ("fr" for french, "de" for german, etc...)
 * If it exists, you can download that file, if you want to modify/review/better the translation (click the file, then download)
 * If it doesn't exist, download the .ts file without language code (or any other .ts available, it will work too)
 * Rename that file with your language code
 * Open it with the Qt-Linguist program
 * Start translating (Qt Linguist is very easy to use)
 * Once it's completely done, save your file
 * send the files to us so we can include them in the Freecad source code so they benefit other users too.

 Available translation files 


 * The following links all direct to the sourceforge which is no longer used by FreeCAD. The code is hosted at https://github.com/FreeCAD/FreeCAD.
 * FreeCAD main GUI
 * Complete Workbench
 * Drawing Workbench
 * Draft Workbench
 * Reverse Engineering Workbench
 * FEM Workbench
 * Robot Workbench
 * Image Workbench
 * Sketcher Workbench
 * Mesh Workbench
 * Test Workbench
 * Points Workbench
 * Raytracing Workbench
 * Part Workbench
 * PartDesign Workbench
 * Assembly Workbench
 * MeshPart Workbench
 * There is a very good Forum post about the old way of translation, but it is in German. See http://forum.freecadweb.org/viewtopic.php?f=13&t=19496&start=60#p152655

Prerequisites
To localise your application module your need to helpers that come with Qt. You can download them from the Trolltech-Website, but they are also contained in the LibPack:
 * qmake: Generates project files
 * lupdate: Extracts or updates the original texts in your project by scanning the source code
 * Qt-Linguist: The Qt-Linguist is very easy to use and helps you translating with nice features like a phrase book for common sentences.

Project Setup
To start the localisation of your project go to the GUI-Part of you module and type on the command line:

This scans your project directory for files containing text strings and creates a project file like the following example:

You can manually add files here. The section TRANSLATIONS contains a list of files with the translation for each language. In the above example MyMod_de.ts is the german translation.

Now you need to run lupdate to extract all string literals in your GUI. Running lupdate after changes in the source code is allways safe since it never deletes strings from your translations files. It only adds new strings.

Now you need to add the .ts-files to your VisualStudio project. Specifiy the following custom build method for them:

Note: Enter this in one command line, the line break is only for layout purpose.

By compiling the .ts-file of the above example, a header file MyMod_de.h is created. The best place to include this is in AppGui.cpp. In our example this would be AppMyModGui.cpp. There you add the line

to publish your translation in the application.

Setting up python files for translation
To ease localization for the py files you can use the tool "pylupdate4" which accepts one or more py files. With the -ts option you can prepare/update one or more .ts files. For instance to prepare a .ts file for French simply enter into the command line:

the pylupdate tool will scan your .py files for translate or tr functions and create a YourModule_fr.ts file. That file can the be translated with QLinguist and a YourModule_fr.qm file produced from QLinguist or with the command

Beware that the pylupdate4 tool is not very good at recognizing translate functions, they need to be formatted very specifically ( see the Draft module files for examples). Inside your file, you can then setup a translator like this (after loading your QApplication but BEFORE creating any qt widget):

Optionally, you can also create the file XML Draft.qrc with this content:

and running pyrcc4 Draft.qrc -o qrc_Draft.py creates a big Python containing all resources. BTW this approach also works to put icon files in one resource file