Localization Older Methods/it

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

Prerequisiti
Per realizzare la traduzione del modulo dell'applicazione servono delle utility fornite con Qt. Esse si possono scaricare da Trolltech-Website, ma sono anche contenute in LibPack:
 * qmake: Genera i file del progetto
 * lupdate: Estrae o aggiorna i testi originali del progetto tramite la scansione del codice sorgente
 * Qt-Linguist: Qt-Linguist è molto facile da usare, agevola la traduzione con pratiche funzioni e dispone di un frasario per le espressioni più comuni.

Setup del progetto
Per iniziare la localizzazione del proprio progetto andare alla GUI-Part del modulo e digitare sulla riga di comando: qmake -project Questo esegue la scansione della directory del progetto alla ricerca dei file contenenti stringhe di testo e crea un file di progetto come nel seguente esempio: 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

È possibile aggiungere manualmente i file qui. La sezione TRANSLATIONS contiene un elenco di file con la traduzione per ogni lingua. Nell'esempio precedente MyMod_de.ts è la traduzione in tedesco.

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: 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  e eseguire pyrcc4 Draft.qrc -o qrc_Draft.py che crea un grande file Python contenente tutte le risorse. Questo metodo funziona anche per inserire i file di icona in un file di risorse