Manual :: Translations (i18n/l10n) ::
How to localize b2evolution
Link: http://manual.b2evolution.net/Localization
This man page refers to b2evolution version: 0.9
So you want to localize (mainly translate) b2evolution to your own language? Here's how to do it with minimum effort by using the gettext system provided by b2evo.
If this is the first time you deal with localization and/or gettext, you may want to read this background information first:
Here's how to proceed to localize b2evo to your own language:
- Step 1 Download the latest available release. You will need the latest language template files! We recommend you use at least version 0.8.3-beta1. Localization is not supported prior to 0.8.3-alpha1.
- Step 2 Check the already available locales. (A locale is identified by a language code followed by a country code. For example en_US and en_GB are different, though similar, locales). The best way is to go to the admin -> settings -> regional. This page will show you all already available locales and their translation completion percentage. (here is an example - Use demouser / demopass to log in.)
- If your locale is not listed, proceed with step 3.
- If your locale is listed and has a high completion percentage, you should assume there is already someone working on the l10n for this locale.
- If your locale is listed but has a low percentage, it may be possible that there once was a translator working on this locale but that he has given up. Open the matching messages.po file (see below) with a text editor and check the dates as well as the translators email address. You may want to get in touch with him before deciding to continue the translation. You don't want to end up doing the same job twice...
- Step 3. Go to the directory /blogs/locales and create a new folder for the new locale by using the same pattern as the existing folder. The first two letters must be your ISO 639 language code. The last two letters must be your ISO 3166 country code. If there is already a locale similar to yours (same language), you may also copy its folder and rename it. That way, you'll benefit from the existing translations
- Step 4. Inside of your locale folder, create a subfolder named LC_MESSAGES?. Yes, this is a little funky, but it's a gettext convention. Your translations will be located in this subfolder. Namely, they'll be in a file called messages.po.
- Step 5. If you're creating a brand new translation, you have no messages.po file yet. In that case, copy the file messages.pot from /locales to your LC_MESSAGES? folder and rename it to messages.po .
- Step 6. You could edit the messages.po file by hand but it's much easier with a dedicated tool such as poedit.
poedit runs on Windows as well as Linux and other Unix OSes. You can see from the screenshot how untranslated strings appear in blue, "fuzzy" translations (the ones you're unsure of and the ones automatically genereated when new strings are added to b2evo) appear in yellow, and translated strings appear in white.
poedit will also let you add comments or read those the developer may have provided in the "".POT"" file.
And the best of all: poedit will show you all references of a given string in the source code. Even better, it will open the sources and highlight the occurrences for you. This way, you can really make sure what a string is used for when you're not sure about how to translate it! How cool is that?
- Step 7. You now need to activate the locale in b2evolution. Open the file /conf/_locales.php and make the following changes:
- a. add an entry to the $locales array by duplicating an existing entry. Customize the locale, the charset you have used for translation and finaly enter the default date and time formats for your country.
- b. you'll probably want to make the newly added locale your default locale (used in the backoffice and for notification messages). Do this by setting $default_locale. You will also have to update the locale for your user profile.
- c. decide if you want b2evolution to localize with the help of the gettext runtime functions ($use_l10n = 1) or with its own l10n system ($use_l10n = 2). The later is generally better. (Note: there are situations where using the gettext runtime would fail miserably...). We strongly recommend you use the default setting (2).
- d. at the end of the file set $allow_po_extraction = 1;
- Step 8. At this time, you should see your localization appear in the regional settings screen. Since you have set $allow_po_extraction = 1, you will see a link named [extract] for each locale. Click to extract the strings for your own locale. (This will create a file name _globals.php in your locale folder.)
- Step 9. Your translations should now be active
The blogs on the public pages, however, will be displayed in the language that has been set for them in the blogs configuration forms.
Please note: if you make changes to your .po/.mo files after having used them in b2evolution, you may need to restart your webserver in order to clear gettext's internal cache and see your changes.
- Step 10. Please send me your messages.po file as well as the settings you have added to the $locales array. I will integrate them in the next public release.
- Step 11. With each new release of b2evolution you'll find your messages.po file automatically updated with new strings that may have appeared in the newer versions of b2evolution. However, the auto update will not be automatically updated in b2evolution since neither the messages.mo, nor the _globals.php file will be updated without your go.
By opening the "".PO"" file with poedit you will only have to translate/edit the new or changed strings and send them back to me.
More on UpdatingLanguageFiles...
You'll see, once you've installed the tools, localizing b2evolution is really easier than it seems! ![]()
New: There is a now a second .POT file for the static html help pages that are displayed before the installation. This file is located in CVS:/b2evolution/gettext/langfiles/static.POT . If you have trouble obtaining this file, please ask us. We do not elaborate here because we will be reorganizing the POT files soon.
