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


PHP MO::merge_with方法代码示例

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


在下文中一共展示了MO::merge_with方法的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: __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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: load

 /**
  * Loads MO file into the list of domains
  *
  * If the domain already exists, the inclusion will fail. If the
  * MO file is not readable, the inclusion will fail.
  *
  * @since 1.0
  * @uses CacheFileReader Reads the MO file
  * @uses gettext_reader Allows for retrieving translated strings
  *
  * @param string $domain Unique identifier for retrieving translated strings
  * @param string $mofile Path to the .mo file
  * @return bool Successfulness of loading textdomain
  */
 public static function load($domain, $mofile)
 {
     if (!is_readable($mofile)) {
         return;
     }
     $mo = new MO();
     $mo->import_from_file($mofile);
     if (isset(self::$translations[$domain])) {
         $mo->merge_with(self::$translations[$domain]);
     }
     self::$translations[$domain] =& $mo;
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:26,代码来源:class-locale.php

示例9: load_textdomain

/**
 * 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.
 *
 * @since 1.5.0
 *
 * @global array $l10n
 *
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
 * @param string $mofile Path to the .mo file.
 * @return bool True on success, false on failure.
 */
function load_textdomain($domain, $mofile)
{
    global $l10n;
    /**
     * Filter text domain and/or MO file path for loading translations.
     *
     * @since 2.9.0
     *
     * @param bool   $override Whether to override the text domain. Default false.
     * @param string $domain   Text domain. Unique identifier for retrieving translated strings.
     * @param string $mofile   Path to the MO file.
     */
    $plugin_override = apply_filters('override_load_textdomain', false, $domain, $mofile);
    if (true == $plugin_override) {
        return true;
    }
    /**
     * Fires before the MO translation file is loaded.
     *
     * @since 2.9.0
     *
     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     * @param string $mofile Path to the .mo file.
     */
    do_action('load_textdomain', $domain, $mofile);
    /**
     * Filter MO file path for loading translations for a specific text domain.
     *
     * @since 2.9.0
     *
     * @param string $mofile Path to the MO file.
     * @param string $domain Text domain. Unique identifier for retrieving translated strings.
     */
    $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:s4mobile,项目名称:WordPressTech,代码行数:64,代码来源:l10n.php

示例10: 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

示例11: yourls_load_textdomain

/**
 * Loads a MO file into the domain $domain.
 *
 * If the 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 $yourls_l10n global by $domain
 * and will be a MO object.
 *
 * @since 1.6
 * @uses $yourls_l10n Gets list of domain translated string objects
 *
 * @param string $domain Unique identifier for retrieving translated strings
 * @param string $mofile Path to the .mo file
 * @return bool True on success, false on failure
 */
function yourls_load_textdomain($domain, $mofile)
{
    global $yourls_l10n;
    $plugin_override = yourls_apply_filter('override_load_textdomain', false, $domain, $mofile);
    if (true == $plugin_override) {
        return true;
    }
    yourls_do_action('load_textdomain', $domain, $mofile);
    $mofile = yourls_apply_filter('load_textdomain_mofile', $mofile, $domain);
    if (!is_readable($mofile)) {
        trigger_error('Cannot read file ' . str_replace(YOURLS_ABSPATH . '/', '', $mofile) . '.' . ' Make sure there is a language file installed. More info: http://yourls.org/translations');
        return false;
    }
    $mo = new MO();
    if (!$mo->import_from_file($mofile)) {
        return false;
    }
    if (isset($yourls_l10n[$domain])) {
        $mo->merge_with($yourls_l10n[$domain]);
    }
    $yourls_l10n[$domain] =& $mo;
    return true;
}
开发者ID:liruqi,项目名称:YOURLS,代码行数:39,代码来源:functions-l10n.php

示例12: language

 public function language($langid = 'default')
 {
     if (!function_exists('gettext')) {
         $this->language_status = 'user';
         $mofile = $this->dir_root . 'langs/' . $langid . '/LC_MESSAGES/' . $this->app_id . '.mo';
         if (!is_readable($mofile)) {
             return false;
         }
         include $this->dir_phpok . 'libs/pomo/mo.php';
         $this->lang = new NOOP_Translations();
         $mo = new MO();
         if (!$mo->import_from_file($mofile)) {
             return false;
         }
         $mo->merge_with($this->lang);
         $this->lang =& $mo;
     } else {
         $this->language_status = 'gettext';
         if ($langid != 'default' && $langid != 'cn') {
             putenv('LANG=' . $langid);
             setlocale(LC_ALL, $langid);
             bindtextdomain($this->app_id, $this->dir_root . 'langs');
             textdomain($this->app_id);
         } else {
             putenv('LANG=zh_CN');
             setlocale(LC_ALL, 'zh_CN');
             bindtextdomain($this->app_id, $this->dir_root . 'langs');
             textdomain($this->app_id);
         }
     }
 }
开发者ID:renlong567,项目名称:43168,代码行数:31,代码来源:init.php

示例13: pll_load_textdomain

/**
 * Load a collection of `.mo` files 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` files are placed in the $pll_l10n global by $domain
 * and will be a MO object.
 *
 * @param   string  $domain  Text domain. Unique identifier for retrieving translated strings.
 * @return  bool             True on success, false on failure.
 *
 * @package WordPress\Skeleton\Polylang
 * @see     WordPress\load_textdomain
 */
function pll_load_textdomain($domain)
{
    global $polylang, $pll_domains, $pll_l10n;
    if (!is_object($polylang)) {
        return false;
    }
    if (empty($pll_domains[$domain])) {
        return false;
    }
    $pll_domain = $pll_domains[$domain];
    $languages_list = $polylang->model->get_languages_list();
    foreach ($languages_list as $language) {
        $locale = $language->locale;
        $mo = new MO();
        foreach ($pll_domain as $dirname => $basename) {
            $mofile = $dirname . '/' . sprintf($basename, $locale);
            if (!is_readable($mofile)) {
                continue;
            }
            if (!$mo->import_from_file($mofile)) {
                continue;
            }
            if (isset($pll_l10n[$domain][$language->slug])) {
                $mo->merge_with($pll_l10n[$domain][$language->slug]);
            }
            $pll_l10n[$domain][$language->slug] = $mo;
        }
    }
    return true;
}
开发者ID:locomotivemtl,项目名称:wordpress-boilerplate,代码行数:45,代码来源:polylang.php

示例14: dpa_override_i18n

/**
 * Replaces a string in the internationalisation table with a custom value.
 *
 * @global object $l10n List of domain translated string (gettext_reader) objects
 * @param string $find Text to find in the table
 * @param string $replace Replacement text
 * @since 2.0
 */
function dpa_override_i18n($find, $replace)
{
    global $l10n;
    if (isset($l10n['buddypress']) && isset($l10n['buddypress']->entries[$find])) {
        $l10n['buddypress']->entries[$find]->translations[0] = $replace;
    } else {
        $mo = new MO();
        $mo->add_entry(array('singular' => $find, 'translations' => array($replace)));
        if (isset($l10n['buddypress'])) {
            $mo->merge_with($l10n['buddypress']);
        }
        $l10n['buddypress'] = $mo;
    }
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:22,代码来源:achievements-core.php

示例15: load_textdomain

/**
 * 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.
 *
 * @since 1.5.0
 *
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
 * @param string $mofile Path to the .mo file.
 * @return bool True on success, false on failure.
 */
function load_textdomain($domain, $mofile)
{
    global $l10n;
    $plugin_override = false;
    if (true == $plugin_override) {
        return true;
    }
    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:poneisme,项目名称:WEIPDCRM,代码行数:35,代码来源:l10n.php


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