I’ve done a translation of the Sandbox theme for my swedish section of the site using the GNU gettext tools. It’s pretty simple.
The following command line examples assume you already are in the sandbox theme directory.
Generate a PO Template
First we have to create a PO Template.
$> xgettext --foreign-user -k__ -k_e -d sandbox -n *.php$> mv sandbox.po sandbox.pot- Edit the charset to read
UTF-8.
Creating a PO File
Start by creating a PO File from the PO Template, in this case using the locale sv_SE (swedish as language, Sweden as country) and output a file using the locale as name.
Now time has come to translating the theme. You can either use a simple text editor or something more fancy like KDE’s KBabel. Anyhow, the editor (in this example) need to spit out UTF-8 encoded output.
$> msginit -l sv_SE -i sandbox.pot -o sv_SE.po- Translate the messages in the
sv_SE.pofile.
Updating a PO File
When code may have changed (for example a new version being released) we need to update the translation project.
Begin with regenerating the sandbox.pot PO Template as described above. Continue by updating the translated PO File using the new template and edit the updated file for new or missing translations.
$> msgmerge -U sv_SE.po sandbox.pot- Translate any new messages in the
sv_SE.pofile.
Generate a MO File
Unfortunately the plain text PO file isn’t very efficient to use by the gettext library. Instead we have to generate a binary MO file from it that can be read by the gettext library efficiently.
$> msgfmt -o sv_SE.mo sv_SE.po- That’s it, really!
Install your translation
Just drop the MO file into the theme directory and don’t forget to set the locale in wp-config.php, and your site will be both localized and internationalized!
5 comments
Great with the translation, Anders. Please be aware, though, that the Sandbox is still a less-than-1 release (0.6.1 is current), so I imagine some of these translates will change.
But the more translates, the better! Thanks for getting on the Sandbox wagon. We’ve made the Sandbox SVN public (for viewing), so check my site for that.
Good job! :-D
Thank you Scott!
I haven’t upgraded to the latest version yet. But I will start track the SVN version, it’s actually easier to track any changes and manage my private patches/modifications to the theme that way.
BTW, I’m thinking about creating a en_US translation so the wording and style on this blog match up against the swedish one. ;-)
Hey Anders, I believe someone is working on another this for the Sandbox, though it seems the link is magically disappeared. Have a look at Zeo’s site, because I know I remember seeing a post of it there. :-O
Hi all,
Yeah sorry for the missing link. I was moving the folders. Here’s the untranslated POT http://sandboxk2.googlecode.com/svn/sandbox-i18n/
Check out
http://www.plaintxt.org/2008/01/27/help-translate-the-sandbox/
Pulls much on the Danish page which used you as a reference.
If you have or can make Swedish or any other languages for 1.3 the Sandbox author will be very happy.
Kjell Knudsen
4 Trackbacks/Pingbacks
[...] til Anders Dahnielson, som med sit eget indlæg om oversættelse af Sandbox til svensk illustrerede processen på fornemste [...]
[...] Un compañero de trabajo y yo hemos traducido el tema Sandbox de WordPress al español, siguiendo éstas instrucciones: Playing with Gettext in the Sandbox. [...]
[...] translated the Wordpress Sandbox theme into Spanish following the tutorial Playing With Gettext in the Sandbox by Dahnielson. I didn’t expect it was so [...]
[...] translated the Wordpress Sandbox theme into Spanish following the tutorial Playing With Gettext in the Sandbox by Dahnielson. I didn’t expect it was so [...]
Post a comment