當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。