Inheritance diagram for translation:

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 | |
in our world, there is a global translation object that is used by global function tr()
| 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
| 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
| key | the string to translate |
| 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
| 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
| 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) |
1.4.7