本文整理汇总了PHP中Tinebase_Translation::getJsTranslations方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Translation::getJsTranslations方法的具体用法?PHP Tinebase_Translation::getJsTranslations怎么用?PHP Tinebase_Translation::getJsTranslations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Translation
的用法示例。
在下文中一共展示了Tinebase_Translation::getJsTranslations方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFrench
/**
* 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: getJsTranslations
/**
* 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: testCustomTranslations
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 <c.weiss@metaways.de>\\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();
}