本文整理汇总了PHP中MO::set_header方法的典型用法代码示例。如果您正苦于以下问题:PHP MO::set_header方法的具体用法?PHP MO::set_header怎么用?PHP MO::set_header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MO
的用法示例。
在下文中一共展示了MO::set_header方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function test_export_mo_file()
{
$entries = array();
$entries[] = new Translation_Entry(array('singular' => 'pink', 'translations' => array('розов')));
$no_translation_entry = new Translation_Entry(array('singular' => 'grey'));
$entries[] = new Translation_Entry(array('singular' => 'green', 'plural' => 'greens', 'translations' => array('зелен', 'зелени')));
$entries[] = new Translation_Entry(array('singular' => 'red', 'context' => 'color', 'translations' => array('червен')));
$entries[] = new Translation_Entry(array('singular' => 'red', 'context' => 'bull', 'translations' => array('бик')));
$entries[] = new Translation_Entry(array('singular' => 'maroon', 'plural' => 'maroons', 'context' => 'context', 'translations' => array('пурпурен', 'пурпурни')));
$mo = new MO();
$mo->set_header('Project-Id-Version', 'Baba Project 1.0');
foreach ($entries as $entry) {
$mo->add_entry($entry);
}
$mo->add_entry($no_translation_entry);
$temp_fn = $this->temp_filename();
$mo->export_to_file($temp_fn);
$again = new MO();
$again->import_from_file($temp_fn);
$this->assertEquals(count($entries), count($again->entries));
foreach ($entries as $entry) {
$this->assertEquals($entry, $again->entries[$entry->key()]);
}
}
示例2: MO
/**
* 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)));
}