Exemplo n.º 1
0
 public function testNewElement()
 {
     copy('TemplateTranslationTiein/tests/test_files/extractor/test-new-elements/original.xml', "{$this->tmpDirTranslationFiles}/en.xml");
     $backend = new ezcTranslationTsBackend($this->tmpDirTranslationFiles, array('keepObsolete' => true));
     $manager = new ezcTranslationManager($backend);
     $context = $manager->getContext('en', 'test');
     try {
         $tr = $context->getTranslation('vier');
         self::fail('Expected exception not thrown.');
     } catch (ezcTranslationKeyNotAvailableException $e) {
         self::assertEquals("The key 'vier' does not exist in the translation map.", $e->getMessage());
     }
     $context = $backend->getContext('en', 'test');
     self::assertEquals('een', $context[0]->original);
     self::assertEquals(ezcTranslationData::TRANSLATED, $context[0]->status);
     $res = `php TemplateTranslationTiein/src/runextractor.php -t TemplateTranslationTiein/tests/test_files/extractor/templates {$this->tmpDirTranslationFiles}`;
     $context = $backend->getContext('en', 'test');
     self::assertEquals('vier', $context[1]->original);
     self::assertEquals(ezcTranslationData::UNFINISHED, $context[1]->status);
     self::assertEquals(ezcTranslationData::TRANSLATED, $context[3]->status);
 }
Exemplo n.º 2
0
 private function translateFromXML($context, $string, $params = array())
 {
     $sys = erLhcoreClassSystem::instance()->SiteDir;
     $reader = new ezcTranslationTsBackend($sys . '/translations/' . $this->languageCode);
     $reader->setOptions(array('format' => 'translation.ts'));
     $manager = new ezcTranslationManager($reader);
     $ContextTranslation = $manager->getContext($this->languageCode, $context);
     return $ContextTranslation->getTranslation($string, $params);
 }
    }
    $Matches = array();
    preg_match_all('/erTranslationClassLhTranslation::getInstance\\(\\)->getTranslation\\(\'(.*?)\',\'(.*?)\'\\)/i', $contentFile, $Matches);
    foreach ($Matches[1] as $key => $section) {
        if (!isset($arrayTranslationsProcess[$section])) {
            $arrayTranslationsProcess[$section] = array();
        }
        if (!in_array($Matches[2][$key], $arrayTranslationsProcess[$section])) {
            $arrayTranslationsProcess[$section][] = $Matches[2][$key];
        }
    }
}
$reader = new ezcTranslationTsBackend($cronjobPathOption->value . '/doc');
$reader->setOptions(array('format' => 'default.ts'));
$reader->initReader($locale);
$manager = new ezcTranslationManager($reader);
function translateToLanguage($apiKey, $toLanguage, $string)
{
    return '';
}
foreach ($arrayTranslationsProcess as $context => $itemsToTranslate) {
    $contextItems = array();
    try {
        $contextItem = $manager->getContext($locale, $context);
    } catch (Exception $e) {
        // Context does not exists
        $reader->initWriter($locale);
        $reader->storeContext($context, $contextItems);
        $reader->deinitWriter();
        $contextItem = $manager->getContext($locale, $context);
    }
Exemplo n.º 4
0
<?php

require_once 'tutorial_example_03.php';
$manager = new ezcTranslationManager($backend);
$manager->addFilter(ezcTranslationBorkFilter::getInstance());
$search = $manager->getContext('nl_NL', 'search');
$params = array('search_string' => 'appelmoes', 'matches' => 4);
echo $search->getTranslation("Search for '%search_string' returned %matches matches.", $params), "\n";
$manager = new ezcTranslationManager($backend);
$manager->addFilter(ezcTranslationLeetFilter::getInstance());
$search = $manager->getContext('nl_NL', 'search');
$params = array('search_string' => 'appelmoes', 'matches' => 4);
echo $search->getTranslation("Search for '%search_string' returned %matches matches.", $params), "\n";
 public function testGetContextMissing()
 {
     $currentDir = dirname(__FILE__);
     $backend = new ezcTranslationTsBackend("{$currentDir}/files/translations");
     $backend->setOptions(array('format' => '[LOCALE].xml'));
     $fillin = ezcTranslationComplementEmptyFilter::getInstance();
     $trm = new ezcTranslationManager($backend);
     $trm->addFilter($fillin);
     try {
         $context = $trm->getContext('nl-nl', 'design/admin/collaboration/admin/view/summary');
         self::fail('Expected Exception was not thrown');
     } catch (ezcTranslationContextNotAvailableException $e) {
         self::assertEquals("The context 'design/admin/collaboration/admin/view/summary' does not exist.", $e->getMessage());
     }
 }
Exemplo n.º 6
0
<?php

require_once 'tutorial_autoload.php';
$backend = new ezcTranslationTsBackend(dirname(__FILE__) . '/translations');
$backend->setOptions(array('format' => 'translation-[LOCALE].xml'));
$manager = new ezcTranslationManager($backend);
$manager->addFilter(ezcTranslationComplementEmptyFilter::getInstance());
$headersContext = $manager->getContext('nl_NL', 'tutorial/headers');
echo $headersContext->getTranslation('header1'), "\n";
Exemplo n.º 7
0
<?php

require_once 'tutorial_autoload.php';
$backend = new ezcTranslationTsBackend(dirname(__FILE__) . '/translations');
$backend->setOptions(array('format' => 'translation-[LOCALE].xml'));
$manager = new ezcTranslationManager($backend);
$headersContext = $manager->getContext('nb_NO', 'tutorial/headers');
$descriptionContext = $manager->getContext('nb_NO', 'tutorial/descriptions');
echo $headersContext->getTranslation('header1'), "\n";
echo $descriptionContext->getTranslation('desc1'), "\n";
echo $descriptionContext->getTranslation('desc2'), "\n";
Exemplo n.º 8
0
<?php

require_once 'tutorial_autoload.php';
$backend = new ezcTranslationTsBackend(dirname(__FILE__) . '/translations');
$backend->setOptions(array('format' => 'translation-[LOCALE].xml'));
$manager = new ezcTranslationManager($backend);
$dutch = $manager->getContext('nl_NL', 'search');
$norsk = $manager->getContext('nb_NO', 'search');
$params = array('search_string' => 'appelmoes', 'matches' => 4);
echo $dutch->getTranslation("Search for '%search_string' returned %matches matches.", $params), "\n";
$params = array('fruit' => 'epplet');
echo $norsk->getTranslation("The %fruit is round.", $params), "\n";