Difference between revisions of "Translation for developers"

Jump to navigation Jump to search
no edit summary
(svn -> git)
Line 1: Line 1:
{{translations}}
<translate><!--T:1-->
Beside the pure [[translation]] part of the work, the '''Kiwix source code needs to be synchronized with Translatewiki'''.
Beside the pure [[translation]] part of the work, the '''Kiwix source code needs to be synchronized with Translatewiki'''.
</translate>


<translate><!--T:2-->
This synchronisation with Translatewiki needs three types of operation:
This synchronisation with Translatewiki needs three types of operation:
* ''Add a string'' to Kiwix and Translatewiki, ie. introducing a dynamic string which will be replaced by the corresponding translation at the runtime.
* ''Add a string'' to Kiwix and Translatewiki, ie. introducing a dynamic string which will be replaced by the corresponding translation at the runtime.
* ''Update the Kiwix strings'' with the translations coming from Translatewiki.
* ''Update the Kiwix strings'' with the translations coming from Translatewiki.
* ''Add a new Translatewiki full translated language to Kiwix''.
* ''Add a new Translatewiki full translated language to Kiwix''.
</translate>


<translate><!--T:3-->
== Requirements ==
== Requirements ==
You need a GNU/Linux Operating System. This is possible to do also that on other operation systems, but this is more complicated to get a working environment.
You need a GNU/Linux Operating System. This is possible to do also that on other operation systems, but this is more complicated to get a working environment.
</translate>


<translate><!--T:4-->
You need to have a few things in mind:
You need to have a few things in mind:
* Kiwix translation files are all in the "kiwix/chrome/locale" directory.
* Kiwix translation files are all in the "kiwix/chrome/locale" directory.
Line 15: Line 23:
** "main.properties" which provides translations for all *.js files.
** "main.properties" which provides translations for all *.js files.
* Translatewiki translations are imported separately in the Kiwix code repository on time a week and we always need to synchronize thus files with Kiwix code in both direction (KW->TW and TW -> KW).
* Translatewiki translations are imported separately in the Kiwix code repository on time a week and we always need to synchronize thus files with Kiwix code in both direction (KW->TW and TW -> KW).
</translate>


<translate><!--T:5-->
'''WARNING: Before any modification of Kiwix source code, update your local code repositories with "git pull origin master" in each one of them.'''
'''WARNING: Before any modification of Kiwix source code, update your local code repositories with "git pull origin master" in each one of them.'''
</translate>


<translate><!--T:6-->
== Checkout the code and start Kiwix ==
== Checkout the code and start Kiwix ==
</translate>


<translate><!--T:7-->
Before starting to work on the integration of new strings in the Kiwix code, it's preferable to [[compilation|achieve to compile Kiwix]]:
Before starting to work on the integration of new strings in the Kiwix code, it's preferable to [[compilation|achieve to compile Kiwix]]:
* Get the unstable code
* Get the unstable code
* Compile it
* Compile it
* Run it by going to the kiwix subdirectory and launching ''kiwix''.
* Run it by going to the kiwix subdirectory and launching ''kiwix''.
</translate>


<translate><!--T:8-->
''Remark: If you are not able to compile Kiwix, or do not have xulrunner available (is the case for example on Ubuntu Oneiric and further) you will still be able to be able to start kiwix and get an interface although the application won't work correctly, but that's enough for example to manipulate the XUL files. In this case you will have to make a few additional stuff like add "MaxVersion=42.*" as new line to kiwix/application.ini and launch Kiwix using this command in the "kiwix" directory "firefox -app application.ini"''.
''Remark: If you are not able to compile Kiwix, or do not have xulrunner available (is the case for example on Ubuntu Oneiric and further) you will still be able to be able to start kiwix and get an interface although the application won't work correctly, but that's enough for example to manipulate the XUL files. In this case you will have to make a few additional stuff like add "MaxVersion=42.*" as new line to kiwix/application.ini and launch Kiwix using this command in the "kiwix" directory "firefox -app application.ini"''.
</translate>


<translate><!--T:9-->
== Add a string to the translations ==
== Add a string to the translations ==
</translate>


<translate><!--T:10-->
=== Find a string to localize ===
=== Find a string to localize ===
</translate>


<translate><!--T:11-->
Go through the *.xul and *.js files to find hardcoded strings (in English).
Go through the *.xul and *.js files to find hardcoded strings (in English).
</translate>


<translate><!--T:12-->
If you find one you need to find a string identifier (foobar for example), have a look to the already localised string to see how it should looks like. the most important to know is that in the *.xul files, it should looks like "&foobar;" and in the *.js like "getProperty('foobar')".
If you find one you need to find a string identifier (foobar for example), have a look to the already localised string to see how it should looks like. the most important to know is that in the *.xul files, it should looks like "&foobar;" and in the *.js like "getProperty('foobar')".
</translate>


<translate><!--T:13-->
=== Translate it in the master language English ===
=== Translate it in the master language English ===
</translate>


<translate><!--T:14-->
You will need to do that on two place. First in the "kiwix/chrome/locale/en/main/" main.dtd or main.properties files. In that way the Kiwix application knows what to display if the user interface language is English.
You will need to do that on two place. First in the "kiwix/chrome/locale/en/main/" main.dtd or main.properties files. In that way the Kiwix application knows what to display if the user interface language is English.
</translate>


<translate><!--T:15-->
=== Update Translatewiki files ===
=== Update Translatewiki files ===
</translate>


<translate><!--T:16-->
But you also need to tell Translatewiki to add this string in the list of string it has to provide (for the Translatewiki translators) to translate. For that you need to checkout an other part of Kiwix code repository. Please run outside of your local kiwix code directory following console command:
But you also need to tell Translatewiki to add this string in the list of string it has to provide (for the Translatewiki translators) to translate. For that you need to checkout an other part of Kiwix code repository. Please run outside of your local kiwix code directory following console command:
</translate>


<source lang="bash">
<source lang="bash">
Line 47: Line 80:
</source>
</source>


<translate><!--T:17-->
You have now on your computer the translatewiki translations. What you need is only to update the "en" file which is the master language file for Translatewiki. So simply add your new string following the examples of other already inserted strings and commit your "en" file.
You have now on your computer the translatewiki translations. What you need is only to update the "en" file which is the master language file for Translatewiki. So simply add your new string following the examples of other already inserted strings and commit your "en" file.
</translate>


<translate><!--T:18-->
Someone from Translatewiki check each week the "en" file for new strings and synchronized Translatewiki with this file if necessary.
Someone from Translatewiki check each week the "en" file for new strings and synchronized Translatewiki with this file if necessary.
</translate>


<translate><!--T:19-->
=== Create stub translation of you new string for all languages ===
=== Create stub translation of you new string for all languages ===
</translate>


<translate><!--T:20-->
The last thing you need to do is creating stub translation of your new localised string for all supported user interface languages in Kiwix. If you do not that, Kiwix won't be able to work correctly in another language as English.
The last thing you need to do is creating stub translation of your new localised string for all supported user interface languages in Kiwix. If you do not that, Kiwix won't be able to work correctly in another language as English.
</translate>


<translate><!--T:21-->
For that purpose you need to use the script TW2PL.pl (this is a perl script, so perl needs to be installed) like following (go in the translatewiki file directory):
For that purpose you need to use the script TW2PL.pl (this is a perl script, so perl needs to be installed) like following (go in the translatewiki file directory):
</translate>
<source lang="bash">
<source lang="bash">
./TW2KW.pl --path=/full/path/to/the/kiwix/code/directory --allLanguages=kw
./TW2KW.pl --path=/full/path/to/the/kiwix/code/directory --allLanguages=kw
</source>
</source>


<translate><!--T:22-->
=== Commit the new Kiwix translation files ===
=== Commit the new Kiwix translation files ===
Now, all the locale file in kiwix/chrome/locale should be update and you should have a lot of (modified) files listed by typing:
Now, all the locale file in kiwix/chrome/locale should be update and you should have a lot of (modified) files listed by typing:
</translate>


<source lang="bash">
<source lang="bash">
Line 67: Line 113:
</source>
</source>


<translate><!--T:23-->
After checking everything is OK, you can commit your modifications: ie. the kiwix/chrome/locale directory and the *.xul and/or *.js files you have modified.
After checking everything is OK, you can commit your modifications: ie. the kiwix/chrome/locale directory and the *.xul and/or *.js files you have modified.
</translate>


<translate><!--T:24-->
== Update Kiwix translations ==
== Update Kiwix translations ==
</translate>


<translate><!--T:25-->
One other task is to update already supported Kiwix languages with the last string updated coming from Translatewiki. The first thing to know about that is that in the remote subversion repository, the Translatewiki file (in maintenance/translatewiki) are each two weeks updated from a Translatewiki contributors. That means, you only need to update your local repository and update and commit the kiwix code translation files like following:
One other task is to update already supported Kiwix languages with the last string updated coming from Translatewiki. The first thing to know about that is that in the remote subversion repository, the Translatewiki file (in maintenance/translatewiki) are each two weeks updated from a Translatewiki contributors. That means, you only need to update your local repository and update and commit the kiwix code translation files like following:
</translate>


<source lang="bash">
<source lang="bash">
Line 79: Line 131:
git push origin master
git push origin master
</source>
</source>
<translate><!--T:26-->
The full path should be the moulinkiwix directory, not the kiwix directory in it.
The full path should be the moulinkiwix directory, not the kiwix directory in it.
</translate>


<translate><!--T:27-->
== Add a new supported language to Kiwix ==
== Add a new supported language to Kiwix ==
</translate>


<translate><!--T:28-->
Kiwix tries to add only 100% translated languages coming from Translatewiki. So it happens often that they are more languages in the "maintenance_tools/translatewiki" directory than in the "kiwix/kiwix/chrome/locale" directory. In such a case, that simply mean the the Translatewiki language was still not integrated in Kiwix code base. We explain now how to do that.
Kiwix tries to add only 100% translated languages coming from Translatewiki. So it happens often that they are more languages in the "maintenance_tools/translatewiki" directory than in the "kiwix/kiwix/chrome/locale" directory. In such a case, that simply mean the the Translatewiki language was still not integrated in Kiwix code base. We explain now how to do that.
</translate>


<translate><!--T:29-->
First of all you need to create the translation files in a new directory at "kiwix/kiwix/chrome/locale/your_language_iso_code" like following:
First of all you need to create the translation files in a new directory at "kiwix/kiwix/chrome/locale/your_language_iso_code" like following:
</translate>


<source lang="bash">
<source lang="bash">
Line 91: Line 151:
</source>
</source>


<translate><!--T:30-->
After that you need go to the kiwix source code directory in "kiwix/chrome" and edit with your prefered text editor the "chrome.manifest" and "chrome.manifest.prod" files. No explanation here, just do like for the already supported languages.
After that you need go to the kiwix source code directory in "kiwix/chrome" and edit with your prefered text editor the "chrome.manifest" and "chrome.manifest.prod" files. No explanation here, just do like for the already supported languages.
</translate>


<translate><!--T:31-->
Next edit chrome/content/main/js/languages.js and here also add the new languages.
Next edit chrome/content/main/js/languages.js and here also add the new languages.
</translate>


<translate><!--T:32-->
Now update CHANGELOG and make a notice about the addition of the new supported languages.
Now update CHANGELOG and make a notice about the addition of the new supported languages.
</translate>


<translate><!--T:33-->
Add the new language directory and commit like following:
Add the new language directory and commit like following:
</translate>
<source lang="bash">
<source lang="bash">
git add kiwix/chrome/locale/language_iso_code
git add kiwix/chrome/locale/language_iso_code
Line 104: Line 173:
</source>
</source>


<translate><!--T:34-->
== See also ==
== See also ==
* [[Translation]]
* [[Translation]]
* [[Compilation]]
* [[Compilation]]
</translate>


<translate><!--T:35-->
[[Category:Developer's Guide]]
[[Category:Developer's Guide]]
</translate>
Administrators, translate-proofr
1,160

edits

Navigation menu