[Indent the HOWTO jtarrio@trasno.net**20060103211930] { hunk ./doc/howto.html 1 + + hunk ./doc/howto.html 5 -PO4Moz HOWTO - + PO4Moz HOWTO + hunk ./doc/howto.html 10 -

PO4Moz HOWTO

-

(Or: how I learned to stop foaming out my mouth and love the XPI)

+

PO4Moz HOWTO

hunk ./doc/howto.html 12 -

PO4Moz is a set of scripts that allow you to convert a recent Mozilla XPI -language pack into a huge POT file you can then edit with your favourite PO -file editor, use gettext tools on (like msgmerge), etc., etc. But then you -can pick the original langpack and the PO file and combine both to create a -translated langpack.

+

(Or: how I learned to stop foaming out my mouth and love the + XPI)

hunk ./doc/howto.html 15 -

Also, you can use an English XPI and a translated XPI together to extract -a translated PO file. This is useful for updating a translation. Neat, -uh?

+

PO4Moz is a set of scripts that allow you to convert a recent + Mozilla XPI language pack into a huge POT file you can then edit + with your favourite PO file editor, use gettext tools on (like + msgmerge), etc., etc. But then you can pick the original langpack + and the PO file and combine both to create a translated + langpack.

hunk ./doc/howto.html 22 -

The Process

+

Also, you can use an English XPI and a translated XPI together + to extract a translated PO file. This is useful for updating a + translation. Neat, uh?

hunk ./doc/howto.html 26 -

Obtaining a PO File for Translating

+

The Process

hunk ./doc/howto.html 28 -

Starting A New Translation

+

Obtaining a PO File for Translating

hunk ./doc/howto.html 30 -

Imagine you want to translate any Mozilla product's en-US.xpi language -pack into a fictional language called Anklebonian (ISO code ank-ANK).

+

Starting A New Translation

hunk ./doc/howto.html 32 -

First, you should downloade the en-US.xpi file from -ftp.mozilla.org (for example, for Firefox 1.0.7, you should -download ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/1.0.7/linux-i686/xpi/en-US.xpi).

+

Imagine you want to translate any Mozilla product's en-US.xpi + language pack into a fictional language called Anklebonian (ISO + code ank-ANK).

hunk ./doc/howto.html 36 -

Next, use the unpack_langpack script to turn that compact XPI -file into a mess of directories and files. You must provide, as arguments, -the pathname of the en-US.xpi file and the name of the new -directory that must hold the aforesaid mess:

+

First, you should downloade the en-US.xpi file from + ftp.mozilla.org (for example, for Firefox 1.0.7, you + should download + ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/1.0.7/linux-i686/xpi/en-US.xpi).

hunk ./doc/howto.html 42 -
$ ./unpack_langpack en-US.xpi dir-en-US
+

Next, use the unpack_langpack script to turn that + compact XPI file into a mess of directories and files. You must + provide, as arguments, the pathname of the en-US.xpi + file and the name of the new directory that must hold the + aforesaid mess:

+
+$ ./unpack_langpack en-US.xpi dir-en-US
+
hunk ./doc/howto.html 51 -

After some screenfuls of zip output, it should be finished.

+

After some screenfuls of zip output, it should be + finished.

hunk ./doc/howto.html 54 -

Now, use the extract_pot script to turn the directory into a POT -file. You should provide the name of the directory and redirect the script's -output into the filename of your choosing:

+

Now, use the extract_pot script to turn the directory + into a POT file. You should provide the name of the directory and + redirect the script's output into the filename of your + choosing:

+
+$ ./extract_pot dir-en-US > firefox-1.0.7.pot
+
hunk ./doc/howto.html 62 -
$ ./extract_pot dir-en-US > firefox-1.0.7.pot
+

Now you can copy firefox-1.0.7.pot into + firefox-1.0.7_ank-ANK.po and start translating.

hunk ./doc/howto.html 65 -

Now you can copy firefox-1.0.7.pot into -firefox-1.0.7_ank-ANK.po and start translating.

+

Importing an Old Translation

hunk ./doc/howto.html 67 -

Importing an Old Translation

+

The scenario is the same as in the previous section, but now + there already is an ank-ANK.xpi file you want to turn into a + valid PO file for translating.

hunk ./doc/howto.html 71 -

The scenario is the same as in the previous section, but now there -already is an ank-ANK.xpi file you want to turn into a valid PO file for -translating.

- -

First, download both the en-US.xpi file and the -ank-ANK.xpi file. Then, unpack them:

- -
$ ./unpack_langpack en-US.xpi dir-en-US
+  

First, download both the en-US.xpi file and + the ank-ANK.xpi file. Then, unpack them:

+
+$ ./unpack_langpack en-US.xpi dir-en-US
hunk ./doc/howto.html 76
-$ ./unpack_langpack ank-ANK.xpi dir-ank-ANK
+$ ./unpack_langpack ank-ANK.xpi dir-ank-ANK
+
hunk ./doc/howto.html 79 -

Then, use the extract_po script to generate the translated PO -file. The first argument is the English directory's name, the second one is -the translation's name. Redirect the output into the filename of your -choosing:

+

Then, use the extract_po script to generate the + translated PO file. The first argument is the English directory's + name, the second one is the translation's name. Redirect the + output into the filename of your choosing:

+
+$ ./extract_po dir-en-US dir-ank-ANK > firefox-1.0.7_ank-ANK.po
+
hunk ./doc/howto.html 87 -
$ ./extract_po dir-en-US dir-ank-ANK > firefox-1.0.7_ank-ANK.po
+

Now you can deal with the PO file directly.

hunk ./doc/howto.html 89 -

Now you can deal with the PO file directly.

+

Importing an Old Translation into a New Translation

hunk ./doc/howto.html 91 -

Importing an Old Translation into a New Translation

+

You have a translation for, say, Firefox 1.0.7, and now + Firefox 1.0.8 has come out and you want to provide a translation. + One way to do this is to generate a POT file out of 1.0.8's + langpack and translate it all again, but it is not the best + way.

hunk ./doc/howto.html 97 -

You have a translation for, say, Firefox 1.0.7, and now Firefox 1.0.8 has -come out and you want to provide a translation. One way to do this is to -generate a POT file out of 1.0.8's langpack and translate it all again, but -it is not the best way.

+

Probably, the best way is using gettext's + msgmerge utility to merge old translations into the new + POT file.

hunk ./doc/howto.html 101 -

Probably, the best way is using gettext's msgmerge -utility to merge old translations into the new POT file.

+

First, obtain a translated PO file for the old version. + Second, obtain a POT file for the new version. Third, use + msgmerge. The first argument is the old PO translation, + the second one the new POT file. Redirect the output into your + new PO file:

+
+$ msgmerge firefox-1.0.7_ank-ANK.po firefox-1.0.8.pot > firefox-1.0.8_ank-ANK.po
+
hunk ./doc/howto.html 110 -

First, obtain a translated PO file for the old version. Second, obtain a -POT file for the new version. Third, use msgmerge. The first -argument is the old PO translation, the second one the new POT file. -Redirect the output into your new PO file:

+

Now you can update firefox-1.0.8_ank-ANK.po.

hunk ./doc/howto.html 112 -
$ msgmerge firefox-1.0.7_ank-ANK.po firefox-1.0.8.pot > firefox-1.0.8_ank-ANK.po
+

Translating the PO File

hunk ./doc/howto.html 114 -

Now you can update firefox-1.0.8_ank-ANK.po.

- -

Translating the PO File

- -

You have performed one of the actions described before, and now you have -a PO file you're eager to edit. Or not, but you're paid for it. Or not, but -someone's tricked you into doing it. Anyway, that's how a typical entry in a -PO file (generated by these tools) looks like:

- -
#. extracted from content/pref-proxies.xul
+  

You have performed one of the actions described before, and + now you have a PO file you're eager to edit. Or not, but you're + paid for it. Or not, but someone's tricked you into doing it. + Anyway, that's how a typical entry in a PO file (generated by + these tools) looks like:

+
+#. extracted from content/pref-proxies.xul
hunk ./doc/howto.html 125
-msgstr ""
+msgstr ""
+
hunk ./doc/howto.html 128 -

Don't panic!

+

Don't panic!

hunk ./doc/howto.html 130 -

The lines starting with a hash sign (#) are comments. These comments -appeared in the language pack and were inserted in the PO file so that you -don't lose any information or any important notes regarding the -translation.

+

The lines starting with a hash sign (#) are comments. These + comments appeared in the language pack and were inserted in the + PO file so that you don't lose any information or any important + notes regarding the translation.

hunk ./doc/howto.html 135 -

The line starting with msgid, and the following ones that are -enclosed in double qoutes, define the string to be translated.

+

The line starting with msgid, and the following ones + that are enclosed in double qoutes, define the string to be + translated.

hunk ./doc/howto.html 139 -

Generally.

+

Generally.

hunk ./doc/howto.html 141 -

In PO files generated by these scripts, the first line of the -“string to be translated” tells us the file where this string -was found and the tag it had in that file. In this example, the string was -in the file locale/browser/pref/pref-connection.dtd and the tag was -lheader. This information is saved because, sometimes, two strings -look the same but mean two different things and, so, must be translated -differently, and PO doesn't support it.

+

In PO files generated by these scripts, the first line of the + “string to be translated” tells us the file where this string was + found and the tag it had in that file. In this example, the + string was in the file + locale/browser/pref/pref-connection.dtd and the tag was + lheader. This information is saved because, sometimes, + two strings look the same but mean two different things and, so, + must be translated differently, and PO doesn't support it.

hunk ./doc/howto.html 150 -

Then, yes, the next lines are the text to be translated. You should read -it and translate it as best as you can and put the translation into the -msgstr:

- -
#. extracted from content/pref-proxies.xul
+  

Then, yes, the next lines are the text to be translated. You + should read it and translate it as best as you can and put the + translation into the msgstr:

+
+#. extracted from content/pref-proxies.xul
hunk ./doc/howto.html 159
-msgstr "Kunexn Sirns"
+msgstr "Kunexn Sirns"
+
hunk ./doc/howto.html 162 -

Isn't Anklebonian a neat language?

+

Isn't Anklebonian a neat language?

hunk ./doc/howto.html 164 -

Be sure to use UTF-8 encoding.

+

Be sure to use UTF-8 encoding.

hunk ./doc/howto.html 166 -

Some things that are not really proper strings appear here, too, like -accelerator keys and command keys:

- -
msgid ""
+  

Some things that are not really proper strings appear here, + too, like accelerator keys and command keys:

+
+msgid ""
hunk ./doc/howto.html 182
-msgstr ""
+msgstr ""
+
hunk ./doc/howto.html 185 -

In this example you can see a label for a command (“New Tab”) -and its associated access and command keys. Look closely at the strings' -tags. The first one is tabCmd.label, the second is -tabCmd.accesskey and the third one is tabCmd.commandkey. -This way you can tell which one is which and which one goes with which -one.

+

In this example you can see a label for a command (“New Tab”) + and its associated access and command keys. Look closely at the + strings' tags. The first one is tabCmd.label, the second + is tabCmd.accesskey and the third one is + tabCmd.commandkey. This way you can tell which one is + which and which one goes with which one.

hunk ./doc/howto.html 192 -

The accesskey is the character that appears underlined in a menu entry or -in a dialog box item's label and that you can press to select it with the -keyboard. The commandkey is a key you can press anywhere, along with the key -Ctrl (in Windows/Unix) or Option (in Mac), to perform the -action. So, the accesskey should be a letter that appears in the label (but -which is not repeated), but the command key should be the same (unless your -country's keyboards don't have that key).

- -
msgid ""
+  

The accesskey is the character that appears underlined in a + menu entry or in a dialog box item's label and that you can press + to select it with the keyboard. The commandkey is a key you can + press anywhere, along with the key Ctrl (in + Windows/Unix) or Option (in Mac), to perform the action. + So, the accesskey should be a letter that appears in the label + (but which is not repeated), but the command key should be the + same (unless your country's keyboards don't have that key).

+
+msgid ""
hunk ./doc/howto.html 214
-msgstr "t"
+msgstr "t"
+
hunk ./doc/howto.html 217 -

With this translation, when the user right-clicks on the tab bar, the -“Profumo Kriexon Av Nutab” menu entry has the N underlined, but -the user can still create new tabs directly by pressing Ctrl-T.

+

With this translation, when the user right-clicks on the tab + bar, the “Profumo Kriexon Av Nutab” menu entry has the N + underlined, but the user can still create new tabs directly by + pressing Ctrl-T.

hunk ./doc/howto.html 222 -

If you have imported old translations, you may run across this one:

- -
#, fuzzy
+  

If you have imported old translations, you may run across this + one:

+
+#, fuzzy
hunk ./doc/howto.html 229
-msgstr "Apro Filo..."
+msgstr "Apro Filo..."
+
hunk ./doc/howto.html 232 -

The #, fuzzy comment indicates that, when msgmerge ran, -it did not find the string in the old translation, but it found a similar -one, so it put its translation in this place and marked it -“fuzzy”. This happens when a string has changed, or when there -is a new string that is similar to an old one, or when it has changed file -or label. Now you should check whether the proposed translation fits the -original string, fix it if necessary, and remove the #, fuzzy -comment:

- -
msgid ""
+  

The #, fuzzy comment indicates that, when + msgmerge ran, it did not find the string in the old + translation, but it found a similar one, so it put its + translation in this place and marked it “fuzzy”. This happens + when a string has changed, or when there is a new string that is + similar to an old one, or when it has changed file or label. Now + you should check whether the proposed translation fits the + original string, fix it if necessary, and remove the #, + fuzzy comment:

+
+msgid ""
hunk ./doc/howto.html 245
-msgstr "Apro Lukaxen..."
+msgstr "Apro Lukaxen..."
+
hunk ./doc/howto.html 248 -

When everything's translated, it will be time to apply your translation -to create a new langpack.

+

When everything's translated, it will be time to apply your + translation to create a new langpack.

hunk ./doc/howto.html 251 -

Creating a Translated Language Pack

+

Creating a Translated Language Pack

hunk ./doc/howto.html 253 -

Obtaining a PO file for translating involved unpacking an English XPI -file. Now you will use this unpacked English langpack to generate an -unpacked translated langpack, and from this, a translated XPI language -pack.

+

Obtaining a PO file for translating involved unpacking an + English XPI file. Now you will use this unpacked English langpack + to generate an unpacked translated langpack, and from this, a + translated XPI language pack.

hunk ./doc/howto.html 258 -

To apply your newly translated PO file to the unpacked langpack you must -use the script apply_po, giving it as its first argument the -directory where you unpacked the original XPI, as the second argument the PO -file, and as the third argument the directory where you want to create the -unpacked translated langpack:

+

To apply your newly translated PO file to the unpacked + langpack you must use the script apply_po, giving it as + its first argument the directory where you unpacked the original + XPI, as the second argument the PO file, and as the third + argument the directory where you want to create the unpacked + translated langpack:

+
+$ ./apply_po dir-en-US firefox-1.0.7_ank-ANK.po dir-ank-ANK
+
hunk ./doc/howto.html 268 -
$ ./apply_po dir-en-US firefox-1.0.7_ank-ANK.po dir-ank-ANK
+

You you can pack the dir-ank-ANK directory to create + your installable Anklebonian XPI language pack, via the + pack_langpack script, whose first argument is the + unpacked directory and second argument is the file that will be + created:

+
+$ ./pack_langpack dir-ank-ANK ank-ANK.xpi
+
hunk ./doc/howto.html 277 -

You you can pack the dir-ank-ANK directory to create your -installable Anklebonian XPI language pack, via the pack_langpack -script, whose first argument is the unpacked directory and second argument -is the file that will be created:

+

Distributing the Translation

hunk ./doc/howto.html 279 -
$ ./pack_langpack dir-ank-ANK ank-ANK.xpi
+

Use your imagination :-)

hunk ./doc/howto.html 281 -

Distributing the Translation

+

Conclusion

hunk ./doc/howto.html 283 -

Use your imagination :-)

+

If you are already used to gettext and tools that + work with the PO format and want to translate Mozilla products, + you may be interested in PO4Moz: it makes your work easy if you + only want to translate, but doesn't make you lose any + flexibility, as the full, unpacked contents of langpacks are + exposed to you, so you can modify them in any way you want.

hunk ./doc/howto.html 290 -

Conclusion

+

Finally, a word of caution: PO files generated by this script + are huge, so you'll need a quite fast computer for most + operations. For example, it takes almost 5 minutes to apply a + fully translated PO file to an unpacked Firefox 1.0.7 langpack in + a 450-MHz Pentium III machine. And msgmerge operations + may take even more time. Fortunately, we only have to do them + once for every new version of the software :-)

hunk ./doc/howto.html 298 -

If you are already used to gettext and tools that work with the -PO format and want to translate Mozilla products, you may be interested in -PO4Moz: it makes your work easy if you only want to translate, but doesn't -make you lose any flexibility, as the full, unpacked contents of langpacks -are exposed to you, so you can modify them in any way you want.

+

Credits & License

hunk ./doc/howto.html 300 -

Finally, a word of caution: PO files generated by this script are huge, -so you'll need a quite fast computer for most operations. For example, it -takes almost 5 minutes to apply a fully translated PO file to an unpacked -Firefox 1.0.7 langpack in a 450-MHz Pentium III machine. And -msgmerge operations may take even more time. Fortunately, we only -have to do them once for every new version of the software :-)

+

This document was written by Jacobo Tarrío Barreiro <jaco + bo at tarrio dot or + g>.

hunk ./doc/howto.html 304 -

Credits & License

+

This document is an "associate documentation file" for PO4Moz, + so it is subject to its license, whose terms are:

hunk ./doc/howto.html 307 -

This document was written by Jacobo Tarrío Barreiro <jacobo at tarrio dot org>.

+

Copyright (c) 2006 Jacobo Tarrío Barreiro

hunk ./doc/howto.html 309 -

This document is an "associate documentation file" for PO4Moz, so it is -subject to its license, whose terms are:

+

Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions:

hunk ./doc/howto.html 318 -

Copyright (c) 2006 Jacobo Tarrío Barreiro

+

The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the + Software.

hunk ./doc/howto.html 322 -

Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions:

- -

The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software.

- -

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE.

- +

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE + AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE.

}