translation Class Reference

handles i18n : UI strings translation More...

Inheritance diagram for translation:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 translation ($path, $user_lang, $default_lang, $ext)
 creates a new translation object
 completeFrom ($path, $user_lang, $default_lang, $ext)
 complete current object with i18n strings read from files
 get ($key)
 return translation for a key
 readFile ($file)
 reads a translation file
 dumpContent ()
 dump content of translation file for debugging purpose

Public Attributes

 $lang

Detailed Description

handles i18n : UI strings translation

in our world, there is a global translation object that is used by global function tr()


Member Function Documentation

translation::completeFrom ( path,
user_lang,
default_lang,
ext 
)

complete current object with i18n strings read from files

tries to load a translation file from parameter, if no files could be loaded, each string will remain untranslated

Parameters:
path path to i18n files
user_lang translation code we want to have (fr, en, es ...)
default_lang lang to default to if user_lang is not found (fr, en, es ...)
ext extension of files (.lang)

translation::dumpContent (  ) 

dump content of translation file for debugging purpose

The content is dumped direclty on STDOUT with pre tags

translation::get ( key  ) 

return translation for a key

if no translation exist, then return key

Parameters:
key the string to translate
Returns:
translated string

translation::readFile ( file  ) 

reads a translation file

translation files have a very simple BNF. Lines starting with '#' are comments Lines starting with '[' and ending with ']' define a key Lines following a key line are considered translation (thus translation can be multi lines) A translation must be followed by an empty line

Parameters:
file file to read

translation::translation ( path,
user_lang,
default_lang,
ext 
)

creates a new translation object

tries to load a translation file from parameter, if no files could be loaded, each string will remain untranslated

Parameters:
path path to i18n files
user_lang translation code we want to have (fr, en, es ...)
default_lang lang to default to if user_lang is not found (fr, en, es ...)
ext extension of files (.lang)


The documentation for this class was generated from the following file:
Generated on Mon Feb 19 19:11:58 2007 for Wiclear by  doxygen 1.4.7