Gallery is internationalized. Instead of containing language specific text messages, it tracks text in a special way so that it can be extracted and translated into other languages. Users will see a version of the text that has been converted into their own language.
In order for the users to see a localized version of Gallery's text, somebody must first translate the text messages that Gallery is going to display. This process is called "localization".
Here we try to outline how you can create and maintain localization files for the content in G2. It's not a particularly difficult thing to do but it requires us to keep the various files up to date whenever the underlying content changes. Luckily we have tools that will aid in this process.
In order to really do this effectively, you need to have a few tools installed on your machine. I've only tested this process on a FreeBSD box, but my guess is that you won't have too much difficulty on Linux, Solaris, or other Unix variants. You may have difficulties following along on Windows, but it should be possible. The following should be installed and in your PATH:
Note: if you're using FreeBSD then you want to use gmake instead of make since FreeBSD's default make is not GNU compatible.
You also need the current G2 files to create up-to-date translations. It is best to work from current SVN or a nightly snapshot. The developer version of the latest G2 release will also work, but some of the strings for translation may be out of date.
Look around the Gallery distribution and you'll find a bunch of directories called "po". ("po" is a gettext term that stands for "portable object"). Here's one way to find them:
find . -type d -name po <-- you type this ./themes/matrix/po <-- you see this ./lib/tools/po ./modules/core/po ./modules/comment/po ./modules/netpbm/po ** Ignore the "lib/tools/po" directory.
These directories contain translation source files. You're going to create new files with an appropriate language code, and then fill them with translated text. The first thing to do is to identify the correct codes from the following two tables:
In most cases you will need just the language code, such as "de" for German. To provide country specific translations for a language used in multiple countries you can use a code in the format xx_XX, such as "pt_BR" for Portuguese/Brazil. If you are unsure which to use, include both language and country. If you find a translation for your language already exists then move on to Maintaining a localization.
Once you've chosen the code, you need to create a new .po file for your code. Let's assume that you chose "de". For each po directory, you need to do this:
make de.po
This will find all text that is marked for localization ({g->text} in tpl files, translate() or i18n() in php code) and create a po file that is ready to be translated.
A word about text editors.
I personally am a fan of XEmacs so I'll be talking about XEmacs in my examples below. If you have instructions for other editors, please contribute them. XEmacs has a major mode called "po-mode" which, if you have it installed, you'll automatically wind up in if you edit a .po file. I'm not going to go into it here, but try it out if you have it.
Now edit de.po. It should have the Gallery license at the top. You'll need to customize these values:
Here's an example of a complete header from modules/core/po/de.po. Note how the authors have maintained the list of all previous translators as a courtesy.
# Previous translators (as far as known, add yourself here, please): # - Jens Tkotz <jens@peino.de> # - Ernesto Baschny <ernst@baschny.de> ... # msgid "" msgstr "" "Project-Id-Version: Gallery: Core 1.0.32\n" "POT-Creation-Date: 2003-02-11 03:09-0800\n" "PO-Revision-Date: 2006-03-05 02:25+0000\n" "Last-Translator: Frederik Kunz <frederik.kunz@web.de>\n" "Language-Team: German <gallery-devel@lists.sourceforge.net>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
If your language doesn't have plural form like in Chinese or Turkish, you need to change the following line too:
"Plural-Forms: nplurals=2; plural=(n != 1);\n" -> Change to "Plural-Forms: nplurals=1; plural=0;\n".
In this case, you need to translate only msgstr[0] and comment out or remove msgstr[1].
Then, look at the lines just below the Gallery license:
#, fuzzy msgid "" msgstr ""
The fuzzy keyword tells you that the translation of the block is incomplete. But once that you update the administration entries, you can remove the "#, fuzzy" line to allow the translation to compile later on.
Next, you'll see a series of blocks like this:
#, c-format (<-- you'll only see this on some lines) msgid "a message in english, with %d or %s tags in it" msgstr ""
You need to put the translation for the English message into the msgstr block, between the quotes, for example:
#, c-format msgid "a message in english, with %d or %s tags in it" msgstr "eine Anzeige auf englisch, mit %d oder %s etikettiert in ihr"
Some msgid values contain hints to assist in translation:
#. HINT: Button label for Bold msgid "B" msgstr "F"
Note that the hint should not be translated or included in the msgstr text. You can request the addition of hint text for particular strings with the Translations Tracker. Specify the module/theme and the msgid. Note that the strings.raw file lists the file(s) where each msgid is used.
You really, really, really should put your editor into UTF-8 mode before editing these messages so that your editor can use the right character set. If you can't edit in UTF-8 for some reason, consider using the GNU "recode" program to convert your translation to UTF-8 before submitting it to us (or just send it anyway and we'll recode it).
If you're using XEmacs with MULE (its MULtilanguagE support) you can add the following to your ~/.xemacs/init.el
; Enable Unicode support (via Mule-UCS) ; (require 'un-define) (set-coding-priority-list '(utf-8)) (set-coding-category-system 'utf-8 'utf-8)
Then when you edit a file that is in UTF-8, it'll have a little "u" in left side of the status bar at the bottom of the screen. Try it out with an existing .po file to see what it looks like.
After doing a few translations, try it out to see how it looks. Run:
make install PO=de
And it will compile your .po file into a .mo file and install it in the appropriate place for the module.
As of Gallery 2.3, the correct place for .po and .mo files is eg the modules/mymodule/po directory. Previous versions of Gallery renamed the .mo file and moved it to eg modules/mymodule/locale/de/LC_MESSAGES/modules_mymodule.mo.
If you're updating the translations for an existing module and the locale/ directory already exists within the module directory structure then the updated .mo files are still copied there (pre 2.3 behaviour); if the locale directory doesn't exist then the files are created in the po/ directory. There is a formal API update notification for the correct location of .po and .mo files here: http://codex.galleryproject.org/Gallery2:API_Changes_Since_The_Last_Release#7.19_.3D.3E_7.20
Although the intention is that Gallery 2.3 will still install language files from the pre-2.3 (modules/mymodule/locale/...) there have been issues reported which are still under investigation.
Repeat this for every directory where you modified a .po file.
Finally, you need to edit modules/core/classes/GalleryTranslator.class and in function getLanguageData, add lines like this:
/* German */ $this->_supportedLanguages['de']['DE']['description'] = 'Deutsch'; $defaultCountry['de'] = 'DE';
The comment should be the name of the language in English; the language 'description' is the name of the language in that language.
Now, log onto G2 and in the User preferences (you may need to edit the user via the Site Administrator) you should see German appear in the dropdown, and if you select it and log on as that user you'll see your translated messages. Alternatively, add the Language selector block to your site using Theme settings.
Note: If the language change doesn't take effect, please review the precedence of the language settings (Session language > user preferences > site wide default language). In doubt, use the language block or toggle the language in your user preferences back and forth.
Now that you've got your localization created, you need to package it up and send it to us so that we can commit it into the repository. The best way to package it is like this:
cd gallery2 zip de.zip `find . -name de.po`
or:
cd gallery2 tar czf nl.tar.gz `find . -name nl.po`
This will make up a zipfile or tarball of just your translated files. Obviously, use your language code instead of de or nl above. Then, go to the Translations Tracker on the Gallery project page on SourceForge and click the "Submit New" button. Put your translation in the "Gallery 2" group and don't forget to attach the files (you must check the checkbox for attachment too!). If your translation doesn't get committed within a few days, jump on IRC (see help section) and talk to us about it.
cd po make de.po (using German as an example)
This will extract all messages from the module that you're in and update the .po file. Look through the .po file for any blocks that have an empty msgstr, or are marked "fuzzy" and update them. After they are fixed, remove the fuzzy tag. You may find tags that look like this:
#, fuzzy #~ msgid "User" #~ msgstr "Gebruikersnaam"
The "#, fuzzy" means that its fuzzy, but the "#~" means that the string no longer exists in G2 (we probably deleted or changed it significantly). You can delete these entries.
You should do a quick check that gettext provides to validate your .po file:
msgfmt -v -c --stat de.po
When you've got everything right, run:
make install PO=de
The translation files get cached by PHP (which is why it's so fast) so you may not see change until you restart your web server. That's annoying, but I haven't figured a good workaround for it yet.
See the Creating a new localization section for testing info, and submit the new files to us. Also be aware of the change in the correct location of .mo and .po files with Gallery 2.3 detailed there. You may wish to migrate the language files to the new location as part of the maintenance, although that will mean the translations no-longer operate with pre G2.3 releases.
If you need help, there are three places to go:
All available Gallery 2 translations, listed alphabetically along with the maintainers / translators. Some translations are 100% up to date and complete, others are only 2% complete or out of date. See: Localization Report. If you have the developer package of G2, you can run http://www.example.com/gallery/lib/tools/reports/localization.php to see the status of all installed translations.
Language | Language Code | Last Translator | List of Translators |
---|---|---|---|
Afrikaans
Afrikaans |
af | Renier | Renier |
العربية
Arabic |
ar | Mohammad Saleh | Mohammad Saleh |
Български
Bulgarian |
bg | Bisser Dobrev | Bisser Dobrev |
Беларуская
Belarusian |
be | Alex Lavysh | Alex Lavysh |
Català
Catalan |
ca_ES | Roger Cervantes | Juan Vega Aiguadé; Roger Cervantes |
中国
Chinese [Simplified] |
zh_CN | Wayne Zhang | Wayne Zhang |
台灣
Chinese [Traditional] |
zh_TW | Stephen Chu | Stephen Chu |
Česky
Czech |
cs | Jan Korbel | Jan Korbel |
Dansk
Danish |
da | Jens Hyllegaard | Lasse Bang Mikkelsen, Allan Beaufour, Bjørn Graabek, Jens Hyllegaard |
Deutsch
German |
de | Andy Staudacher | Jens Tkotz, Ernesto Baschny, Frederik Kunz, Georg Rehfeld, Bananeweizen, Moritz Stoltenburg |
Ελληνικά
Greek |
el | Akis Panas | Nikos Batsis, Anthi Andreou, Akis Panas |
English [British] | en_GB | Stephen Ryan | Joan McGalliard, Alan Harder, Stephen Ryan |
Español
Spanish |
es | Oscar Garcia Amor | Oscar Garcia Amor |
Español de Argentina
Spanish [Argentine] |
es_AR | Alvaro Cortizo | Alvaro Cortizo |
Español de Mexico
Spanish [Mexican] |
es_MX | Wieland E. Kublun | Wieland E. Kublun |
Eesti
Estonian |
et | poromaan | poromaan |
Euskera
Basque |
eu | Piarres Beobide | Piarres Beobide |
فارسی
Farsi |
fa | Mohammad Samini | Jalal Kheradmand, Pedram Hayati, Mohammad Samini |
Français
French |
fr | Arnaud MOURONVAL | Arnaud MOURONVAL |
עברית
Hebrew |
he | Guy Sheffer | Guy Sheffer, Omri Amos |
Irish Gaelic
Irish |
ga | Beckett Madden-Woods | Beckett Madden-Woods |
Íslenska
Icelandic |
is | Johann S Jonsson | Johann S Jonsson |
Italiano
Italian |
it | Ermanno Baschiera | Ermanno Baschiera |
日本語
Japanese |
ja | Kennichi Uehara | Kennichi Uehara, Yosuke Suzuki |
한국말
Korean |
ko | Juice | Juice |
Latviešu
Latvian |
lv | Jānis Baiža | Jānis Baiža |
Lietuvių
Lithuanian |
lt | Darius Žitkevičius | Darius Žitkevičius |
Magyar
Hungarian |
hu | Sandor Dibuz | Gergely Dömsödi, József R.Nagy, Sandor Dibuz |
Nederlands
Dutch |
nl | Marijke van Velsen | Marcel van Groenigen, Kees van den Broek, Arjen Gideonse, B. Scheijgrond, Marijke van Velsen |
Norsk Bokmål
Norwegian |
no | Sverre M. Vikan | Frode Tviberg, Sverre M. Vikan, Jon Harald Carlsen, Robin Smidsrod (sponsored by Grieg Multimedia AS), Terje Dahl |
Polski
Polish |
pl | Kappana | Sebastian Marek, Kappana |
Português
Portuguese |
pt | Francisco Neto | Hugo Cruz, Francisco Neto |
Português Brasileiro
Portuguese [Brazilian] |
pt_BR | Paulino Michelazzo | Ernesto Baschny, José Ricardo, Celso Reeks, Paulino Michelazzo |
Română
Romanian |
ro | Serban Constantintinescu | Serban Constantintinescu |
Русский
Russian |
ru | Ser Moro | Konstantin Ivanov, modus, Ser Moro |
Українська
Ukrainian |
uk | Anton Gladky | Yurii Smetana, Anton Gladky |
Quốc Ngữ (國語)
Vietnamese |
vi | Trung Dong Huynh | Trung Dong Huynh |
Suomea
Finnish |
fi | Jyrki Heinonen | Jussi Karppanen; Erkka Hakkarainen; Jyrki Heinonen |
Srpski
Serbian |
sr | Jozef Selesi | Jozef Selesi |
Slovenčina
Slovak |
sk | Branislav Hanacek | Branislav Hanacek |
Slovenščina
Slovenian |
sl | Jure Babnik | Janez Troha, Jure Babnik |
Svenska
Swedish |
sv | Anders Lindquist | Christian Wallin, Mikael Gustafsson, Peter Liversten, Hampus Nygren, Anders Lindquist |
Türkçe
Turkish |
tr | Goker ISIK | Goker ISIK, Roman Neumüller |