当前位置: 首页>>代码示例>>PHP>>正文


PHP i18n::get_translators方法代码示例

本文整理汇总了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));
         }
     }
 }
开发者ID:lekoala,项目名称:silverstripe-subsites-extras,代码行数:22,代码来源:SubsiteProfile.php

示例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]);
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:12,代码来源:i18nTest.php

示例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;
开发者ID:silvercart,项目名称:silvercart,代码行数:31,代码来源:SilvercartRequireDefaultCountries.php


注:本文中的i18n::get_translators方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。