本文整理汇总了PHP中format_code_lang函数的典型用法代码示例。如果您正苦于以下问题:PHP format_code_lang函数的具体用法?PHP format_code_lang怎么用?PHP format_code_lang使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了format_code_lang函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: dropdown_languages
/**
* Show language selector.
*
* @param array $lang_files Optional. Language file names. Defaults to array().
* @param string $current Optional. Current language code. Defaults to ''.
*
* @return void
*/
private function dropdown_languages(array $lang_files = array(), $current = '')
{
$output = array();
// Inherit site specific language
$output[] = '<option value=""' . selected($current, '', FALSE) . '>' . __('Site Language', 'multilingual-press') . "</option>";
foreach ((array) $lang_files as $file_name) {
$code_lang = basename($file_name, '.mo');
$code_lang = esc_attr($code_lang);
if ('en_US' === $code_lang) {
// American English
$lang = __('English', 'multilingual-press');
} else {
$lang = format_code_lang($code_lang);
}
$lang = esc_html($lang);
$selected = selected($code_lang, $current, FALSE);
if ('' !== $selected) {
$selected = ' ' . $selected;
}
$output[$lang] = '<option value="' . $code_lang . '"' . $selected . '>' . $lang . '</option>';
}
// Order by name
uksort($output, 'strnatcasecmp');
echo implode("\n\t", $output);
}
开发者ID:luisarn,项目名称:multilingual-press,代码行数:33,代码来源:Mlp_User_Backend_Language.php
示例2: mu_dropdown_languages
function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
$flag = false;
$output = array();
foreach ( (array) $lang_files as $val ) {
$code_lang = basename( $val, '.mo' );
if ( $code_lang == 'en_US' ) { // American English
$flag = true;
$ae = __( 'American English' );
$output[$ae] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
} elseif ( $code_lang == 'en_GB' ) { // British English
$flag = true;
$be = __( 'British English' );
$output[$be] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>';
} else {
$translated = format_code_lang( $code_lang );
$output[$translated] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . esc_html ( $translated ) . '</option>';
}
}
if ( $flag === false ) // WordPress english
$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>";
// Order by name
uksort( $output, 'strnatcasecmp' );
$output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current );
echo implode( "\n\t", $output );
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:31,代码来源:ms.php
示例3: dropdown_languages
/**
* Show language selector.
*
* @param array $lang_files
* @param string $current
* @return void
*/
private function dropdown_languages($lang_files = array(), $current = '')
{
$output = array();
// Inherit site specific language
$output[] = '<option value=""' . selected($current, '', false) . '>' . __('Site Language') . "</option>";
foreach ((array) $lang_files as $file_name) {
$code_lang = basename($file_name, '.mo');
$code_lang = esc_attr($code_lang);
if ('en_US' === $code_lang) {
$lang = __('English');
} else {
$lang = format_code_lang($code_lang);
}
$lang = esc_html($lang);
$selected = selected($current, $code_lang, FALSE);
$output[$lang] = "<option value='{$code_lang}' {$selected}>{$lang}</option>";
}
// Order by name
uksort($output, 'strnatcasecmp');
echo implode("\n\t", $output);
}
开发者ID:ycms,项目名称:multilingual-press,代码行数:28,代码来源:Mlp_User_Backend_Language.php
示例4: get_available_languages
/**
* Load the languages set for each blog
*
* @since 0.1
* @static
* @access public
* @uses get_site_option, get_blog_option, get_current_blog_id, format_code_lang
* @param $nonrelated | filter out non-related blogs? By default
* @return array $options
*/
static function get_available_languages($nonrelated = FALSE)
{
$related_blogs = '';
// Get all registered blogs
$languages = get_site_option('inpsyde_multilingual');
if (!is_array($languages)) {
return FALSE;
}
// Do we need related blogs only?
if (FALSE === $nonrelated) {
$related_blogs = get_blog_option(get_current_blog_id(), 'inpsyde_multilingual_blog_relationship');
}
// No related blogs? Leave here.
if (!is_array($related_blogs) && FALSE === $nonrelated) {
return;
}
$options = array();
// Loop through blogs
foreach ($languages as $language_blogid => $language_data) {
// no blogs with a link to other blogs
if ('-1' === $language_data['lang']) {
continue;
}
// Filter out blogs that are not related
if (is_array($related_blogs) && !in_array($language_blogid, $related_blogs)) {
continue;
}
$lang = $language_data['lang'];
// We only need the first two letters
// of the language code, i.e. "de"
if (2 !== strlen($lang)) {
$lang = substr($lang, 0, 2);
if (is_admin()) {
$lang = format_code_lang($lang);
}
}
$options[$language_blogid] = $lang;
}
return $options;
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:50,代码来源:class-Mlp_Helpers.php
示例5: get_lang_codes
/**
* add filter to get the language
* shortcodes from wordpress
*
* @access public
* @since 0.1
* @uses add_filter, format_code_lang, remove_filter
* @return array $lang_codes
*/
public function get_lang_codes()
{
// Get Current Language Codes
add_filter('lang_codes', array($this, 'load_lang_codes'));
format_code_lang('');
// hack to get all available languages
remove_filter('lang_codes', array($this, 'load_lang_codes'));
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:17,代码来源:class-Mlp_Default_Module.php
示例6: get_available_languages
/**
* Get all available languages
* @uses get_available_languages
* @uses format_code_lang
* @return array
*/
public function get_available_languages()
{
if (empty($this->available_languages)) {
$this->available_languages = array('en_US' => __('American English', 'msls'));
foreach (get_available_languages() as $code) {
$this->available_languages[esc_attr($code)] = format_code_lang($code);
}
/**
* Returns custom filtered available languages
* @since 1.0
*
* @param array $available_languages
*/
$this->available_languages = (array) apply_filters('msls_options_get_available_languages', $this->available_languages);
}
return $this->available_languages;
}
开发者ID:kpobococ,项目名称:Multisite-Language-Switcher,代码行数:23,代码来源:MslsOptions.php
示例7: get_language_options
/**
* Returns the HTML of the option elements according to the given available languages and the selected one.
*
* @param string[] $language_files An array of all file names for all available languages.
* @param string $selected Currently selected language value.
*
* @return string The HTML of the option element according to the given arguments.
*/
private function get_language_options(array $language_files, $selected)
{
$options = array_reduce($language_files, function (array $options, $language_file) use($selected) {
$language_code = basename($language_file, '.mo');
$language = 'en_US' === $language_code ? __('English', 'multilingual-press') : format_code_lang($language_code);
$options[$language] = $this->get_language_option($language, $language_code, $selected);
return $options;
}, [$this->get_language_option(__('Site Language', 'multilingual-press'), '', $selected)]);
// Order by name.
uksort($options, 'strnatcasecmp');
return implode('', $options);
}
开发者ID:inpsyde,项目名称:multilingual-press,代码行数:20,代码来源:Setting.php
注:本文中的format_code_lang函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论