本文整理匯總了PHP中Translations::translate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translations::translate方法的具體用法?PHP Translations::translate怎麽用?PHP Translations::translate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Translations
的用法示例。
在下文中一共展示了Translations::translate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
function test_digit_and_merge()
{
$entry_digit_1 = new Translation_Entry(array('singular' => 1, 'translations' => array('1')));
$entry_digit_2 = new Translation_Entry(array('singular' => 2, 'translations' => array('2')));
$domain = new Translations();
$domain->add_entry($entry_digit_1);
$domain->add_entry($entry_digit_2);
$dummy_translation = new Translations();
$this->assertEquals('1', $domain->translate('1'));
$domain->merge_with($dummy_translation);
$this->assertEquals('1', $domain->translate('1'));
}
示例2: array
function test_translate()
{
$entry1 = new Translation_Entry(array('singular' => 'baba', 'translations' => array('babax')));
$entry2 = new Translation_Entry(array('singular' => 'baba', 'translations' => array('babay'), 'context' => 'x'));
$domain = new Translations();
$domain->add_entry($entry1);
$domain->add_entry($entry2);
$this->assertEquals('babax', $domain->translate('baba'));
$this->assertEquals('babay', $domain->translate('baba', 'x'));
$this->assertEquals('baba', $domain->translate('baba', 'y'));
$this->assertEquals('babaz', $domain->translate('babaz'));
}
示例3: t
/**
* Alias for Translations::translate
*
* @param string $key
* @return string
*/
function t($key)
{
return Translations::translate($key);
}