FreeCAD-Doc/localwiki/Localisation-id.html
2018-07-19 18:47:02 -05:00

226 lines
21 KiB
HTML

<html><head><title>Localisation/id</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Localisation/id</h1></div>
<div id="mw-content-text" lang="id" dir="ltr" class="mw-content-ltr"><hr/><div class="mw-parser-output"><p><b>Localisation</b> 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 <i>Edit→Preferences→Application</i>. FreeCAD uses <a href="http://en.wikipedia.org/wiki/Qt_(toolkit)" class="extiw" title="wikipedia:Qt (toolkit)">Qt</a> to enable multiple language support. On Unix/Linux systems, FreeCAD uses the current locale settings of your system by default.
</p>
<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Helping_to_translate_FreeCAD"><span class="tocnumber">1</span> <span class="toctext">Helping to translate FreeCAD</span></a>
<ul>
<li class="toclevel-2 tocsection-2"><a href="#How_to_Translate"><span class="tocnumber">1.1</span> <span class="toctext">How to Translate</span></a></li>
<li class="toclevel-2 tocsection-3"><a href="#Translating_with_Qt-Linguist_.28old_way.29"><span class="tocnumber">1.2</span> <span class="toctext">Translating with Qt-Linguist (old way)</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-4"><a href="#Preparing_your_own_modules.2Fapplications_for_translation"><span class="tocnumber">2</span> <span class="toctext">Preparing your own modules/applications for translation</span></a>
<ul>
<li class="toclevel-2 tocsection-5"><a href="#Prerequisites"><span class="tocnumber">2.1</span> <span class="toctext">Prerequisites</span></a></li>
<li class="toclevel-2 tocsection-6"><a href="#Project_Setup"><span class="tocnumber">2.2</span> <span class="toctext">Project Setup</span></a></li>
<li class="toclevel-2 tocsection-7"><a href="#Setting_up_python_files_for_translation"><span class="tocnumber">2.3</span> <span class="toctext">Setting up python files for translation</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-8"><a href="#Translating_the_wiki"><span class="tocnumber">3</span> <span class="toctext">Translating the wiki</span></a>
<ul>
<li class="toclevel-2 tocsection-9"><a href="#Translation_plugin"><span class="tocnumber">3.1</span> <span class="toctext">Translation plugin</span></a></li>
<li class="toclevel-2 tocsection-10"><a href="#Old_translation_instructions"><span class="tocnumber">3.2</span> <span class="toctext">Old translation instructions</span></a></li>
</ul>
</li>
</ul>
</div>
<h2><span class="mw-headline" id="Helping_to_translate_FreeCAD">Helping to translate FreeCAD</span></h2>
<p>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 <a rel="nofollow" class="external text" href="http://crowdin.net">Crowdin</a> collaborative on-line translation system.
</p>
<h3><span class="mw-headline" id="How_to_Translate">How to Translate</span></h3>
<ul><li> Go to the <a rel="nofollow" class="external text" href="http://crowdin.net/project/freecad">FreeCAD translation project page on Crowdin</a>;</li>
<li> Login by creating a new profile, or using a third-party account like your GMail address;</li>
<li> Click on the language you wish to work on;</li>
<li> Start translating by clicking on the Translate button next to one of the files. For example, <i>FreeCAD.ts</i> contains the text strings for the FreeCAD main GUI.</li>
<li> You can vote for existing translations, or you can create your own.</li></ul>
<pre><b>Note</b>: 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: <a rel="nofollow" class="external free" href="http://www.freecadweb.org/tracker/view.php?id=137">http://www.freecadweb.org/tracker/view.php?id=137</a>
</pre>
<p><br />
</p>
<h3><span class="mw-headline" id="Translating_with_Qt-Linguist_.28old_way.29">Translating with Qt-Linguist (old way)</span></h3>
<table class="mw-collapsible mw-collapsed wikitable">
<tr>
<td>The following information doesn't need to be used anymore and will likely become obsolete.
<p>It is being kept here so that programmers may familiarize themselves with how it works.
</p>
</td></tr>
<tr>
<td>
<ul><li> Open all of the language folders of FreeCAD shown below</li>
<li> Verify that a .ts file with your language code doesn't exist ("fr" for french, "de" for german, etc...)</li>
<li> If it exists, you can download that file, if you want to modify/review/better the translation (click the file, then download)</li>
<li> If it doesn't exist, download the .ts file without language code (or any other .ts available, it will work too)</li>
<li> Rename that file with your language code</li>
<li> Open it with the Qt-Linguist program</li>
<li> Start translating (Qt Linguist is very easy to use)</li>
<li> Once it's completely done, save your file</li>
<li> <a rel="nofollow" class="external text" href="http://www.freecadweb.org/tracker/main_page.php">send the files to us</a> so we can include them in the freecad source code so they benefit other users too.<br /></li></ul>
<p><b> Available translation files </b><br />
</p>
<ul><li> The following links all direct to the sourceforge which is no longer used by FreeCAD. The code is hosted at <a rel="nofollow" class="external free" href="https://github.com/FreeCAD/FreeCAD">https://github.com/FreeCAD/FreeCAD</a>.</li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Gui/Language/">FreeCAD main GUI</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Complete/Gui/Resources/translations/">Complete Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Drawing/Gui/Resources/translations/">Drawing Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Draft/Resources/translations/">Draft Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/ReverseEngineering/Gui/Resources/translations/">Reverse Engineering Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Fem/Gui/Resources/translations/">FEM Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Robot/Gui/Resources/translations/">Robot Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Image/Gui/Resources/translations/">Image Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Sketcher/Gui/Resources/translations/">Sketcher Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Mesh/Gui/Resources/translations/">Mesh Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Test/Gui/Resources/translations/">Test Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Points/Gui/Resources/translations/">Points Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Raytracing/Gui/Resources/translations/">Raytracing Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Part/Gui/Resources/translations/">Part Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/PartDesign/Gui/Resources/translations/">PartDesign Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Assembly/Gui/Resources/translations/">Assembly Workbench</a></li>
<li> <a rel="nofollow" class="external text" href="http://free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/MeshPart/Gui/Resources/translations/">MeshPart Workbench</a></li>
<li> There is a very good Forum post about the old way of translation, but it is in German. See <a rel="nofollow" class="external free" href="http://forum.freecadweb.org/viewtopic.php?f=13&amp;t=19496&amp;start=60#p152655">http://forum.freecadweb.org/viewtopic.php?f=13&amp;t=19496&amp;start=60#p152655</a></li></ul>
</td></tr></table>
<h2><span class="mw-headline" id="Preparing_your_own_modules.2Fapplications_for_translation">Preparing your own modules/applications for translation</span></h2>
<h3><span class="mw-headline" id="Prerequisites">Prerequisites</span></h3>
<p>To localise your application module your need to helpers that come with <i>Qt</i>. You can download them from the <a rel="nofollow" class="external text" href="http://www.trolltech.com/products/qt/downloads">Trolltech-Website</a>, but they are also contained in the <a href="Third_Party_Libraries.html" title="Third Party Libraries">LibPack</a>:
</p>
<dl><dt>qmake</dt>
<dd> Generates project files</dd>
<dt>lupdate</dt>
<dd> Extracts or updates the original texts in your project by scanning the source code</dd>
<dt>Qt-Linguist</dt>
<dd> The <i>Qt-Linguist</i> is very easy to use and helps you translating with nice features like a phrase book for common sentences.</dd></dl>
<h3><span class="mw-headline" id="Project_Setup">Project Setup</span></h3>
<p>To start the localisation of your project go to the GUI-Part of you module and type on the command line:
</p>
<pre>
qmake -project
</pre>
<p>This scans your project directory for files containing text strings and creates a project file like the following example:
</p>
<pre>
######################################################################
# 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
</pre>
<p>You can manually add files here. The section <tt>TRANSLATIONS</tt> contains a list of files with the translation for each language. In the above example <i>MyMod_de.ts</i> is the german translation.
</p><p>Now you need to run <tt>lupdate</tt> to extract all string literals in your GUI. Running <tt>lupdate</tt> after changes in the source code is allways safe since it never deletes strings from your translations files. It only adds new strings.
</p><p>Now you need to add the <tt>.ts</tt>-files to your VisualStudio project. Specifiy the following custom build method for them:
</p>
<pre>python ..\..\..\Tools\qembed.py "$(InputDir)\$(InputName).ts"
"$(InputDir)\$(InputName).h" "$(InputName)" </pre>
<p>Note: Enter this in one command line, the line break is only for layout purpose.
</p><p>By compiling the <tt>.ts</tt>-file of the above example, a header file <i>MyMod_de.h</i> is created. The best place to include this is in <i>App&lt;Modul&gt;Gui.cpp</i>. In our example this would be <i>AppMyModGui.cpp</i>. There you add the line
</p>
<pre>new Gui::LanguageProducer("Deutsch", &lt;Modul&gt;_de_h_data, &lt;Modul&gt;_de_h_len); </pre>
<p>to publish your translation in the application.
</p>
<h3><span class="mw-headline" id="Setting_up_python_files_for_translation">Setting up python files for translation</span></h3>
<p>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:
</p>
<pre>
pylupdate4 *.py -ts YourModule_fr.ts
</pre>
<p>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
</p>
<pre>
lrelease YourModule_fr.ts
</pre>
<p>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):
</p>
<pre>
translator = QtCore.QTranslator()
translator.load("YourModule_"+languages[ln])
QtGui.QApplication.installTranslator(translator)
</pre>
<p>Optionally, you can also create the file XML Draft.qrc with this content:
</p>
<pre>
&lt;RCC&gt;
&lt;qresource prefix="/translations" &gt;
&lt;file&gt;Draft_fr.qm&lt;/file&gt;
&lt;/qresource&gt;
&lt;/RCC&gt;
</pre>
<p>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
</p>
<h2><span class="mw-headline" id="Translating_the_wiki">Translating the wiki</span></h2>
<p>This wiki is hosting a lot of contents, the majority of which build up the manual. You can browse the documentation starting from the <a href="https://www.freecadweb.org/wiki/index.php?title=Main_Page" title="Main Page">Main Page</a>, or have a look at the User's manual <a href="Online_Help_Toc.html" title="Online Help Toc">Online Help Toc</a>.
</p>
<h3><span class="mw-headline" id="Translation_plugin">Translation plugin</span></h3>
<p>When the Wiki moved away from SourceForge, <a href="https://www.freecadweb.org/wiki/index.php?title=User:Yorik" title="User:Yorik">Yorik</a> installed a <a class="external text" href="http://www.mediawiki.org/wiki/Help:Extension:Translate">Translation plugin</a> which allows to ease translations between pages. For example, the page title can now be translated. Other advantages of the Translation plugin are that it keeps track of translations, notifies if the original page has been updated, and maintains translations in sync with the original English page.
</p><p>The tool is documented in <a class="external text" href="http://www.mediawiki.org/wiki/Help:Extension:Translate">Extension:Translate</a>, and is part of a <a class="external text" href="http://www.mediawiki.org/wiki/MediaWiki_Language_Extension_Bundle">Language Extension Bundle</a>.
</p><p>To quickly get started on preparing a page for translation and activating the plugin, please read the <a class="external text" href="http://www.mediawiki.org/wiki/Help:Extension:Translate/Page_translation_example">Page translation example</a>.
</p><p>To see an example of how the Translation tool works once the translation plugin is activated on a page, you can visit the <a href="https://www.freecadweb.org/wiki/index.php?title=Main_Page" title="Main Page">Main Page</a>. You will see a new language menu bar at the bottom. It is automatically generated. Click for instance on the German link, it will get you to <a href="https://www.freecadweb.org/wiki/index.php?title=Main_Page/de" title="Main Page/de">Main Page/de</a>. Right under the title, you can read "This page is a <b>translated version</b> of a page Main Page and the translation is xx% complete." (xx being the actual percentage of translation). Click on the "translated version" link to start translation, or to update or correct the existing translation.
</p><p>You will notice that you cannot directly edit a page anymore once it's been marked as a translation. You have to go through the translation utility.
</p><p>When adding new content, the English page should be created first, then translated into another language. If someone wants to change/add content in a page, he should do the English one first.
</p><p>It is recommended to have basic knowledge of wiki style formatting and general guidelines of the FreeCAD wiki, because you will have to deal with some tags while translating. You can find this information on <a href="WikiPages.html" title="WikiPages">WikiPages</a>.
</p><p>The sidebar (navigation menu on the left) is also translatable. Please follow dedicated instructions on <a href="Localisation_Sidebar.html" title="Localisation Sidebar">Localisation Sidebar</a> page.
</p><p><b>REMARK: The first time you switch a page to the new translation system, it looses all its old 'manual' translations. To recover the translation, you need to open an earlier version from the history, and copy/paste manually the paragraphs to the new translation system.</b>
</p><p>Remark: to be able to translate in the wiki, you must of course <a href="/wiki/FAQ#How_can_I_get_edit_permission_on_the_wiki.3F" title="FAQ">gain wiki edit permission</a>.
</p><p><br />
If you are unsure how to proceed, don't hesitate to ask for help in the <a rel="nofollow" class="external text" href="http://forum.freecadweb.org">forum</a>.
</p>
<h3><span class="mw-headline" id="Old_translation_instructions">Old translation instructions</span></h3>
<table class="mw-collapsible mw-collapsed wikitable">
<tr>
<td>These instructions are for historical background only, while the pages are being passed to the new translation plugin.
</td></tr>
<tr>
<td>
<p>So the first step is to <b>check if the manual translation has already been started for your language</b> (look in the left sidebar, under "manual").<br />
If not, head to the <a rel="nofollow" class="external text" href="http://forum.freecadweb.org/">forum</a> and say that you want to start a new translation, we'll create the basic setup for the language you want to work on.<br />
You must then <a href="/wiki/FAQ#How_can_I_get_edit_permission_on_the_wiki.3F" title="FAQ">gain wiki edit permission</a>.<br />
If your language is already listed, see what pages are still missing a translation (they will be listed in red). The technique is simple: <b>go into a red page, and copy/paste the contents of the corresponding English page, and start translating</b>.<br />
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 <b>a slash and your language code</b> in almost all the links. Look at other already translated pages to see how they did it.<br />
Add a slash and your language code in the categories, like [[Category:Developer Documentation/fr]] <br />
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.<br />
Four templates are commonly used in manual pages. These 4 templates have localized versions (Template:Docnav/fr, Template:fr, etc...)
</p>
<ul><li> <a href="https://www.freecadweb.org/wiki/index.php?title=Template:GuiCommand" title="Template:GuiCommand">Template:GuiCommand</a>&#160;: is the Gui Command information block in upper-right of command documentation.</li>
<li> <a href="https://www.freecadweb.org/wiki/index.php?title=Template:Docnav" title="Template:Docnav">Template:Docnav</a>&#160;: it is the navigation bar at the bottom of the pages, showing previous and next pages.</li></ul>
<p><b> Page Naming Convention </b><br />
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.<br />
If you want the Docnav template to show linked pages in your language, you can use <b>redirect pages</b>. They are basically shortcut links to the actual page. Here is an example with the French page for About FreeCAD.<br />
</p>
<ul><li> The page About FreeCAD/fr is the page with content</li>
<li> The page À propos de FreeCAD contains this code:</li></ul>
<pre>#REDIRECT [[About FreeCAD/fr]]
</pre>
<ul><li> In the About FreeCAD/fr page, the Docnav code will look like this:</li></ul>
<pre>{{docnav/fr|Bienvenue sur l'aide en ligne|Fonctionnalités}}
</pre>
<p>The page "Bienvenue sur l'aide en ligne" redirects to Online Help Startpage/fr, and the page "Fonctionnalités" redirects to Feature list/fr.
</p>
</td></tr></table>
<div style="clear:both"></div>
</div>
</div>
</div><div class="printfooter">
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Localisation/id&amp;oldid=216779">http://www.freecadweb.org/wiki/index.php?title=Localisation/id&amp;oldid=216779</a>"</div>
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
</div>
</div>
<div id="mw-navigation">
<h2>Navigation menu</h2>
</body></html>