Localization Older Methods/fr

Ceci est un regroupement d'anciennes méthodees de localisation utilisées par FreeCAD dans le passé. Ils montrent une partie des processus internes, mais les techniques sur la page Localisation doivent être utilisées à partir de maintenant.

Translatiion avec Qt-Linguist (ancienne voie)
Les informations suivantes ne doivent plus être utilisées et deviendront probablement obsolètes. Ces informations sont conservées ici afin que les programmeurs puissent se familiariser avec son fonctionnement. -


 * Ouvrez tous les dossiers de langue de FreeCAD indiqués ci-dessous
 * Vérifiez qu’il n’existe pas de fichier .ts avec votre code de langue ("fr" pour le français, "de" pour l’allemand, etc ...)
 * S'il existe, vous pouvez télécharger ce fichier si vous souhaitez modifier/réviser/améliorer la traduction (cliquez sur le fichier, puis téléchargez-le)
 * S'il n'existe pas, téléchargez le fichier .ts sans code de langue (ou tout autre fichier .ts disponible, cela fonctionnera aussi)
 * Renommez ce fichier avec votre code de langue
 * Ouvrez-le avec le programme Qt-Linguist
 * Commencez à traduire (Qt Linguist est très facile à utiliser)
 * Une fois que c'est complètement fait, sauvegardez votre fichier
 * envoyez-nous les fichiers afin que nous puissions les inclure dans le code source de freecad afin que les autres utilisateurs en bénéficient également.

Fichiers de traduction disponibles


 * 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

Prérequis
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:

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