本文整理匯總了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();
}