Localisation

Localisation is in general the process of providing a Software with a multiple language user interface. In FreeCAD you can set the language of the user interface under Edit→Preferences→Application. FreeCAD uses Qt to enable multiple language support. On Unix/Linux systems, FreeCAD uses the current locale settings of your system by default.

How to Translate
Note We are currently implementing a new online translation system on crowdin. You can start translating imediately here: http://crowdin.net/project/freecad. Please note that it's still under testing. The following information doesn't need to be used anymore and will likely become obsolete.

One of the very important things you can do for FreeCAD if you are not a programmer, is to help to translate the program in your language. To do so is very easy:


 * 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

 * 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

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:

qmake -project

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

TEMPLATE = app DEPENDPATH += .\Icons INCLUDEPATH +=. HEADERS += ViewProvider.h Workbench.h SOURCES += AppMyModGui.cpp \ Command.cpp \ ViewProvider.cpp \ Workbench.cpp TRANSLATIONS += MyMod_de.ts
 * 1) Automatically generated by qmake (1.06c) Do 2. Nov 14:44:21 2006
 * 1) Automatically generated by qmake (1.06c) Do 2. Nov 14:44:21 2006
 * 1) Input

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: python ..\..\..\Tools\qembed.py "$(InputDir)\$(InputName).ts" "$(InputDir)\$(InputName).h" "$(InputName)" 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 new Gui::LanguageProducer("Deutsch", _de_h_data, _de_h_len); 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: pylupdate4 *.py -ts YourModule_fr.ts

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

lrelease YourModule_fr.ts

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):

translator = QtCore.QTranslator translator.load("YourModule_"+languages[ln]) QtGui.QApplication.installTranslator(translator) Optionally, you can also create the file XML Draft.qrc with this content:   Draft_fr.qm 

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

Translating the wiki
This wiki is hosting a lot of contents. The most up-to-date and interesting material is gathered in the manual. So the first step is to check if the manual translation has already been started for your language (look in the left sidebar, under "manual"). If not, head to the forum and say that you want to start a new translation, we'll create the basic setup for the language you want to work.

You must then gain wiki edit permission (see previous question in this FAQ)

If your language is already listed, see what pages are still missing a translation (they will be listed in red). The technique is simple: go into a red page, and copy/paste the contents of the corresponding english page, and start translating. Do not forget to include all the tags and templates from the original english page. Some of those templates will have an equivalent in your language (for example, there is a french Docnav template called Docnav/fr). Look at other already translated pages to see how they did it.

Then, once you translated a page, you must add to the original english page a link to your translation, so readers know that there is a translated version available, using the template. Look at how other translators did it to do the same.

And if you are unsure, head to the forums and ask people to check what you did and tell you if it's right or not.

Three templates are commonly used in manual pages. These 3 templates have localised versions (Template:Docnav/fr, Template:fr, etc...)
 * Template:Docnav : it is the navigation bar at the bottom of the pages, showing previous and next pages
 * Template:Languages : this template must be placed on original pages, to indicate the reader that a translation exists. The localised version must in return be placed on the translated page, to link to the original english page.
 * Template:en : there is one of these for each language. They must be placed inside the language template.