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


PHP MO::import_from_file方法代码示例

本文整理汇总了PHP中MO::import_from_file方法的典型用法代码示例。如果您正苦于以下问题:PHP MO::import_from_file方法的具体用法?PHP MO::import_from_file怎么用?PHP MO::import_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MO的用法示例。


在下文中一共展示了MO::import_from_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filterOverrideLoadTextdomain

 public function filterOverrideLoadTextdomain($override, $domain, $mofile)
 {
     global $l10n;
     $key = md5($mofile);
     $data = $this->getCacheFileContent($key);
     $mo = new \MO();
     if (!$data) {
         if (is_file($mofile) && $mo->import_from_file($mofile)) {
             $data = ['entries' => $mo->entries, 'headers' => $mo->headers];
             $this->setCacheFileContent($key, $data);
         } else {
             return false;
         }
     } else {
         if (isset($data['entries'])) {
             $mo->entries = $data['entries'];
         }
         if (isset($data['headers'])) {
             $mo->headers = $data['headers'];
         }
     }
     if (isset($l10n[$domain])) {
         $mo->merge_with($l10n[$domain]);
     }
     $l10n[$domain] =& $mo;
     return true;
 }
开发者ID:kmvan,项目名称:poil10n,代码行数:27,代码来源:Api.php

示例2: getMo

 public function getMo($locale)
 {
     if (file_exists($file = $this->getMoFile($locale))) {
         $mo = new \MO();
         $mo->import_from_file($file);
         return $mo;
     }
     return false;
 }
开发者ID:wemakecustom,项目名称:wp-pot-generator,代码行数:9,代码来源:Translatable.php

示例3: MO

function &load_translations($mo_filename)
{
    if (is_readable($mo_filename)) {
        $translations = new MO();
        $translations->import_from_file($mo_filename);
    } else {
        $translations = new Translations();
    }
    return $translations;
}
开发者ID:akirk,项目名称:GlotPress,代码行数:10,代码来源:app.php

示例4: __i18n_load_db_mo

function __i18n_load_db_mo( $lang, $mofile )
{
    global $__i18n;
    if ( ! is_readable($mofile) ) return false;
    $mo = new MO();
    if ( ! $mo->import_from_file($mofile) ) return false;
    if ( isset($__i18n[$lang]) )
    {
        $mo->merge_with($__i18n[$lang]);
    }
    $__i18n[$lang] = &$mo;
    return true;
}
开发者ID:pf5512,项目名称:phpstudy,代码行数:13,代码来源:i18n.php

示例5: load_textdomain

function load_textdomain($domain, $mofile)
{
    global $l10n;
    if (!is_readable($mofile)) {
        return;
    }
    $mo = new MO();
    $mo->import_from_file($mofile);
    if (isset($l10n[$domain])) {
        $mo->merge_with($l10n[$domain]);
    }
    $l10n[$domain] =& $mo;
}
开发者ID:rmccue,项目名称:GlotPress,代码行数:13,代码来源:l10n.php

示例6: MO

 static function load_textdomain($domain, $mofile)
 {
     if (!is_readable($mofile)) {
         return false;
     }
     $mo = new MO();
     if (!$mo->import_from_file($mofile)) {
         return false;
     }
     if (isset(self::$l10n[$domain])) {
         $mo->merge_with(self::$l10n[$domain]);
     }
     self::$l10n[$domain] =& $mo;
     return true;
 }
开发者ID:MBerguer,项目名称:wp-demo,代码行数:15,代码来源:localization.php

示例7: load_textdomain

function load_textdomain($domain, $mofile)
{
    $l10n = get_i18n_cache();
    if (!is_readable($mofile)) {
        return false;
    }
    $mo = new MO();
    if (!$mo->import_from_file($mofile)) {
        return false;
    }
    if (isset($l10n[$domain])) {
        $mo->merge_with($l10n[$domain]);
    }
    $l10n[$domain] =& $mo;
    set_i18n_cache($l10n);
    return true;
}
开发者ID:ydhl,项目名称:yangzie,代码行数:17,代码来源:i18n.php

示例8: translate

/**
 * Load a .mo file into the text domain $domain.
 *
 * If the text domain already exists, the translations will be merged. If both
 * sets have the same string, the translation from the original value will be taken.
 *
 * On success, the .mo file will be placed in the $l10n global by $domain
 * and will be a MO object.
 *
 * @param    string     $domain Text domain. Unique identifier for retrieving translated strings.
 * @param    string     $mofile Path to the .mo file.
 *
 * @return   boolean    True on success, false on failure.
 *
 * Inspired from Luna <http://getluna.org>
 */
function translate($mofile, $domain = 'featherbb', $language = false)
{
    global $l10n;
    if (!$language) {
        $mofile = ForumEnv::get('FEATHER_ROOT') . 'featherbb/lang/' . User::get()->language . '/' . $mofile . '.mo';
    } else {
        $mofile = ForumEnv::get('FEATHER_ROOT') . 'featherbb/lang/' . $language . '/' . $mofile . '.mo';
    }
    if (!is_readable($mofile)) {
        return false;
    }
    $mo = new MO();
    if (!$mo->import_from_file($mofile)) {
        return false;
    }
    if (isset($l10n[$domain])) {
        $mo->merge_with($l10n[$domain]);
    }
    $l10n[$domain] =& $mo;
    return true;
}
开发者ID:featherbb,项目名称:featherbb,代码行数:37,代码来源:l10n.php

示例9: load_textdomain

function load_textdomain($domain, $mofile)
{
    global $l10n;
    $plugin_override = apply_filters('override_load_textdomain', false, $domain, $mofile);
    if (true == $plugin_override) {
        return true;
    }
    do_action('load_textdomain', $domain, $mofile);
    $mofile = apply_filters('load_textdomain_mofile', $mofile, $domain);
    if (!is_readable($mofile)) {
        return false;
    }
    $mo = new MO();
    if (!$mo->import_from_file($mofile)) {
        return false;
    }
    if (isset($l10n[$domain])) {
        $mo->merge_with($l10n[$domain]);
    }
    $l10n[$domain] =& $mo;
    return true;
}
开发者ID:AppItNetwork,项目名称:yii2-wordpress-themes,代码行数:22,代码来源:I10n.php

示例10: get_translations_for_domain

 private function get_translations_for_domain($domain = "default")
 {
     if ($this->entries != null) {
         return true;
     }
     $mo = new MO();
     $current_language = JFactory::getLanguage();
     $mo_file = JPATH_COMPONENT . DIRECTORY_SEPARATOR . "language" . DIRECTORY_SEPARATOR . $domain . "-" . $current_language->getTag() . ".mo";
     if (!file_exists($mo_file)) {
         $mo_file = JPATH_COMPONENT . DIRECTORY_SEPARATOR . "language" . DIRECTORY_SEPARATOR . $domain . "-" . str_replace("-", "_", $current_language->getTag()) . ".mo";
         if (!file_exists($mo_file)) {
             return false;
         }
     }
     if (!$mo->import_from_file($mo_file)) {
         return false;
     }
     if (!isset($lang[$domain])) {
         $lang[$domain] = $mo;
     }
     $this->merge_with($lang[$domain]);
 }
开发者ID:jhener79,项目名称:vlakc,代码行数:22,代码来源:translate.class.php

示例11: array

 function get_translation_from_woocommerce_mo_file($string, $language, $return_original = true)
 {
     global $sitepress;
     $original_string = $string;
     if (!isset($this->translations_from_mo_file[$original_string][$language])) {
         if (!isset($this->translations_from_mo_file[$original_string])) {
             $this->translations_from_mo_file[$original_string] = array();
         }
         if (!isset($this->mo_files[$language])) {
             $mo = new MO();
             $mo_file = WP_LANG_DIR . '/plugins/woocommerce-' . $sitepress->get_locale($language) . '.mo';
             if (!file_exists($mo_file)) {
                 return $return_original ? $string : null;
             }
             $mo->import_from_file($mo_file);
             $this->mo_files[$language] =& $mo->entries;
         }
         if (in_array($string, array('product', 'product-category', 'product-tag'))) {
             $string = 'slug' . chr(4) . $string;
         }
         if (isset($this->mo_files[$language][$string])) {
             $this->translations_from_mo_file[$original_string][$language] = $this->mo_files[$language][$string]->translations[0];
         } else {
             $this->translations_from_mo_file[$original_string][$language] = $return_original ? $original_string : null;
         }
     }
     return $this->translations_from_mo_file[$original_string][$language];
 }
开发者ID:Alexg10,项目名称:Egzobeatbox,代码行数:28,代码来源:wc-strings.class.php

示例12: MO

 /**
  * @param bool   $override Whether to override the .mo file loading. Default false.
  * @param string $domain   Text domain. Unique identifier for retrieving translated strings.
  * @param string $file     Path to the MO file.
  * @return bool
  */
 function _override_load_textdomain_filter($override, $domain, $file)
 {
     global $l10n;
     if (!is_readable($file)) {
         return false;
     }
     $mo = new MO();
     if (!$mo->import_from_file($file)) {
         return false;
     }
     if (isset($l10n[$domain])) {
         $mo->merge_with($l10n[$domain]);
     }
     $l10n[$domain] =& $mo;
     return true;
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:22,代码来源:loadTextdomain.php

示例13: MO

 function test_load_pot_file()
 {
     $mo = new MO();
     $this->assertEquals(false, $mo->import_from_file(DIR_TESTDATA . '/pomo/mo.pot'));
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:5,代码来源:mo.php

示例14: MO

 function get_translation_from_woocommerce_mo_file($string, $language)
 {
     global $sitepress;
     $mo = new MO();
     $mo_file = WP_LANG_DIR . '/plugins/woocommerce-' . $sitepress->get_locale($language) . '.mo';
     if (!file_exists($mo_file)) {
         return $string;
     }
     $mo->import_from_file($mo_file);
     $translations = $mo->entries;
     if (in_array($string, array('product', 'product-category', 'product-tag'))) {
         $string = 'slug' . chr(4) . $string;
     }
     if (isset($translations[$string])) {
         return $translations[$string]->translations[0];
     }
     return $string;
 }
开发者ID:mahirziyaokan,项目名称:woocommerce-multilingual,代码行数:18,代码来源:terms.class.php

示例15: justInTimeLocalisation

 /**
  * load any enqueued locales as localisations on the main script
  */
 public function justInTimeLocalisation()
 {
     if (!empty($this->locales)) {
         $domain = 'flexible-map';
         $i18n = array();
         // map old two-character language-only locales that now need to target language_country translations
         $upgradeMap = array('bg' => 'bg_BG', 'cs' => 'cs_CZ', 'da' => 'da_DK', 'de' => 'de_DE', 'es' => 'es_ES', 'fa' => 'fa_IR', 'fr' => 'fr_FR', 'gl' => 'gl_ES', 'he' => 'he_IL', 'hi' => 'hi_IN', 'hu' => 'hu_HU', 'id' => 'id_ID', 'is' => 'is_IS', 'it' => 'it_IT', 'ko' => 'ko_KR', 'lt' => 'lt_LT', 'mk' => 'mk_MK', 'ms' => 'ms_MY', 'mt' => 'mt_MT', 'nb' => 'nb_NO', 'nl' => 'nl_NL', 'pl' => 'pl_PL', 'pt' => 'pt_PT', 'ro' => 'ro_RO', 'ru' => 'ru_RU', 'sk' => 'sk_SK', 'sl' => 'sl_SL', 'sr' => 'sr_RS', 'sv' => 'sv_SE', 'ta' => 'ta_IN', 'tr' => 'tr_TR', 'zh' => 'zh_CN');
         foreach (array_keys($this->locales) as $locale) {
             // check for specific locale first, e.g. 'zh-CN', then for generic locale, e.g. 'zh'
             foreach (array($locale, substr($locale, 0, 2)) as $locale) {
                 if (isset($upgradeMap[$locale])) {
                     // upgrade old two-character language-only locales
                     $moLocale = $upgradeMap[$locale];
                 } else {
                     // revert locale name to WordPress locale name as used in .mo files
                     $moLocale = strtr($locale, '-', '_');
                 }
                 // compose full path to .mo file
                 $mofile = sprintf('%slanguages/%s-%s.mo', FLXMAP_PLUGIN_ROOT, $domain, $moLocale);
                 if (is_readable($mofile)) {
                     $mo = new MO();
                     if ($mo->import_from_file($mofile)) {
                         // pull all translation strings into a simplified format for our script
                         // TODO: handle plurals (not yet needed, don't have any)
                         $strings = array();
                         foreach ($mo->entries as $original => $translation) {
                             $strings[$original] = $translation->translations[0];
                         }
                         $i18n[$locale] = $strings;
                         break;
                     }
                 }
             }
         }
         if (!empty($i18n)) {
             wp_localize_script('flxmap', 'flxmap', array('i18n' => $i18n));
         }
     }
 }
开发者ID:evinw,项目名称:project_gg_studios,代码行数:42,代码来源:class.FlxMapPlugin.php


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