\PhalApi_Translator

Translator Class

  • translate by language package
  • the priority of translation, project level is higher than system level


Usage:

     // initialization, set the langugae
     PhalApi_Translator::setLanguage('zh_cn');

     // translate
     $msg = T('hello {name}', array('name' => 'phper'));
     var_dump($msg);

Summary

Methods
Properties
Constants
get()
formatVar()
setLanguage()
addMessage()
getLanguage()
No public properties found
No constants found
getMessageFilePath()
$message
$language
N/A
No private methods found
No private properties found
N/A

Properties

$message

$message : array

Type

array — translation map

$language

$language : array

Type

array — language

Methods

get()

get(string  $key, array  $params = array()) : string

Translate

Parameters

string $key

content to be translated

array $params

dynamic params

Returns

string

formatVar()

formatVar(  $name) 

Parameters

$name

setLanguage()

setLanguage(string  $language) 

Set language

Parameters

string $language

language package folder name

addMessage()

addMessage(string  $path) : NULL

Add more translation for different language

  • provide more translation for libraries or other external lib

Parameters

string $path

new package folder name to added

Returns

NULL

getLanguage()

getLanguage() 

Get current language

getMessageFilePath()

getMessageFilePath(  $root,   $language) 

Parameters

$root
$language