/**
  * test french translations singular
  * 
  * @see 0007014: Dates not formatted
  */
 public function testFrench()
 {
     Tinebase_Core::getCache()->clean();
     $jsTranslations = Tinebase_Translation::getJsTranslations('fr', 'Tinebase');
     $this->assertTrue(preg_match("/: \"liste \\\\\"\n/", $jsTranslations, $matches) === 0, 'Translation string missing / preg_match fail: ' . print_r($matches, TRUE));
     $this->assertContains(': "liste \\"à faire\\""', $jsTranslations, 'Could not find french singular of "todo lists"');
 }
コード例 #2
0
 /**
  * returns javascript of translations for the currently configured locale
  * 
  * Note: This function is only used in development mode. In debug/release mode
  * we can include the static build files in the view. With this we avoid the 
  * need to start a php process and stream static js files through it.
  * 
  * @return javascript
  *
  */
 public function getJsTranslations()
 {
     if (!in_array(TINE20_BUILDTYPE, array('DEBUG', 'RELEASE'))) {
         $locale = Tinebase_Core::get('locale');
         $translations = Tinebase_Translation::getJsTranslations($locale);
         header('Content-Type: application/javascript');
         die($translations);
     }
     $this->_deliverChangedFiles('lang');
     die;
 }
コード例 #3
0
    public function testCustomTranslations()
    {
        $lang = 'en_GB';
        $translationPath = Tinebase_Core::getTempDir() . "/tine20/translations";
        Tinebase_Config::getInstance()->translations = $translationPath;
        $translationDir = "{$translationPath}/{$lang}/Tinebase/translations";
        @mkdir($translationDir, 0777, TRUE);
        $poFile = "{$translationDir}/{$lang}.po";
        $poData = 'msgid ""
msgstr ""
"Project-Id-Version: Tine 2.0 - Tinebase\\n"
"POT-Creation-Date: 2008-05-17 22:12+0100\\n"
"PO-Revision-Date: 2008-07-29 21:14+0100\\n"
"Last-Translator: Cornelius Weiss <*****@*****.**>\\n"
"Language-Team: Tine 2.0 Translators\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=UTF-8\\n"
"Content-Transfer-Encoding: 8bit\\n"
"X-Poedit-Language: en\\n"
"X-Poedit-Country: US\\n"
"X-Poedit-SourceCharset: utf-8\\n"
"Plural-Forms: nplurals=2; plural=n != 1;\\n"
"X-Tine20-Language: My Language\\n"
"X-Tine20-Country: MY REGION\\n"

#: Acl/Rights/Abstract.php:75
msgid "run"
msgstr "изпълни"
';
        file_put_contents($poFile, $poData);
        $availableTranslations = Tinebase_Translation::getAvailableTranslations();
        foreach ($availableTranslations as $langInfo) {
            if ($langInfo['locale'] == $lang) {
                $customInfo = $langInfo;
            }
        }
        // assert cutom lang is available
        $this->assertTrue(isset($customInfo), 'custom translation not in list of available translations');
        $this->assertEquals('My Language', $customInfo['language'], 'custom language param missing');
        $this->assertEquals('MY REGION', $customInfo['region'], 'custom region param missing');
        // test the translation
        $translation = Tinebase_Translation::getTranslation('Tinebase', new Zend_Locale($lang));
        // NOTE: Zent_Translate does not work with .po files
        //$this->assertEquals("изпълни", $translation->_('run'));
        $jsTranslations = Tinebase_Translation::getJsTranslations($lang, 'Tinebase');
        $this->assertEquals(1, preg_match('/изпълни/', $jsTranslations));
        Tinebase_Core::setupUserLocale();
    }