Literal Handling

by John McGeechan

The literal handling script illustrates a simple way of providing multi lingual capabilities to a website. Instead of having hard coded string literals within scripts, a simple call can be made to the literals class which will look for a match for the requested literal and the particular language it was requested in. The base literals class is extensible so that each site script can abstract it's own literals away into a seperate literal handling class.

This abstraction away from hard coded literals allows for easy maintenace of string literals and facilitates multi-lingual functionality.

NB Of course this class could easily use sql tables to hold the literal values, they are stored in files for illustrative purposes only

baseLiterals.php

This is the base class for literal processing, it holds all common logic as well as the most common generic message literals for a site

 see source

 testbaseLiterals.php

 A set of re-runnable tests for the base literals class

 see source

run tests