Пример #1
0
 public function testGetLanguageInstance()
 {
     $Language1 = PMCLibrary::getLanguageInstance();
     $this->assertNotNull($Language1);
     $Language2 = PMCLibrary::getLanguageInstance();
     $this->assertSame($Language1, $Language2);
 }
Пример #2
0
 public function testAttachLanguageNewway()
 {
     $langArray = array();
     $langArray['testIndex2'] = 'testValue2';
     PMCLibrary::getLanguageInstance()->attachLanguage($langArray);
     $expect = 'testValue2';
     $result = _T('testIndex2');
     $this->assertEquals($expect, $result);
 }
Пример #3
0
 /**
  * 取出翻譯資源檔對應字串。
  *
  * @param args 翻譯資源檔索引、其餘變數
  * @see LanguageLoader->getTranslation
  */
 protected function _T()
 {
     $args = func_get_args();
     // 為字串資源鍵值加上模組名前綴
     if (isset($args[0]) && !empty($args[0])) {
         $args[0] = $this->clazz . '_' . $args[0];
     }
     return call_user_func_array(array(PMCLibrary::getLanguageInstance(), 'getTranslation'), $args);
 }
Пример #4
0
 public function testAttachLanguage()
 {
     $beforeCount = count(PMCLibrary::getLanguageInstance()->getLanguage());
     $this->mod->testAttachLanguage();
     $afterCount = count(PMCLibrary::getLanguageInstance()->getLanguage());
     $this->assertEquals($beforeCount + 2, $afterCount);
 }
Пример #5
0
/**
 * 動態附加翻譯資源。此函式已經由 {@link #LanguageLoader->attachLanguage} 取代。
 *
 * @deprecated 7th.Release. Use LanguageLoader->attachLanguage instead.
 * @param callable $fcall 附加翻譯資源字串的函式
 */
function AttachLanguage($fcall)
{
    $GLOBALS['language'] = array();
    call_user_func($fcall);
    PMCLibrary::getLanguageInstance()->attachLanguage($GLOBALS['language']);
}