Made for: WordPress 2.0.x + - Tested up to: WordPress 2.5.1
Download: Better Language Management
Description
Better Language Management is a plugin for you who don’t have an English blog.
The plugin let you upload and upgrade your preferred language inside WordPress, and you can add support to your theme and/ or plugins to look for .mo files in your language directory as well.
Install
- Unzip betterlang.zip and upload betterlang.php to your wp-content/plugins/ folder
- Log into your blog and activate the plugin
- Go to Manage/ Edit -> Languages to upload and upgrade your language packages (.mo files)
Adding support for themes and plugins
The plugin is set up so you can upload any language files for a theme or plugin to language folder as well, but in order to do that you need to add support for it.
For a theme you need to open header.php and see if it got the following line on the very top:
load_theme_textdomain('domain');
First take a note of what ‘domain’ is in that code; as and example my theme Basic2Col has the textdomain ‘basic2col’.
Now replace the code with:
load_betterlang_textdomain('domain');
Just replace “domain” with whatever you have noted from the original code. In the Basic2Col example the code would be:
load_betterlang_textdomain('basic2col');
Save your header.php and upload to the themes folder.
The next thing you need to is to find the theme’s .mo file for your language; like a Norwegian translation for the theme will have the name nb_NO.mo. Now you need to rename this to reflect the textdomain; so the .mo file gets a name structure like: domain-lang_CODE.mo.
So a Norwegian language file for Basic2Col will need to be renamed to basic2col-nb_NO.mo
Now the very last thing you need to do is to go to Manage/ Edit -> Languages and upload the renamed .mo file from your computer.
As for plugins the process is almost the same, but the code to look for is:
load_plugin_textdomain('domain');
Plugin or Theme author?
To make life easier for any non-English WordPress Bloggers out there, you can add support for this plugin with using the following code in Plugins:
if(function_exists('load_betterlang_textdomain')) {
load_betterlang_textdomain('domain'); }
else {
load_plugin_textdomain('domain'); }
And for Themes:
if(function_exists('load_betterlang_textdomain')) {
load_betterlang_textdomain('domain'); }
else {
load_theme_textdomain('domain'); }
Just remember to replace ‘domain’ to something suitable for your plugin or theme, - and as unique as possible.
Some fun reading for you:
- Boren.nu: Localizing Plugins and Themes
- ZyBlog: Localizing WordPress Themes
Notes
This plugin won’t work if you haven’t made the changes you need in wp-config.php and if you don’t have a folder called languages in wp-content. See Installing WordPress in Your Language for more info.
If you find neither load_theme_textdomain nor load_plugin_textdomain in your theme’s or plugin’s code this means:
- The theme or plugin can’t be translated
- The theme or plugin needs to use the your main (the one that translate your entire blog) language file to be translated - examples are the akismet plugin and the classic wordpress theme
If you don’t rename a .mo file for a theme or plugin to reflect the textdomain, this plugin will think the .mo file applies for your entire blog. So doublecheck that everything is in order before uploading anything.
Translations
The language files (betterlang-lang_CODE.mo) for Better Language Management should go in /wp-content/languages/ and you can use the plugin to update them.
If you wish to translate the plugins there’s a .post file included in the plugin’s zip-folder
Supported plugins and themes
If you have added support for Better Language Management to your plugin or theme, feel free to contact me and I’ll add a link to it below.