Language API 規格
Table of Contents
|
規格版本
- LanguageLoader : 2012/12/13 by scribe
- Version 0.2 (r527) : 2007/09/15 by RT
- Version 0.1 (r344) : 2007/03/01 by RT
LanguageLoader 物件
getLocale
public string getLocale()
取得語系設定。
回傳值:
語系代表字串 (如: zh_TW, en_US)
getLanguage
public array getLanguage()
取得翻譯資源字串陣列。
回傳值:
翻譯字串陣列
getTranslation
public function getTranslation(string $langstrid [, object.. $args])
取得指定項目之翻譯,並進行變數字串的替代。
參數:
$langstrid - 翻譯資源索引字
$args - 變數
回傳值:
翻譯後之字串
attachLanguage
public void attachLanguage(array $language)
附加翻譯資源字串。
參數:
$language - 翻譯資源字串陣列
PMCLibrary::getLanguageInstance()->attachLanguage( array( 'test' => '這是測試', 'no_time' => '%1$s,快沒有時間了!' ) );
相容方法一覽
7th.Release 以後推薦使用物件存取來達成,但仍提供舊有的便利方法供呼叫。
_T
string function _T(string $langstrid, [mixed …])
以指定語言字串範本為基礎輸出符合語系的字串。
輸入:
$langstrid - 欲使用的語言字串範本的代號。如代號不存在會直接輸出代號。
其後的變數 - 用作套用至語言字串範本中作替代之用。回傳值:
替代好的語言字串。
AttachLanguage
void function AttachLanguage(callback $fcall)
在載入語言檔時附加額外的語言字串。
輸入:
$fcall - 欲附加額外的語言字串的回調函式。