HOWTO-internationalization.htm 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Internationalization</title>
  5. <meta charset="utf-8">
  6. <link href="./manual.css" rel="stylesheet" type="text/css">
  7. </head>
  8. <body>
  9. <div id="container">
  10. <header class="logo-header">
  11. <img class="header-logo" alt="Logo" src="puppylogo96.png">
  12. <h1>HOWTO internationalize applications</h1>
  13. </header>
  14. <p>Page updated May 12, 2013</p>
  15. <p>
  16. Internationalization of applications and scripts in Puppy Linux has become extremely easy, with MoManager, a GUI application.
  17. </p>
  18. <section>
  19. <h2>Applications written in BaCon</h2>
  20. <p>
  21. BaCon is a BASIC compiler, one of our officially supported languages for Puppy development. Internationalization is supported by the compiler, as explained here:
  22. </p>
  23. <p>
  24. <a href="http://bkhome.org/bacon/international.htm">http://bkhome.org/bacon/international.htm</a>
  25. </p>
  26. <p>
  27. There are at least two applications that you will find in every recent Puppy that are written in BaCon and have internationalization support:
  28. <ul class="code">
  29. <li>/usr/sbin/welcome1stboot</li>
  30. <li>/usr/local/simple_network_setup/proxy-setup</li>
  31. </ul>
  32. </p>
  33. <p>
  34. If you have the 'devx' SFS loaded, then these will also be present:
  35. <ul class="code">
  36. <li>/usr/sbin/welcome1stboot.bac</li>
  37. <li>/usr/sbin/welcome1stboot.pupdev</li>
  38. <li>/usr/share/doc/nls/welcome1stboot/welcome1stboot.pot</li>
  39. <li>/usr/local/simple_network_setup/proxy-setup.bac</li>
  40. <li>/usr/local/simple_network_setup/proxy-setup.pupdev</li>
  41. <li>/usr/share/doc/nls/proxy-setup/proxy-setup.pot</li>
  42. </ul>
  43. </p>
  44. <p>
  45. The .bac file is the BaCon source code. The .pot file is the language translation file. The .pupdev file is just a text file which has instructions on how to compile and create a .pot language translation file, plus any other developer notes. The .pupdev is optional, not necessarily always in the 'devx' -- but if you read one of the .pupdev files it should show you how to create a .pot language translation file for any other BaCon application.
  46. </p>
  47. <p>
  48. When you compile a BaCon application, place the .pot file into /usr/share/doc/nls, as per the above examples. This could be in a PET package of your application. MoManager searches this path for .pot files to be translated.
  49. </p>
  50. <p>
  51. Actually, the same thing holds for any application, written in C, Vala, Genie, or whatever, place the .pot file into /usr/share/doc/nls/&lt;domainname&gt;/&lt;domainname&gt;.pot and MoManager will use it.
  52. </p>
  53. </section>
  54. <section>
  55. <h2>Scripts internationalized with 'gettext'</h2>
  56. <p>
  57. There are a lot of scripts in Puppy that use 'gettext' for translating. Here are some in /usr/sbin:
  58. <ul class="code">
  59. <li>alsaconf</li>
  60. <li>connectwizard</li>
  61. <li>hostname-set</li>
  62. <li>keymap-set</li>
  63. <li>mousecheck</li>
  64. <li>quicksetup</li>
  65. <li>shutdownconfig</li>
  66. </ul>
  67. Inside each script you will find a line like this:
  68. <code>export TEXTDOMAIN=myapp</code>
  69. MoManager finds all scripts with this entry, which confirms that it uses 'gettext', and offers a GUI interface for translating each script. You do not have to learn the commandline tools for translating, the GUI interface makes it easy.
  70. </p>
  71. <p>
  72. Basically, MoManager will create a .pot file for the application, in the above example that will be 'myapp.pot'. Note that multiple scripts can have the same domainname 'myapp' and just the one 'myapp.pot' will be created. So, if your application has several scripts, you don't have to have a .pot for each (but you can if you want), just have the one .pot -- this is more efficient if there are common text strings to be translated in the scripts, and is simpler just to have the one .pot file.
  73. </p>
  74. <p>
  75. One technical detail: please place the "export ..." at column one, and do not place quotes around "myapp", the line in the script should look just like I have shown:
  76. <code>export TEXTDOMAIN=myapp</code>
  77. .pot files are "translation files", which you then have to insert the translations for a particular language. When that is done, it becomes a .po file, and it is then compiled to a binary form and becomes a .mo file. The compiled .mo files are kept at /usr/share/locale. MoManager handles these conversions for you.
  78. </p>
  79. <section>
  80. <h3>Pre-existing .pot files</h3>
  81. <p>
  82. MoManager will create a .pot file from the script, however the commandline-tool (xgettext) to extract the text strings from the script and create the .pot file does not always work properly. An example is /usr/sbin/alsaconf -- in this case, we have a pre-existing .pot file, /usr/share/doc/nls/alsaconf/alsaconf.pot.
  83. </p>
  84. <p>
  85. MoManager will automatically use any pre-existing .pot file that it finds in /usr/share/doc/nls, rather than use xgettext to extract the strings from the script(s).
  86. </p>
  87. </section>
  88. </section>
  89. <section>
  90. <h2>MoManager translation manager</h2>
  91. <p>
  92. MoManager is a GUI application written by me (Barry Kauler) that makes it very easy for anyone to create non-English translations for applications in Puppy. You must have a Puppy built from a Woof version later than February 14, 2012, however if you want to use MoManager to create a "langpack" for a particular language it is recommended to use the very latest Puppy built from latest Woof -- see my blog (<a href="http://bkhome.org/blog2/">http://bkhome.org/blog2</a>) for announcements of Puppy builds.
  93. </p>
  94. <p>
  95. MoManager is for creating and updating translation files for scripts, XML files, menu files, any other data text files, and binary executables.
  96. </p>
  97. <p>
  98. Scripts are applications that are text files, usually written in Bash or Ash (or Perl, Python, Tcl, etc.). Note, if you are unfamiliar with 'scripts', don't worry, they are just applications.
  99. </p>
  100. <p>
  101. To use MoManager, the best thing to do is just go ahead and use it. You will find it in the 'Utility' menu. Once started, you will see two columns of drop-down lists, one list is of files that already have a translation file for your language (on left side), the other list is for files that do not yet have a translation file. if you select a file from the formerlist, you may update the translation, and in the latter case you may create a new translation file.
  102. </p>
  103. <p>
  104. <div>Here is a snapshot of the main window, Puppy running with de_DE locale:</div>
  105. <img style=" width: 862px; height: 664px;" alt="MoManager" src="http://puppylinux.com/development/MoManager.png">
  106. </p>
  107. <section>
  108. <h3>Scripts</h3>
  109. <p>
  110. In the case of updating an existing translation file, MoManager automatically synchronises with the latest script, and will identify any changed strings -- if you see the text "fuzzy" anywhere in the translation file, it is likely that the original English text has changed and you will need to update the translation.
  111. </p>
  112. <p>
  113. A translation file for a script means that when the application runs, it will output all text in your language. By creating translation files for all the scripts, you can help to create a Puppy that runs nicely in your language.
  114. </p>
  115. <p>
  116. Although it is probably possible to figure out how to edit a translation file, known as a 'po' file in it's editable form, or 'mo' file in it's compiled form, it is helpful to readup a bit on the topic. I suggest:
  117. <ul>
  118. <li><a href="http://translate.sourceforge.net/wiki/guide/project/howto">http://translate.sourceforge.net/wiki/guide/project/howto</a></li>
  119. <li><a href="http://www.gnu.org/software/gettext/manual/html_node/gettext_9.html#PO-Files">http://www.gnu.org/software/gettext/manual/html_node/gettext_9.html#PO-Files</a></li>
  120. </ul>
  121. ...note though, reading all of that can be confusing! It is possible to use MoManager without understanding all of those details. MoManager uses a normal text editor to edit .po files rather than a specialized po-editor (such as poedit) and this is quite easy to do, you just need a very basic understanding of the format of .po files.
  122. </p>
  123. </section>
  124. <section>
  125. <h3>poedit</h3>
  126. <p>
  127. This is a special text editor for .po files. Although MoManager uses the default text editor (usually Geany in most puppies), if poedit is installed then MoManager can use it -- you will see a checkbox in the main window of MoManager to choose poedit.
  128. </p>
  129. <p>
  130. To install poedit, look in the Puppy Package Manager. Most builds of Puppy will have it available.
  131. </p>
  132. </section>
  133. <section>
  134. <h3>Langpack</h3>
  135. <p>
  136. You will also see in the MoManager window, a button to generate a "langpack" PET package. if you would like to translate Puppy for a particular language, this button is very nice. It will gather up all the translations for your language and put them into a PET package, which you can then send to me, and I can place it along with the others at ibiblio.org. See the existing "langpacks" at ibiblio.org, named "langpack_*.pet", for example "langpack_de-20120729.pet":
  137. </p>
  138. <p>
  139. <a href="http://distro.ibibilio.org/quirky/pet_packages-noarch/">http://distro.ibibilio.org/quirky/pet_packages-noarch/</a>
  140. </p>
  141. <p>
  142. Note that the langpack is accumulative. Say for example that you install "langpack_de-20120729.pet" (German). You can then create some more translations, or update existing ones, then click the "Create langpack PET" button, and a new updated PET will be created. Please let me know if this mechanism leaves anything out!
  143. </p>
  144. <p>
  145. There are already maintainers for some languages, for example Puppy Forum member L18L maintains the German translation. So, if you want to contribute to the German translations please do it through L18L. At the time of writing, these are the translators:
  146. <table>
  147. <tbody>
  148. <tr>
  149. <td>da</td>
  150. <td>Danish</td>
  151. <td>maans</td>
  152. </tr>
  153. <tr>
  154. <td>de
  155. </td>
  156. <td>German</td>
  157. <td>L18L
  158. </td>
  159. </tr>
  160. <tr>
  161. <td>el</td>
  162. <td>Greek</td>
  163. <td>kounelii</td>
  164. </tr>
  165. <tr>
  166. <td>es
  167. </td>
  168. <td>Spanish</td>
  169. <td>vicmz
  170. </td>
  171. </tr>
  172. <tr>
  173. <td>fr
  174. </td>
  175. <td>French</td>
  176. <td>esmourguit
  177. </td>
  178. </tr>
  179. <tr>
  180. <td>it</td>
  181. <td>Italian</td>
  182. <td>vicmz (temporary)</td>
  183. </tr>
  184. <tr>
  185. <td>nl</td>
  186. <td>Dutch</td>
  187. <td>Bert</td>
  188. </tr>
  189. <tr>
  190. <td>pl</td>
  191. <td>Polish</td>
  192. <td>robwoj44</td>
  193. </tr>
  194. <tr>
  195. <td>pt</td>
  196. <td>Portuguese</td>
  197. <td>vicmz</td>
  198. </tr>
  199. <tr>
  200. <td>ru
  201. </td>
  202. <td>Russian</td>
  203. <td>rodin.s
  204. </td>
  205. </tr>
  206. </tbody>
  207. </table>
  208. </section>
  209. <section>
  210. <h3>Further information</h3>
  211. <p>
  212. If you want to learn more about MoManager, go to my blog <a href="http://bkhome.org/blog">http://bkhome.org/blog</a> and <a href="http://bkhome.org/blog2/">http://bkhome.org/blog2</a> (my new blog), and type "MoManager" into the search box.
  213. </p>
  214. <p>
  215. To interact with others working on translating Puppy, including asking questions about anything that puzzles you, please go to the Puppy Forum here: <a href="http://www.murga-linux.com/puppy/index.php?f=16">http://www.murga-linux.com/puppy/index.php?f=16</a>
  216. </p>
  217. </section>
  218. </section>
  219. <footer>
  220. Regards,<br>
  221. Barry Kauler
  222. <div class="legal">(c) This page is Copyright Barry Kauler 2012, 2013, all rights reserved.</div>
  223. </footer>
  224. </div>
  225. </body>
  226. </html>