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.

Helping to translate FreeCAD
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 now easier than ever, with the use of the Crowdin collaborative on-line translation system.

How to Translate

 * Go to the FreeCAD translation project page on Crowdin;
 * Login by creating a new profile, or using a third-party account like your GMail address;
 * Click on the language you wish to work on;
 * Start translating by clicking on the Translate button next to one of the files. For example, FreeCAD.ts contains the text strings for the FreeCAD main GUI.
 * You can vote for existing translations, or you can create your own.

Note: If you are actively taking part in translating FreeCAD and want to be informed before next release is ready to be launched, so there is time to review your translation, please subscribe to this issue: http://sourceforge.net/apps/mantisbt/free-cad/view.php?id=137

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

 * 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 on.

You must then gain wiki edit permission.

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). You should use a slash and your language code in almost all the links. Look at other already translated pages to see how they did it.

Add a slash and your language code in the categories, like

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.


 * In the original english page add your language in alphabetic order:
 * In the page you have translated you should use your language template and put the english first and then the rest of languages in alphabetic order:

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.

Four templates are commonly used in manual pages. These 4 templates have localized versions (Template:Docnav/fr, Template:fr, etc...)
 * Template:GuiCommand : is the Gui Command information block in upper-right of command documentation.
 * 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.

Page Naming Convention
Please take note that, due to limitations in the Sourceforge implementation of the MediaWiki engine, we require that your pages all keep their original English counterpart's name, appending a slash and your language code. For example, the translated page for About FreeCAD should be About Freecad/es for Spanish, About FreeCAD/pl for polish, etc. The reason is simple: so that if translators go away, the wiki's administrators, who do not speak all languages, will know what these pages are for. This will facilitate maintenance and avoid lost pages.

If you want the Docnav template to show linked pages in your language, you can use redirect pages. They are basically shortcut links to the actual page. Here is an example with the French page for About FreeCAD.

The page "Bienvenue sur l'aide en ligne" redirects to Online Help Startpage/fr, and the page "Fonctionnalités" redirects to Feature list/fr.
 * The page About FreeCAD/fr is the page with content
 * The page À propos de FreeCAD contains this code:
 * 1) REDIRECT About FreeCAD/fr
 * In the About FreeCAD/fr page, the Docnav code will look like this:

If you are unsure how to proceed, don't hesitate to ask for help in the forum.