addTranslation() 공개 메소드

Translations are arrays in the Zend Translation array format, eg: $english = array('message1' => 'message1', 'message2' => 'message2'); $german = array('message1' => 'Nachricht1','message2' => 'Nachricht2');
public addTranslation ( string $country_code, array $language_array ) : boolean
$country_code string Standard country code (eg 'en', 'nl', 'es')
$language_array array Formatted array of strings
리턴 boolean Depending on success
예제 #1
0
 public function testIssuesNoticeOnMissingKey()
 {
     // key is missing from all checked translations
     _elgg_services()->logger->disable();
     $this->assertEquals("{$this->key}b", $this->translator->translate("{$this->key}b"));
     $logged = _elgg_services()->logger->enable();
     $this->assertEquals([['message' => "Missing English translation for \"{$this->key}b\" language key", 'level' => Logger::NOTICE]], $logged);
     // has fallback key
     $this->translator->addTranslation('en', ["{$this->key}b" => 'Dummy']);
     _elgg_services()->logger->disable();
     $this->assertEquals('Dummy', $this->translator->translate("{$this->key}b", [], 'es'));
     $logged = _elgg_services()->logger->enable();
     $this->assertEquals([['message' => "Missing es translation for \"{$this->key}b\" language key", 'level' => Logger::NOTICE]], $logged);
 }
예제 #2
0
 public function testCheckLanguageKeyExists()
 {
     $translator = new Translator();
     $translator->addTranslation('en', array('__elgg_php_unit:test_key' => 'Dummy'));
     $this->assertTrue($translator->languageKeyExists('__elgg_php_unit:test_key'));
     $this->assertFalse($translator->languageKeyExists('__elgg_php_unit:test_key:missing'));
 }
예제 #3
0
 public function setUp()
 {
     $this->actionsDir = dirname(dirname(__FILE__)) . "/test_files/actions";
     $session = ElggSession::getMock();
     _elgg_services()->setValue('session', $session);
     _elgg_services()->session->start();
     $config = $this->config();
     _elgg_services()->setValue('config', $config);
     $this->input = new Input();
     _elgg_services()->setValue('input', $this->input);
     $this->actions = new ActionsService($config, $session, _elgg_services()->crypto);
     _elgg_services()->setValue('actions', $this->actions);
     $this->request = $this->prepareHttpRequest();
     _elgg_services()->setValue('request', $this->request);
     $this->translator = new Translator();
     $this->translator->addTranslation('en', ['__test__' => 'Test']);
     $this->hooks = new PluginHooksService();
     $this->system_messages = new SystemMessagesService(elgg_get_session());
     _elgg_services()->logger->disable();
 }
예제 #4
0
파일: RouterTest.php 프로젝트: elgg/elgg
 function setUp()
 {
     $this->pages = dirname(dirname(__FILE__)) . '/test_files/pages';
     $this->fooHandlerCalls = 0;
     $session = ElggSession::getMock();
     _elgg_services()->setValue('session', $session);
     _elgg_services()->session->start();
     $config = $this->config();
     _elgg_services()->setValue('config', $config);
     $this->input = new Input();
     _elgg_services()->setValue('input', $this->input);
     $this->request = $this->prepareHttpRequest('', 'GET');
     _elgg_services()->setValue('request', $this->request);
     $this->translator = new Translator();
     $this->translator->addTranslation('en', ['__test__' => 'Test']);
     $this->hooks = new PluginHooksService();
     $this->router = new Router($this->hooks);
     $this->system_messages = new SystemMessagesService(elgg_get_session());
     $this->viewsDir = dirname(dirname(__FILE__)) . "/test_files/views";
     $this->createService();
     _elgg_services()->logger->disable();
 }