本文整理汇总了PHP中i18n::get_translators方法的典型用法代码示例。如果您正苦于以下问题:PHP i18n::get_translators方法的具体用法?PHP i18n::get_translators怎么用?PHP i18n::get_translators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类i18n
的用法示例。
在下文中一共展示了i18n::get_translators方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enable_custom_translations
protected static function enable_custom_translations()
{
$locale = i18n::get_locale();
$lang = i18n::get_lang_from_locale($locale);
$profileDir = self::getProfileDir();
$translators = array_reverse(i18n::get_translators(), true);
// Make sure to include base translations
i18n::include_by_locale($lang);
foreach ($translators as $priority => $translators) {
foreach ($translators as $name => $translator) {
/* @var $adapter Zend_Translate_Adapter */
$adapter = $translator->getAdapter();
// Load translations from profile
$filename = $adapter->getFilenameForLocale($lang);
$filepath = Director::baseFolder() . "/mysite/lang/" . $profileDir . '/' . $filename;
if ($filename && !file_exists($filepath)) {
continue;
}
$adapter->addTranslation(array('content' => $filepath, 'locale' => $lang));
}
}
}
示例2: testRegisterTranslator
public function testRegisterTranslator()
{
$translator = new Zend_Translate(array('adapter' => 'i18nTest_CustomTranslatorAdapter', 'disableNotices' => true));
i18n::register_translator($translator, 'custom', 10);
$translators = i18n::get_translators();
$this->assertArrayHasKey('custom', $translators[10]);
$this->assertInstanceOf('Zend_Translate', $translators[10]['custom']);
$this->assertInstanceOf('i18nTest_CustomTranslatorAdapter', $translators[10]['custom']->getAdapter());
i18n::unregister_translator('custom');
$translators = i18n::get_translators();
$this->assertArrayNotHasKey('custom', $translators[10]);
}
示例3: SilvercartCountry
$country->write();
}
// write country ZW
if (!SilvercartCountry::get()->filter("ISO2", "ZW")->exists()) {
$country = new SilvercartCountry();
$country->ISO2 = "ZW";
$country->ISO3 = "ZWE";
$country->FIPS = "ZI";
$country->ISON = "716";
$country->Title = _t("SilvercartCountry.TITLE_ZW");
$country->Continent = "AF";
$country->Currency = "ZWL";
$country->Locale = Translatable::get_current_locale();
$country->write();
}
$translatorsByPrio = i18n::get_translators();
foreach ($translatorsByPrio as $priority => $translators) {
foreach ($translators as $name => $translator) {
$adapter = $translator->getAdapter();
$languages = $adapter->getList();
foreach ($languages as $language) {
$locale = i18n::get_locale_from_lang($language);
if ($country->hasLanguage($locale)) {
continue;
}
$data = $adapter->getMessages($language);
foreach (SilvercartCountry::get() as $country) {
$key = 'TITLE_' . strtoupper($country->ISO2);
if (array_key_exists('SilvercartCountry.' . $key, $data)) {
$translation = new SilvercartCountryLanguage();
$translation->Locale = $locale;