本文整理汇总了PHP中MO类的典型用法代码示例。如果您正苦于以下问题:PHP MO类的具体用法?PHP MO怎么用?PHP MO使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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]);
}
示例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;
}
示例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 <enginethemes@enginethemes.com>');
$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)));
}
示例14: load_textdomain
/**
* Load a Text Domain
* @author Howard <howard@realtyna.com>
* @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;
}
示例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);