How to translate my Church Admin Plugin

I love the fact that Church admin is being used in so many nations now – why not help by translating it?

It’s easier than you think. Firstly you need a free program call Poedit from www.poeditor.net – it works on Mac and Windows

Once installed open it up and click on “Create a new translation” if you are starting a new translation or open existing if updating one.
screen1

Then select a “po” file from the languages folder to translate from default.po is the UK English file
screen2

For a new translation – you’ll have the option to set the translation language at this point. then click on each source text in turn and type in the translation in the bottom “Translation box”
screen3

When you have finished click “Validate” to make sure it’s valid, which will hopefully bring up the following alert box

no problems
Click okay and then save.

Poedit will have started the filename with the correct language and country code you have chosen earlier – in this case American English (with all it’s butchering of the Queen’s English 😉 )

save-as1

WordPress has a naming convention where you need to prepend that with the plugin name and a hyphen – so the filename becomes church-admin-en_US.po

Then click save. You can then upload for your own use. Please email me the file to “clients AT themoyles DOT co DOT uk”, so I can add it to the WordPress repository for use by others too.

Thanks

Last step! You need to internationalise your installation, if you haven’t already!
In wp-config.php add the line

define(‘WPLANG’, ‘en_US’);

where you use the right language and country code for your nation and language

How to internationalise a wordpress plugin

If you want your plugin to have a greater reach why not internationalise it – hopefully people will soon start translating it for you!

Here’s what to do!

Step 1

set up the plugin to load the translation files with this code, changing “your-plugin-name” as needed.

That means that wordpress will load the right translation file from your plugins languages directory.

Step2

Change all the output text in your plugin to use the internationalised versions

so $foo= ‘Blah Blah’; becomes $foo=__(‘Blah Blah’,’your-plugin-name’);
and
echo ‘Blah Blah’; becomes _e(‘Blah Blah’,’your-plugin-name’);
Thoroughly test your plugin at this stage!

Step 3

Set up the initial default translation file defautlt.po in the languages folder.
Download and install poedit from http://www.poedit.net/download.php
The instructions are about as useful as a chocolate teapot, hence this blog post.

Once you have installed the Poedit program, open it.
poedit-first-screen
Click on File then New catalog…
poedit-new-catlog-first-tab
Fill out the Project Name at least and then click on the Sources Path tab.
This is where everyone goes wrong on Windows computers! The base path needs to be the full path to your plugin root directory not “.” e.g. C:\xampp\htdocs\wordpress\wp-content\plugins\church-admin
Then you can add the sub directories in the paths section by clickingthe second icon from the left (dotted box type icon).

Next click on the Sources Keywords tab and select each of the current ones and delete them.
Add __ and _e and then press ok

With any luck you will not get the annoying “Updating the catalog failed error” which happens when you don’t do the full windows path.
poedit-error

Now you can save the file as default.po in the languages folder of your plugin.

Click on Update at the top and it will search your php files finding words that will need to be translated

poedit-done

Click save to save it!
Then commit the default.po file and language directory using your SVN programme and let your user base now of the update, by announcing it readme.txt, your facebook plugin page, twitter account….

Hope that helps. A future post will be how to translate your favourite wordpress plugin!