Lokalizacja - tłumaczenie interfejsu i dokumentacji

From FreeCAD Documentation
Revision as of 12:50, 7 October 2010 by Kwahoo (talk | contribs)

Lokalizacja jest ogólnym procesem dostarczania Oprogramowaniu wsparcia wielu języków interfejsu użytkownika. We FreeCADzie możesz ustawić język interfejsu użytkownika Edit→Preferences→Application. FreeCAD używa Qt by aktywować wsparcie wielu języków. W systemach Unix/Linux, FreeCAD domyślnie używa aktualnych ustawień językowych twojego systemu.

Pomoc w tłumaczeniu FreeCADa

Jedną z bardzo ważnych rzeczy, które możesz zrobić dla FreeCADa, jeśli nie jesteś programistą, jest pomoc w tłumaczeniu programu na twój język.Dokonanie tego jest łatwiejsze niż kiedykolwiek, dzięki użyciu systemu wspólnego tłumaczenia online Crowdin.

Jak tłumaczyć

  • Udaj się na stronę Crowdin tłumaczenia projektu FreeCAD;
  • Zaloguj się tworząc nowy profil lub używając konta innego dostawcy jak twój adres GMail;
  • Kliknij na język nad którym chcesz pracować;
  • Rozpocznij tłumaczenie przez kliknięcie przycisku Translate przy jednym z plików. Na przykład FreeCAD.ts zawiera ciągi tekstu z głównego interfejsu graficznego FreeCAD.
  • Możesz głosować na istniejące tłumaczenia lub dodawać własne.
Uwaga: Jeśli bierzesz aktywny udział w tłumaczeniu FreeCADa i chcesz być informowany o tym kiedy następna wersja będzie gotowe do wydania, to jest wtedy jest czas na przegląd twojego tłumaczenia. Proszę powiadom o tym: 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

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

Tłumaczenie wiki

Wiki ma sporą objętość. Najnowsze i najbardziej interesujące materiały przechowywane są w podręczniku. Sprawdź najpierw czy tłumaczenie podręcznika zostało rozpoczęte w twoim języku (spójrz na lewy pasek boczny poniżej "manual"). Jeśli, przejdź do forum i oznajmij, że chcesz rozpocząć nowe tłumczenie, stworzymy podstawowe ustawienia dla języka nad którym chcesz pracować.

Później musisz uzyskać uprawnienia do edycji wiki.

Jeśli twój język jest już na liście, sprawdź dla których stron nadal brakuje tłumaczenia (będą wypisane na czerwono). Sposób jest prosty: wchodzisz na czerwoną stronę, kopiujesz zawartość z odpowiadającej jej anglojęzycznej strony i zaczynasz tłumaczyć. Nie zapomnij załączyć wszystkich tagów i szablonów z oryginalnej anglojęzycznej strony. Niektóre z tych szablonów posiadają odpowiedniki w twoim języku (np. polski szablon Docnav nazwany Docnav/pl). Spójrz na inne przetłumaczone strony by zobaczyć jak zrobili to inni.

Wtedy, gdy przetłumaczysz stronę, musisz dodać na oryginalnej anglojęzycznej stronie skrót do twojego tłumaczenia, by czytający wiedzieli, że przetłumaczona wersja jest dostępna. Użyj szablonu {{languages}}. Zobacz jak inni tłumacze zrobili to samo.

Jeśli nie jesteś czegoś pewny, udaj się na forum i poproś ludzi o sprawdzenie i powiedzenie czy to jest dobrze wykonane czy nie.

Trzy szablony są wspólne dla wszystkich stron podręcznika. Te 3 szablony posiadają przetłumaczone wersje (Template:Docnav/pl, Template:pl, etc...)

  • Template:Docnav : pasek nawigacji na dole strony, pokazuje wcześniejsze i następne strony.
  • Template:Languages : szablon, który musi być umieszczony na oryginalnych stronach by zaznaczyć obecność tłumaczeń. Zlokalizowana wersja musi być umieszczona na przetłumaczonej stronie linkuj ąc do oryginalnej anglojęzycznej strony.
  • Template:en : jeden dla każdego z języków. Musi znajdować się w środku szablonu languages.

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/pl
Extra python modules/pl
Available translations of this page: Template:Se