Translation: ezcTranslation
[ ]
[ Linguist format ]
[ ]
[ ]
[ ]
[ ]
Class: ezcTranslation
|
ezcTranslation is a container that holds the translated strings for a specific context. [
source]
ezcTranslation objects are returned by the ezcTranslationManager for every requested context.
Method Summary
|
public ezcTranslation |
__construct(
$data )
Constructs the ezcTranslation object. |
|
public string |
compileTranslation(
$key, [$params = array()] )
Returns the translated version of the original string $key. |
|
public string |
getTranslation(
$key, [$params = array()] )
Returns the translated version of the original string $key. |
Methods
__construct
ezcTranslation __construct(
$data )
Constructs the ezcTranslation object.
The constructor receives an array containing the translation elements, and builds up an internal map between the original string and the accompanying translation data.
Parameters
| Name |
Type |
Description |
$data |
array(ezcTranslationData) |
|
compileTranslation
string compileTranslation(
string
$key, [
$params = array()] )
Returns the translated version of the original string $key.
This method returns a translated string and substitutes the parameters $param in the localized string with PHP code to place the variable data into the string at a later moment. Instead of the values for each of the parameters, an expression to get to the data should be sumbitted into the $params array.
1. echo $translation->compileTranslation( "Hello #%nr", array( "nr" => '$this->send->nr' ) );
Will return something like:
1. 'Hallo #' . $this->send->nr . ''
Parameters
| Name |
Type |
Description |
$key |
string |
|
$params |
array(string=>string) |
|
getTranslation
string getTranslation(
string
$key, [
$params = array()] )
Returns the translated version of the original string $key.
This method returns a translated string and substitutes the parameters $param in the localized string.
Parameters
| Name |
Type |
Description |
$key |
string |
|
$params |
array(string=>string) |
|
Throws
| Class | Description |
ezcTranslationKeyNotAvailableException |
when the key is not available |
ezcTranslationParameterMissingException |
when not enough parameters are passed for a parameterized string |
Last updated: Fri, 03 Oct 2008