Languages, Translations, i18n, l10n
Like WordPress, BuddyPress has the built in capability to be used in any language.
Each BuddyPress version includes a POT file which contains all the strings who can be translated. See /bp-languages/buddypress.pot
Important: The POT file is not the translation. You have to download your language file or make it yourself.
At this time, there is no unique or official place to get a translation for BuddyPress. Some are on the dedicated WordPress site for translation projects translate.wordpress.org, but many other are elsewhere.
How to get a language file on http://translate.wordpress.org/projects/buddypress/dev
- Select BuddyPress in the list
- Select your language
- At the bottom of the page select ‘all current’ as ‘.mo’ and press ‘export’
- Do the same to get the ‘.po’ file
If you maintain several BuddyPres projects or if you need to be constantly up to date to a standart translation, you can use the BuddyPress-Translation plugin by @djpaul which give you the possibility to load your BuddyPress with the translations provided by translate.wordpress.org. Do not use this if you use a very customized translation.
- The BuddyPress i18n repo which contains some updated translations for ru_RU, zh_TW, it_IT, fr_FR…
- BuddyPress en Español
- BuddyPress auf Deutsch
- Persian World for BuddyPress, WordPress and bbPress
- or ask your local WordPress translators team !
If you do not see your language in the list, please ask for it on the support forum or consider creating your own translation file.
Sorry for you, but you have to finish the work yourself. See further down how to do this.
- Make a copy of the bp-languages folder outside of the buddypress folder.
- Keep the POT file as is and download the po/mo files into it.
- Rename the folder to something accurate to your project.
- The po/mo files must be named buddypress-xx_XX.mo and buddypress-xx_XX.po, where xx_XX is your language ISO code.
- Move the MO file to /wp-content/languages/ on your server. If the folder does not exist, create it !
- Make sure you have enabled your language on the WordPress “Settings > General” admin page.
- If you are using BuddyPress on a network install, go to “BuddyPress > Settings”.
- Check also your language setting in wp-config:
define ( 'WP_LANG', 'xx_XX' );
You can find the latest BuddyPress POT file here: http://svn.buddypress.org/trunk/bp-languages/buddypress.pot.
For previous versions, see the /bp-languages/ repertory in any BuddyPress Branch or Tag check out.
Translating BuddyPress, even from scratch, is exactly the same work as translating a theme or a plug-in.
- Do it directly on-line on the BuddyPress translation project.
- Stay independent and make your own copy. In this case, you will need a compiler software like poEdit.
For instructions, please take a look at Translating WordPress as many of the instructions there can be applied to BuddyPress.
Important: if you use the first solution and need some customization, you will not get a copy for your personal needs on the fly. This situation will probably lead you to consider the second option.
The bp-languages folder is in the BuddyPress folder. It is not used by BuddyPress or by WordPress and contains only one file: buddypress.pot This is only provided so for translation purpose. If you need a complete translation for BuddyPress, or want only to change some labels or text, make a copy of this bp-languages folder outside of BuddyPress before. Keep in mind that the original folder will be overwritten at the next release update.
Once your cahnges are done and safely stored, you have to copy the compiled .mo file to the server into /wp-content/languages/buddypress-xx_XX.mo
A complete language folder contains at least 3 files.
- buddypress.pot – all strings you can translate, with their positions in the BuddyPress files
- buddypress-xx_XX.po – same content as pot AND the translation
- buddypress-xx_XX.mo – same content as .po in compiled format
POT and PO file can be integraly written and edited with a text editor. But you need a compiler to generate the .mo which is the only file you need for getting the translation to work on your site.
The other difference between these files is the header information in each of them.
The pot file header is really basic and contains only specific informations about BuddyPress version and creation date. It looks like this:
The pot file header
# Copyright (C) 2013 BuddyPress
# This file is distributed under the same license as the BuddyPress package.
“Project-Id-Version: BuddyPress \n”
“POT-Creation-Date: 2013-07-27 18:35:29+00:00\n”
“Content-Type: text/plain; charset=UTF-8\n”
“PO-Revision-Date: 2013-MO-DA HO:MI+ZONE\n”
“Last-Translator: FULL NAME <EMAIL@ADDRESS>\n”
“Language-Team: LANGUAGE <LL@li.org>\n”
The po file header
“Project-Id-Version: BuddyPress-fr_FR 1.8\n”
“POT-Creation-Date: 2013-07-16 19:35:17+00:00\n”
“PO-Revision-Date: 2013-07-25 10:31+0100\n”
“Last-Translator: dan <firstname.lastname@example.org>\n”
“Language-Team: Dan <email@example.com>\n”
“Content-Type: text/plain; charset=UTF-8\n”
“Plural-Forms: nplurals=2; plural=(n > 1);\n”
Good to know
- The po file header contains additional information about the translator and about the environment. These lines are automatically generated by the compiler when you fill in the required fileds before begining a translation project (here with Poedit).
- Header informations should be in the .po file.
- The mo file is compiled, humans cannot read it.
- Refer to your compiler documentation for more information about heading information.
Read here about some secrets about keywords-list and plural-forms settings. This is crucial to know, specially if you are debuging a translation.
Of course, you can apply these recommendations to any other theme or plugin translation.
The most common translation issues are due to special characters, erroneous numeric variables (%s, %1$s, etc) or malformed HTML. Such errors goes from untranslated strings to blank pages, depending on how PHP’s gettext function handled the string. So the first source of error is the po/mo file.
Be warned that tracking down such errors can be long and fastidious.
The best way to get rid of this is to locate the error on the template.
Open the PO file in a text editor and search for the supposed to be culprit template file name within the source code. Check if a string in this file is containing something you omit or did wrong. For example an %s changed into %1$s…
- Incident found: My Favorites counter doesn’t count or doesn’t show the counter.
- Where: on the activity page
The easiest place to find an expression is the POT file, where ALL BuddyPress wordings are stored. Use a text editor such as Notepad++ to do so.
- Search for My Favorites…
Is in /bp-languages/buddypress.pot
OK, we have found the file and know the code position into it, which is line 71.
_e( “The activity I’ve marked as a favorite.”, ‘buddypress’ )
printf( __( ‘My Favorites <span>%s</span>’, ‘buddypress’ )
Now open buddypress-xx_XX.po file, search again for My Favorites to get the translated expression.
msgid "My Favorites <span>%s</span>"
msgstr "Mes favoris <strong>%</strong>"
The translator changed the HTML tag from span to strong and erased the little s during the cosmetic surgery. Make the correction and save. But if you did this change in the text editor and you reloaded the file to the server, NOTHING will happen.
- Because you worked on the .po file, which is not used by PHP on the server
- Because you did not compiled the file to the .mo format
- To make a correction in a translation, do it directly from within your compiler software.
- if you use a text editor, do not forget to save the file a second time from within the compiler, to generate the .mo file.
- Set the compiler preferences to generate automatically a .mo file each time you save a file
Once the .mo file is correctly updated and uploaded to your site, you will now see your correction !
Sometimes, translations are showing partially or odd, with strange characters. Assuming there are no conflicts with your databse, server, doctype or charset declaration, the culprit is probably in the translation. The translation maybe contain reserved characters, specific language characters such as the french à or the spanish ñ, and last but not least, apostrophes. In such cases, you have to check the BuddyPress translation first, but you must absolutely check your theme and plugins too.
The po file contains this:
PHP and HTML do not understand human languages subtilities. So they must be “coded” a little. The output of the translated string:
Vous êtes invité(e) par le groupe [group name here]
To close this case study, it is important to understand that the original strings are only “proposals”. You do not have to translate word for word, much less to translate all suggested words. The only things you should never change, alter or translate – if they exist in a string – are the variables.
In our case it was %s
Translation files can serve another purpose other than strict language translations. They are the best approach to changing text and labels on your site. A guide to achieving this can be found here Customizing labels, messages, and urls
Assist in making translations at http://translate.wordpress.org/projects/buddypress/dev
Subscribe to http://wppolyglots.wordpress.com/
Lines to be translated grow and evolve.
Version – Lines
1.0 – 910
1.2 – 910
1.5 – 1114
1.6 – 1226
1.7 – 1275
1.8 – 1277
1.9 – 1311
2.0 – 1476
Great starter tutorial by @vanillalounge
A good read for techies by @otto42
Back to school for some HTML entities usages (w3schools.com)
WordPress Codex: about internationalization (i18n)
WordPress Codex: L10n function reference
WordPress Codex: Translation Tools
Changing Core WordPress Strings by @viper007bond (works also for BP).