Permalink

Although time has been short recently, I have started making some changes to my Dojo listing code, which I wanted to add to the blog.

Firstly, I have added some simple internationalisation support.
As of version 0.3.0 simple Internationalisation using Gettext is added. The language support is in the /locale/xx/LC_MESSAGES/ directories, using the standard two letter abbreviations for languages, i.e. en for English, es for Spanish etc. Native speakers can assist the project by editing the messages.po file in the directory. The .po file is then used to create the .mo file.

Basically, I have since gone through most of my views and replaced echo statements with the gettext abbreviation _('........'); statement as below.

<?php echo _(“Home”); ?>

The next step was/is to create tranlation files using:

xgettext ../../../views/*.php

Then run :

msgfmt messages.po -o messages.mo

I then needed to add some simple code to the app to manage which language is displayed. Including the translation is a case of including


// Specify location of translation tables
bindtextdomain (“messages”, “./locale”);

// Choose domain
textdomain (“messages”);


in the main index.php file and also selecting the language using:

<?php
// Set language to Spanish
putenv (“LC_ALL=es”);
?>


This all works pretty smoothly, if the .po file is blanked, then it defaults to the original. So for English, I have not had to add anything. So all I need now is people to translate the text. :-)

Automated testing.
I have added a /tests/ folder to the project and included the simpletest framework to make testing my code simple and easy. So far I have done very little except get it in place and working.

I have started by adding some basic tests to the Dojo model.

My intention is as I progress to write my tests first and then write the code to implement the features I want. It's good practice, but I am lazy and have nt been doing it.

I've just this evening merged the branch I was using to develop the localisation into the master branch on http://github.com/lancew/DojoList

Go take a look at the code there, or see it in action at http://dojolist.org

Lance.
:-)
im9aVVlpkCw

External permalink