MVCLight includes a localization library based on gettext principles. Both gettext and a custom translations file system are available, and they allow support for plural forms.To use it, include this line on your controller, as it is done in appController in this demo.$this->language->initGetText('en_GB');
Then, if gettext is available you can use your own MO files. Otherwise, you can take the file application/lang/es_ES as an example of use.
The function __() is defined to overload the gettext function _() and it is used like this:
__('there are %s apples', array( 'count' => 9, 'caps' => ('first'|'words'|'upper'|'none'), 'vars' => array('kitchen','window',...) ) );
Examples:
Code | __('there are %1$s apples in %2$s',array('count'=>0,'vars'=>__('the kitchen'))) |
---|---|
Produces | there are 0 apples in the kitchen |
Code | __('there are %1$s apples in %2$s',array('count'=>1,'vars'=>__('the window'))) |
Produces | there are 1 apples in the window |
Code | __('there are %1$s apples in %2$s',array('count'=>5,'vars'=>__('the living room'))) |
Produces | there are 5 apples in the living room |
Code | __('there are %1$s apples in %2$s',array('count'=>12,'vars'=>__('the corridor'))) |
Produces | there are 12 apples in the corridor |