Localización

From FreeCAD Documentation
Revision as of 22:30, 7 September 2010 by Jmvillar (talk | contribs) (Created page with ''''Localización''' es, en general, el proceso de proporcionar un software con una interfaz de usuario en múltiples lenguajes. En FreeCAD puede establecer el idioma de la interf…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Localización es, en general, el proceso de proporcionar un software con una interfaz de usuario en múltiples lenguajes. En FreeCAD puede establecer el idioma de la interfaz de usuario enEditar→Preferencias→aplicación. FreeCAD utiliza Qt para habilitar el soporte para varios idiomas. En Unix / Linux, FreeCAD utiliza la configuración regional actual de su sistema por defecto.

Cómo ayudar a traducir FreeCAD

Una de las cosas mas importantes que puede hacer por FreeCAD si no es un programador, es ayudar a traducir el programa a su idioma. Hacerlo es ahora más fácil que nunca, con el uso de la Crowdin] sistema colaborativo de traducción en línea.

Como traducir

  • Vaya a FreeCAD translation project page on Crowdin;
  • haga Login creando un nuevo profile, o usando una cuenta de una tercera-parte, como su dirección GMail;
  • Haga Click en el idioma en el que quiera trabajar;
  • Comience la traducción haciendo click en el boton Tanslate próximo a uno de los archivos. Por ejemplo, FreeCAD.ts contiene las cadenas de texto para el GUI (interfaz gráfico de usuario) principal de FreeCAD.
  • Puede elegir entre la traducciones existentes, o crear la suya propia.


Traducción con Qt-Linguist (forma antigua)

LO QUE SIGUE EXPLICA EL METODO OBSOLETO DE TRADUCCIÓN, Y SOLO SIRVE COMO REFERENCIA DIDÁCTICA

La siguiente información no tiene por qué ser usado más y probablemente se convierta en obsoleto. Se mantiene aquí para que los programadores puedan conocer cómo funciona.


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

Preparing your own modules/applications for translation

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:

######################################################################
# Automatically generated by qmake (1.06c) Do 2. Nov 14:44:21 2006
######################################################################

TEMPLATE = app
DEPENDPATH += .\Icons
INCLUDEPATH += .

# Input
HEADERS += ViewProvider.h Workbench.h
SOURCES += AppMyModGui.cpp \
           Command.cpp \
           ViewProvider.cpp \
           Workbench.cpp
TRANSLATIONS += MyMod_de.ts

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 App<Modul>Gui.cpp. In our example this would be AppMyModGui.cpp. There you add the line

new Gui::LanguageProducer("Deutsch", <Modul>_de_h_data, <Modul>_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:

<RCC>
<qresource prefix="/translations" > 
<file>Draft_fr.qm</file> 
</qresource> 
</RCC> 

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). 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 {{languages}} 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 localized 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.

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 About FreeCAD/fr is the page with content
  • The page À propos de FreeCAD contains this code:
#REDIRECT [[About FreeCAD/fr]]
  • In the About FreeCAD/fr page, the Docnav code will look like this:
{{docnav/fr|Bienvenue sur l'aide en ligne|Fonctionnalités}}

The page "Bienvenue sur l'aide en ligne" redirects to Online Help Startpage/fr, and the page "Fonctionnalités" redirects to Feature list/fr.

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


Branding/es
Extra python modules/es
Available translations of this page: Template:Se