本文整理汇总了PHP中MO类的典型用法代码示例。如果您正苦于以下问题:PHP MO类的具体用法?PHP MO怎么用?PHP MO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MO类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wpll_create_mofile
function wpll_create_mofile()
{
global $wpll_pofile, $wpll_mofile;
include_once ABSPATH . WPINC . '/pomo/po.php';
$po = new PO();
if (!@$po->import_from_file($wpll_pofile)) {
return;
}
foreach ($po->entries as $key => $entry) {
if (!empty($entry->references)) {
$entry->references = array_filter($entry->references, 'wpll_filter_references');
if (empty($entry->references)) {
unset($po->entries[$key]);
continue;
}
}
if (!empty($entry->translations)) {
if ($entry->singular == $entry->translations[0]) {
unset($po->entries[$key]);
}
}
}
$mo = new MO();
$mo->headers = $po->headers;
$mo->entries = $po->entries;
$mo->export_to_file($wpll_mofile);
die;
}
开发者ID:slaFFik,项目名称:l10n-ru,代码行数:28,代码来源:wplang-lite.php
示例2: 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
示例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: 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
示例5: __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
示例6: load_textdomain
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: import_from_reader
function import_from_reader($reader) {
$reader->setEndian('little');
$endian = MO::get_byteorder($reader->readint32());
if (false === $endian) {
return false;
}
$reader->setEndian($endian);
$revision = $reader->readint32();
$total = $reader->readint32();
// get addresses of array of lenghts and offsets for original string and translations
$originals_lo_addr = $reader->readint32();
$translations_lo_addr = $reader->readint32();
$reader->seekto($originals_lo_addr);
$originals_lo = $reader->readint32array($total * 2); // each of
$reader->seekto($translations_lo_addr);
$translations_lo = $reader->readint32array($total * 2);
$length = create_function('$i', 'return $i * 2 + 1;');
$offset = create_function('$i', 'return $i * 2 + 2;');
for ($i = 0; $i < $total; ++$i) {
$reader->seekto($originals_lo[$offset($i)]);
$original = $reader->read($originals_lo[$length($i)]);
$reader->seekto($translations_lo[$offset($i)]);
$translation = $reader->read($translations_lo[$length($i)]);
if ('' == $original) {
$this->set_headers($this->make_headers($translation));
} else {
$this->add_entry($this->make_entry($original, $translation));
}
}
return true;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:35,代码来源:mo.php
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: change_language
/**
* change language : if language file not exist return false
* if language file not in THEME_LANGUAGE_PATH copy it from DEFAULT_LANG to THEME_LANGUAGE_PATH
* @since 1.0
*/
function change_language()
{
$lang = $_REQUEST['lang_name'];
if (!in_array($lang, $this->get_language_list())) {
wp_send_json(array('success' => false));
}
if (!in_array($lang, get_available_languages(THEME_LANGUAGE_PATH))) {
$mo = new MO();
$mo->set_header('Project-Id-Version', THEME_NAME . 'v' . ET_VERSION);
$mo->set_header('Report-Msgid-Bugs-To', ET_URL);
$mo->set_header('MO-Creation-Date', gmdate('Y-m-d H:i:s+00:00'));
$mo->set_header('MIME-Version', '1.0');
$mo->set_header('Content-Type', 'text/plain; charset=UTF-8');
$mo->set_header('Content-Transfer-Encoding', '8bit');
$mo->set_header('MO-Revision-Date', '2010-MO-DA HO:MI+ZONE');
$mo->set_header('Last-Translator', 'JOB <EMAIL@ADDRESS>');
$mo->set_header('Language-Team', 'ENGINETHEMES.COM <[email protected]>');
$mo->import_from_file(DEFAULT_LANGUAGE_PATH . '/' . $lang . '.mo');
$mo->export_to_file(THEME_LANGUAGE_PATH . '/' . $lang . '.mo');
}
$this->set_site_language($lang);
wp_send_json(array('success' => true, 'data' => array('ID' => $lang, 'lang_name' => $lang)));
}
开发者ID:rinodung,项目名称:wp-question,代码行数:28,代码来源:class-ae-languages.php
示例14: load_textdomain
/**
* Load a Text Domain
* @author Howard <[email protected]>
* @static
* @global array $l10n
* @param string $domain
* @param string $mofile
* @return boolean
*/
public static function load_textdomain($domain, $mofile)
{
global $l10n;
unset($l10n[$domain]);
if (!is_readable($mofile)) {
return false;
}
$mo = new MO();
if (!$mo->import_from_file($mofile)) {
return false;
}
$l10n[$domain] =& $mo;
return true;
}
开发者ID:gvh1993,项目名称:project-vvvh,代码行数:23,代码来源:global.php
示例15: header
header("Content-Length: 0");
ob_end_flush();
flush();
// set memory limit to the same as WP.
if (function_exists('memory_get_usage') && inbytes(@ini_get('memory_limit')) < inbytes($STATIC['WP']['MEMORY_LIMIT'])) {
@ini_set('memory_limit', $STATIC['WP']['MEMORY_LIMIT']);
}
//check existing Logfile
if (empty($STATIC) or !is_file($STATIC['LOGFILE'])) {
delete_working_file();
die('No logfile found!');
}
//load translation
if (is_file(dirname(__FILE__) . '/../lang/backwpup-' . $STATIC['WP']['WPLANG'] . '.mo')) {
require $STATIC['WP']['ABSPATH'] . $STATIC['WP']['WPINC'] . '/pomo/mo.php';
$TRANSLATE = new MO();
$TRANSLATE->import_from_file(dirname(__FILE__) . '/../lang/backwpup-' . $STATIC['WP']['WPLANG'] . '.mo');
} else {
require $STATIC['WP']['ABSPATH'] . $STATIC['WP']['WPINC'] . '/pomo/translations.php';
$TRANSLATE = new NOOP_Translations();
}
//set ticks
declare (ticks=1);
//set timezone
date_default_timezone_set('UTC');
// set charakter encoding
if (!@mb_internal_encoding($STATIC['WP']['CHARSET'])) {
mb_internal_encoding('UTF-8');
}
//set function for PHP user defineid error handling
set_error_handler('joberrorhandler', E_ALL | E_STRICT);
开发者ID:rubyerme,项目名称:rubyerme.github.com,代码行数:31,代码来源:job_run.php
示例16: load_translations_from_mo
private function load_translations_from_mo($mo_file)
{
$translations = array();
$mo = new MO();
$pomo_reader = new POMO_CachedFileReader($mo_file);
$mo->import_from_reader($pomo_reader);
foreach ($mo->entries as $str => $v) {
$str = str_replace("\n", '\\n', $v->singular);
$translations[] = array('orig' => $str, 'trans' => $v->translations[0], 'context' => $v->context);
if ($v->is_plural) {
$str = str_replace("\n", '\\n', $v->plural);
$translation = !empty($v->translations[1]) ? $v->translations[1] : $v->translations[0];
$translations[] = array('orig' => $str, 'trans' => $translation, 'context' => $v->context);
}
}
return $translations;
}
开发者ID:crazyyy,项目名称:octagram,代码行数:17,代码来源:wpml-string-scanner.class.php
示例17: get_translation_from_woocommerce_mo_file
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
示例18: _override_load_textdomain_filter
/**
* @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
示例19: icl_st_load_translations_from_mo
function icl_st_load_translations_from_mo($mo_file)
{
$translations = array();
$mo = new MO();
$mo->import_from_file($mo_file);
foreach ($mo->entries as $str => $v) {
$str = str_replace("\n", '\\n', $str);
$translations[$str] = $v->translations[0];
}
return $translations;
}
开发者ID:edgarter,项目名称:wecare,代码行数:11,代码来源:functions.php
示例20: 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
注:本文中的MO类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论