• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_get_available_translations函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_get_available_translations函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_available_translations函数的具体用法?PHP wp_get_available_translations怎么用?PHP wp_get_available_translations使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_get_available_translations函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getLanguageMutation

 protected function getLanguageMutation()
 {
     $i84676540daef1510ea5729a183290848a9e7accb = 0;
     $i05355412b857f5174e9a2f71b1e936a86ad60cd22621e8ed49bfcd8c8447959e1a834cd7df379456 = $i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900 = array();
     if (file_exists(ABSPATH . 'wp-admin/includes/translation-install.php')) {
         require_once ABSPATH . 'wp-admin/includes/translation-install.php';
         $i05355412b857f5174e9a2f71b1e936a86ad60cd22621e8ed49bfcd8c8447959e1a834cd7df379456 = get_available_languages();
         $i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900 = wp_get_available_translations();
     }
     if (isset($i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[SMS_DEFAULT_MUTATION]) && isset($i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[SMS_DEFAULT_MUTATION]["native_name"])) {
         $iced8cbcfca3c880f0f157e119d1cc6f8691e7e89 = array(SMS_DEFAULT_MUTATION => $i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[SMS_DEFAULT_MUTATION]["native_name"], "en_US" => "English (United States)");
         $this->mutationColors[SMS_DEFAULT_MUTATION] = $i84676540daef1510ea5729a183290848a9e7accb++ % count(self::$colors);
         $this->mutationColors["en_US"] = $i84676540daef1510ea5729a183290848a9e7accb++ % count(self::$colors);
     } else {
         $iced8cbcfca3c880f0f157e119d1cc6f8691e7e89 = array("en_US" => "English (United States)");
         $this->mutationColors["en_US"] = $i84676540daef1510ea5729a183290848a9e7accb++ % count(self::$colors);
     }
     foreach ($i05355412b857f5174e9a2f71b1e936a86ad60cd22621e8ed49bfcd8c8447959e1a834cd7df379456 as $i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772) {
         if ($i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772 != SMS_DEFAULT_MUTATION) {
             $this->mutationColors[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772] = $i84676540daef1510ea5729a183290848a9e7accb++ % count(self::$colors);
             if (isset($i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772]) && isset($i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772]["native_name"])) {
                 $iced8cbcfca3c880f0f157e119d1cc6f8691e7e89[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772] = $i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772]["native_name"];
             }
         }
     }
     return $iced8cbcfca3c880f0f157e119d1cc6f8691e7e89;
 }
开发者ID:etondeengole,项目名称:Store_Application,代码行数:27,代码来源:smsAdapter.php


示例2: activate

 /** 
  * @from 1.1
  */
 public function activate()
 {
     // initialization
     $options = get_option($this->option_name);
     $languages = $this->get_languages();
     if (empty($languages) && empty($options)) {
         require_once ABSPATH . 'wp-admin/includes/translation-install.php';
         $translations = wp_get_available_translations();
         $locale = get_locale();
         $language_name = isset($translations[$locale]['native_name']) ? $translations[$locale]['native_name'] : 'English';
         $language_slug = isset($translations[$locale]['iso']) && !empty($translations[$locale]['iso']) ? array_shift($translations[$locale]['iso']) : 'en';
         $post_id = wp_insert_post(array('post_type' => $this->language_post_type, 'post_title' => $language_name, 'post_name' => $language_slug, 'post_status' => 'publish'));
         $options = array();
         $options['main'] = $post_id;
         $options['default'] = $post_id;
         $options['show_slug'] = false;
         $options['autodetect'] = false;
         $options['current_first'] = false;
         $options['taxonomy'] = array('category');
         $options['cpt'] = array('post', 'page');
         $options['version'] = '1.2';
         update_option($this->option_name, $options);
     }
     $admins = get_role('administrator');
     $admins->add_cap('edit_language');
     $admins->add_cap('edit_languages');
     $admins->add_cap('edit_other_languages');
     $admins->add_cap('publish_languages');
     $admins->add_cap('read_language');
     $admins->add_cap('read_private_languages');
     $admins->add_cap('delete_language');
 }
开发者ID:Blueprint-Marketing,项目名称:sublanguage,代码行数:35,代码来源:admin.php


示例3: init

 /**
  * Constructor.
  */
 public function init()
 {
     $this->load_textdomain(self::NAME);
     $this->title(__('Localization', 'debug-bar-localization'));
     add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
     add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
     if (!function_exists('wp_get_available_translations')) {
         require_once ABSPATH . 'wp-admin/includes/translation-install.php';
     }
     $this->wp_translations = wp_get_available_translations();
     $this->load_call_types = array('core' => __('WP Core', 'debug-bar-localization'), 'theme' => __('Themes', 'debug-bar-localization'), 'muplugin' => __('Must-Use Plugins', 'debug-bar-localization'), 'plugin' => __('Plugins', 'debug-bar-localization'), 'unknown' => __('Unknown', 'debug-bar-localization'));
 }
开发者ID:jrfnl,项目名称:debug-bar-localization,代码行数:15,代码来源:class-debug-bar-localization.php


示例4: language_detector_admin_notices

 public static function language_detector_admin_notices()
 {
     // Check if the nag screen has been disabled for this language
     if (self::has_language_detector_dismissed()) {
         return;
     }
     // Get the current language locale
     $language = get_locale();
     require_once ABSPATH . 'wp-admin/includes/translation-install.php';
     $translations = wp_get_available_translations();
     printf('<div id="si_language_detect_nag_dismiss" class="notice notice-info is-dismissible"><p>%s</p></div>', sprintf(__('<span class="dashicons dashicons-megaphone"></span> <b>%1$s</b> does not have a translation for <b>%2$s</b>, please help the community translate at <a href="%3$s" target="_blank">%3$s</a>. Supporting translators receive major discounts on <a href="%4$s" target="_blank">pro licenses</a> and <a href="%5$s" target="_blank">add-ons</a>.', 'sprout-invoices'), esc_html(self::PLUGIN_NAME), esc_html($translations[$language]['native_name']), esc_url('https://translate.wordpress.org/projects/wp-plugins/sprout-invoices/'), si_get_sa_link('https://sproutapps.co/sprout-invoices/purchase/', 'translation'), si_get_sa_link('https://sproutapps.co/marketplace/', 'translation')));
 }
开发者ID:danielbachhuber,项目名称:marcgratch.com,代码行数:12,代码来源:SI_l10n.php


示例5: bogo_get_language_native_name

function bogo_get_language_native_name($locale)
{
    if ('en_US' == $locale) {
        return 'English (United States)';
    }
    if (!function_exists('wp_get_available_translations')) {
        require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    }
    static $available_translations = array();
    if (empty($available_translations)) {
        $available_translations = wp_get_available_translations();
    }
    if (isset($available_translations[$locale]['native_name'])) {
        return $available_translations[$locale]['native_name'];
    }
    return false;
}
开发者ID:karthikakamalanathan,项目名称:wp-cookieLawInfo,代码行数:17,代码来源:functions.php


示例6: load

 public function load($lang = null)
 {
     if (null !== $lang) {
         require_once ABSPATH . 'wp-admin/includes/translation-install.php';
         global $locale;
         if (!in_array($lang, get_available_languages())) {
             if (array_key_exists($lang, wp_get_available_translations())) {
                 $language = wp_download_language_pack($lang);
                 if ($language) {
                     load_default_textdomain($language);
                     $locale = $language;
                 }
             }
         } else {
             load_default_textdomain($lang);
             $locale = $lang;
         }
     }
     $this->init();
     $this->register_globals();
 }
开发者ID:pbearne,项目名称:contrib2core,代码行数:21,代码来源:class-wp-locale-switcher.php


示例7: flagatar_admin_bar

 public function flagatar_admin_bar()
 {
     global $wp_admin_bar, $blog_id;
     // This is functionality for WP 4.0+ only
     if (version_compare(get_bloginfo('version'), '4.0', '>=')) {
         // Get native language names
         if (file_exists(ABSPATH . 'wp-admin/includes/translation-install.php')) {
             require_once ABSPATH . 'wp-admin/includes/translation-install.php';
         }
         $translations = function_exists('wp_get_available_translations') ? wp_get_available_translations() : array();
     } else {
         $translations = array();
     }
     // Loop user's blogs trough
     foreach ((array) $wp_admin_bar->user->blogs as $blog) {
         $node_id = 'blog-' . $blog->userblog_id;
         $node = $wp_admin_bar->get_node($node_id);
         if ($node) {
             // We'll put it back...
             $wp_admin_bar->remove_node($node_id);
             // Get language
             $lang = is_multisite() ? get_blog_option($blog->userblog_id, 'WPLANG', 'en_US') : get_bloginfo('language');
             // Oh, just sometimes language returns empty on WP 4.0, try different key
             if (empty($lang) && is_multisite()) {
                 $lang = get_blog_option($blog->userblog_id, 'language', 'en_US');
             }
             // Still no language? Default to US.
             if (empty($lang)) {
                 $lang = 'en_US';
             }
             // Blog name - and is this blog currently active?
             $blogname = $blog_id == $blog->userblog_id ? '<strong class="current">' . $blog->blogname . '</strong>' : $blog->blogname;
             // Update node and put it back
             $node->title = '<div class="blavatar flagatar" style="background-image:url(' . plugins_url('flags/' . strtoupper(substr($lang, -2)) . '.png', __FILE__) . ')"></div> ' . $blogname;
             // If we have name for this language, show it as title. Fall back to locale.
             $node->meta['title'] = isset($translations[$lang]) ? esc_attr($translations[$lang]['english_name'] . ' (' . $translations[$lang]['native_name'] . ')') : esc_attr($lang);
             $wp_admin_bar->add_node($node);
         }
     }
 }
开发者ID:simison,项目名称:WP-admin-bar-languages,代码行数:40,代码来源:admin-bar-languages.php


示例8: _vp_get_language_name_by_code

 function _vp_get_language_name_by_code($code)
 {
     require_once ABSPATH . 'wp-admin/includes/translation-install.php';
     $translations = wp_get_available_translations();
     return isset($translations[$code]) ? $translations[$code]['native_name'] : 'English (United States)';
 }
开发者ID:versionpress,项目名称:versionpress,代码行数:6,代码来源:setup-hooks.php


示例9: _vp_get_language_name_by_code

 function _vp_get_language_name_by_code($code)
 {
     $translations = wp_get_available_translations();
     return isset($translations[$code]) ? $translations[$code]['native_name'] : 'English (United States)';
 }
开发者ID:wp-cpm,项目名称:versionpress,代码行数:5,代码来源:versionpress.php


示例10: hw_dropdown_languages

 /**
  * display list of language in dropdown
  * @param array $args
  */
 public static function hw_dropdown_languages($args = array())
 {
     $avaibles_languages = self::get_available_languages();
     //avaiable languages
     $args = wp_parse_args($args, array('id' => '', 'name' => '', 'languages' => array(), 'translations' => array(), 'selected' => '', 'show_available_translations' => true));
     $translations = $args['translations'];
     if (empty($translations)) {
         require_once ABSPATH . 'wp-admin/includes/translation-install.php';
         $translations = wp_get_available_translations();
     }
     if (empty($args['languages'])) {
         $args['languages'] = self::hw_get_available_languages();
     }
     /*
      * $args['languages'] should only contain the locales. Find the locale in
      * $translations to get the native name. Fall back to locale.
      */
     $languages = array();
     foreach ($args['languages'] as $locale) {
         //check lang for avaiable
         if (in_array($locale, $avaibles_languages)) {
             continue;
         }
         //exists installed this language
         $found_uninstalled = true;
         if (isset($translations[$locale])) {
             $translation = $translations[$locale];
             $languages[] = array('language' => $translation['language'], 'native_name' => $translation['native_name'], 'lang' => $translation['iso'][1]);
             // Remove installed language from available translations.
             unset($translations[$locale]);
         } else {
             $languages[] = array('language' => $locale, 'native_name' => $locale, 'lang' => '');
         }
     }
     if (!isset($found_uninstalled)) {
         return false;
     }
     //no avaible uninstalled languages in wp system
     printf('<select name="%s" id="%s" multiple style="max-height:200px;width:200px">', esc_attr($args['name']), esc_attr($args['id']));
     // Holds the HTML markup.
     $structure = array();
     foreach ($languages as $language) {
         $structure[] = sprintf('<option value="%s" lang="%s"%s data-installed="1">%s</option>', esc_attr($language['language']), esc_attr($language['lang']), selected($language['language'], $args['selected'], false), esc_html($language['native_name']));
     }
     echo join("\n", $structure);
     echo '</select>';
     return true;
 }
开发者ID:hoangsoft90,项目名称:hw-hoangweb-plugin,代码行数:52,代码来源:class.wp.languages.php


示例11: qtranxf_updateGettextDatabasesEx

/**
 * return 'true', if no update needed,
 * or 'false', if update is impossible to do,
 * or 0, if all languages were updated successfully,
 * or positive integer number of errors occurred on languages update.
 */
function qtranxf_updateGettextDatabasesEx($force = false, $only_for_language = '')
{
    if (empty($only_for_language)) {
        if (!$force) {
            $next_update = get_option('qtranslate_next_update_mo');
            if (time() < $next_update) {
                return true;
            }
        }
        update_option('qtranslate_next_update_mo', time() + 7 * 24 * 60 * 60);
    }
    if (!is_dir(WP_LANG_DIR)) {
        if (!@mkdir(WP_LANG_DIR)) {
            return false;
        }
    }
    require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    require_once ABSPATH . 'wp-admin/includes/file.php';
    //include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
    //$result = translations_api( 'core', array( 'version' => $wp_version ));
    //if ( is_wp_error( $result ) ){
    //	qtranxf_add_warning(__('Gettext databases <strong>not</strong> updated:', 'qtranslate') . ' ' . $result->get_error_message());
    //	return false;
    //}
    //$translations = $result['translations'];
    $translations = wp_get_available_translations();
    if (empty($translations)) {
        qtranxf_add_warning(__('Gettext databases <strong>not</strong> updated:', 'qtranslate') . ' ' . __('Failed to fetch the list of available translations.', 'qtranslate'));
        return false;
    }
    set_time_limit(300);
    if (empty($only_for_language)) {
        global $q_config;
        $langs = $q_config['enabled_languages'];
        $locales = $q_config['locale'];
    } else {
        $langs = array($only_for_language);
        $locales = qtranxf_language_configured('locale');
    }
    $errcnt = 0;
    /*
    	//qtranxf_dbg_log('qtranxf_updateGettextDatabasesEx: count($translations): ',count($translations));
    	//qtranxf_dbg_log('qtranxf_updateGettextDatabasesEx: $translations: ',$translations);
    	foreach ( $translations as $loc => $translation ) {
    		$locale = $translation['language'];
    		$lang = null;
    		foreach($langs as $lng) {
    			if(!isset($locales[$lng])){
    				$locales = qtranxf_language_configured('locale');
    				if(!isset($locales[$lng])) continue;
    			}
    			if($locales[$lng] != $locale) continue;
    			$lang = $lng;
    			break;
    		}
    		if(!$lang) continue;
    */
    foreach ($langs as $lang) {
        $loc = $locales[$lang];
        if (!isset($translations[$loc])) {
            continue;
        }
        $mo = WP_LANG_DIR . '/' . $loc . '.mo';
        $mo_ok = file_exists($mo);
        //qtranxf_dbg_log('qtranxf_updateGettextDatabasesEx: $mo_ok for '.$mo.': ',$mo_ok);
        if ($mo_ok) {
            continue;
        }
        //WP now takes care of translations updates on its own
        $translation = (object) $translations[$loc];
        $skin = new Automatic_Upgrader_Skin();
        $upgrader = new Language_Pack_Upgrader($skin);
        $translation->type = 'core';
        $result = $upgrader->upgrade($translation, array('clear_update_cache' => false));
        if (is_wp_error($result)) {
            qtranxf_add_warning(sprintf(__('Failed to update gettext database for "%s": %s', 'qtranslate'), $lang, $result->get_error_message()));
            ++$errcnt;
        }
    }
    return $errcnt;
}
开发者ID:dmitriyvi,项目名称:qtranslate-x,代码行数:88,代码来源:qtx_update_gettext_db.php


示例12: qtranxf_default_enabled_languages

/**
 * since 3.2.9.2
 */
function qtranxf_default_enabled_languages()
{
    //$languages = get_available_languages();
    //qtranxf_dbg_log('qtranxf_default_enabled_languages: count(languages): ',count($languages));
    //qtranxf_dbg_log('qtranxf_default_enabled_languages: get_available_languages: ',$languages);
    $locale = get_locale();
    if (!$locale) {
        $locale = 'en_US';
    }
    $lang = null;
    $locales = qtranxf_default_locale();
    foreach ($locales as $ln => $lo) {
        if ($lo != $locale) {
            continue;
        }
        $lang = $ln;
        break;
    }
    if (!$lang) {
        require_once ABSPATH . 'wp-admin/includes/translation-install.php';
        $translations = wp_get_available_translations();
        //qtranxf_dbg_log('qtranxf_default_enabled_languages: count(available_translations): ',count($translations));
        //qtranxf_dbg_log('qtranxf_default_enabled_languages: wp_get_available_translations: ',$translations);
        if (empty($translations[$locale])) {
            $lang = substr($locale, 0, 2);
            $name = 'Unknown';
        } else {
            $translation = $translations[$locale];
            $lang = current($translation['iso']);
            if (!$lang) {
                $lang = substr($locale, 0, 2);
            }
            $name = empty($translation['native_name']) ? 'Unknown' : $translation['native_name'];
        }
        $flag_location = WP_CONTENT_DIR . '/' . qtranxf_flag_location_default();
        do {
            $p = strpos($locale, '_');
            if ($p > 0) {
                $fn = strtolower(substr($locale, $p, 2));
                $flag = $fn . '.png';
                if (file_exists($flag_location . $flag)) {
                    break;
                }
                $flag = $fn . '.gpg';
                if (file_exists($flag_location . $flag)) {
                    break;
                }
            }
            $fn = strtolower(substr($locale, 0, 2));
            $flag = $fn . '.png';
            if (file_exists($flag_location . $flag)) {
                break;
            }
            $flag = $fn . '.gpg';
            if (file_exists($flag_location . $flag)) {
                break;
            }
            $flag = 'aa.png';
        } while (false);
        $props = array('language_name' => $name, 'flag' => $flag, 'locale' => $locale, 'date_format' => __('F j, Y'), 'time_format' => __('g:i a'), 'not_available' => 'Sorry, this entry is only available in %LANG:, : and %.');
        qtranxf_set_default_options($qtranslate_options);
        qtranxf_save_languages(array($lang => $props), $qtranslate_options);
        //qtranxf_dbg_log('qtranxf_default_enabled_languages: $props: ',$props);
    }
    $enabled_languages = array($lang);
    if ($lang != 'en') {
        $enabled_languages[] = 'en';
    }
    //qtranxf_dbg_log('qtranxf_default_enabled_languages: $lang="'.$lang.'"; $locale="'.$locale.'"; $enabled_languages: ',$enabled_languages);
    return $enabled_languages;
}
开发者ID:razik440,项目名称:qtranslate-x,代码行数:74,代码来源:qtx_activation_hook.php


示例13: wp_download_language_pack

/**
 * Download a language pack.
 *
 * @since 4.0.0
 *
 * @see wp_get_available_translations()
 *
 * @param string $download Language code to download.
 * @return string|bool Returns the language code if successfully downloaded
 *                     (or already installed), or false on failure.
 */
function wp_download_language_pack($download)
{
    // Check if the translation is already installed.
    if (in_array($download, get_available_languages())) {
        return $download;
    }
    if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
        return false;
    }
    // Confirm the translation is one we can download.
    $translations = wp_get_available_translations();
    if (!$translations) {
        return false;
    }
    foreach ($translations as $translation) {
        if ($translation['language'] === $download) {
            $translation_to_load = true;
            break;
        }
    }
    if (empty($translation_to_load)) {
        return false;
    }
    $translation = (object) $translation;
    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $skin = new Automatic_Upgrader_Skin();
    $upgrader = new Language_Pack_Upgrader($skin);
    $translation->type = 'core';
    $result = $upgrader->upgrade($translation, array('clear_update_cache' => false));
    if (!$result || is_wp_error($result)) {
        return false;
    }
    return $translation->language;
}
开发者ID:johnpbloch,项目名称:wordpress,代码行数:45,代码来源:translation-install.php


示例14: wp_dropdown_languages

/**
 * Language selector.
 *
 * @since 4.0.0
 * @since 4.3.0 Introduced the `echo` argument.
 *
 * @see get_available_languages()
 * @see wp_get_available_translations()
 *
 * @param string|array $args {
 *     Optional. Array or string of arguments for outputting the language selector.
 *
 *     @type string   $id                           ID attribute of the select element. Default empty.
 *     @type string   $name                         Name attribute of the select element. Default empty.
 *     @type array    $languages                    List of installed languages, contain only the locales.
 *                                                  Default empty array.
 *     @type array    $translations                 List of available translations. Default result of
 *                                                  wp_get_available_translations().
 *     @type string   $selected                     Language which should be selected. Default empty.
 *     @type bool|int $echo                         Whether to echo or return the generated markup. Accepts 0, 1, or their
 *                                                  bool equivalents. Default 1.
 *     @type bool     $show_available_translations  Whether to show available translations. Default true.
 * }
 * @return string HTML content only if 'echo' argument is 0.
 */
function wp_dropdown_languages($args = array())
{
    $args = wp_parse_args($args, array('id' => '', 'name' => '', 'languages' => array(), 'translations' => array(), 'selected' => '', 'echo' => 1, 'show_available_translations' => true));
    $translations = $args['translations'];
    if (empty($translations)) {
        require_once ABSPATH . 'wp-admin/includes/translation-install.php';
        $translations = wp_get_available_translations();
    }
    /*
     * $args['languages'] should only contain the locales. Find the locale in
     * $translations to get the native name. Fall back to locale.
     */
    $languages = array();
    foreach ($args['languages'] as $locale) {
        if (isset($translations[$locale])) {
            $translation = $translations[$locale];
            $languages[] = array('language' => $translation['language'], 'native_name' => $translation['native_name'], 'lang' => current($translation['iso']));
            // Remove installed language from available translations.
            unset($translations[$locale]);
        } else {
            $languages[] = array('language' => $locale, 'native_name' => $locale, 'lang' => '');
        }
    }
    $translations_available = !empty($translations) && $args['show_available_translations'];
    $output = sprintf('<select name="%s" id="%s">', esc_attr($args['name']), esc_attr($args['id']));
    // Holds the HTML markup.
    $structure = array();
    // List installed languages.
    if ($translations_available) {
        $structure[] = '<optgroup label="' . esc_attr_x('Installed', 'translations') . '">';
    }
    $structure[] = '<option value="" lang="en" data-installed="1">English (United States)</option>';
    foreach ($languages as $language) {
        $structure[] = sprintf('<option value="%s" lang="%s"%s data-installed="1">%s</option>', esc_attr($language['language']), esc_attr($language['lang']), selected($language['language'], $args['selected'], false), esc_html($language['native_name']));
    }
    if ($translations_available) {
        $structure[] = '</optgroup>';
    }
    // List available translations.
    if ($translations_available) {
        $structure[] = '<optgroup label="' . esc_attr_x('Available', 'translations') . '">';
        foreach ($translations as $translation) {
            $structure[] = sprintf('<option value="%s" lang="%s"%s>%s</option>', esc_attr($translation['language']), esc_attr(current($translation['iso'])), selected($translation['language'], $args['selected'], false), esc_html($translation['native_name']));
        }
        $structure[] = '</optgroup>';
    }
    $output .= join("\n", $structure);
    $output .= '</select>';
    if ($args['echo']) {
        echo $output;
    }
    return $output;
}
开发者ID:s4mobile,项目名称:WordPressTech,代码行数:78,代码来源:l10n.php


示例15: edd_lp_language_dropdown

/**
 * Renders an HTML Dropdown of all the available languages
 *
 * @param  array  $args   Arguments for the dropdown
 *
 * @return string $output Languages dropdown
 *
 * @since 0.1.0
 */
function edd_lp_language_dropdown($args = array())
{
    $defaults = array('name' => 'languages', 'id' => 'languages', 'class' => '', 'multiple' => false, 'selected' => 0, 'chosen' => false, 'placeholder' => __('Select a language', 'edd-language-packs'));
    $args = wp_parse_args($args, $defaults);
    require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    $translations = wp_get_available_translations();
    $options = array();
    if ($translations) {
        $options[0] = __('Select a language', 'edd-language-packs');
        foreach ($translations as $translation) {
            $options[$translation['language']] = esc_html($translation['english_name']);
        }
    } else {
        $options[0] = __('No languages found', 'edd-language-packs');
    }
    // This ensures that any selected products are included in the drop down
    if (is_array($args['selected'])) {
        foreach ($args['selected'] as $language => $english_name) {
            if (!in_array($language, $options)) {
                $options[$language] = $english_name;
            }
        }
    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
        if (!in_array($args['selected'], $options)) {
            $options[key($args['selected'])] = $args['selected'];
        }
    }
    $output = EDD()->html->select(array('name' => $args['name'], 'selected' => $args['selected'], 'id' => $args['id'], 'class' => $args['class'], 'options' => $options, 'chosen' => $args['chosen'], 'multiple' => $args['multiple'], 'placeholder' => $args['placeholder'], 'show_option_all' => false, 'show_option_none' => false));
    return $output;
}
开发者ID:fxbenard,项目名称:edd-language-packs,代码行数:39,代码来源:metabox.php


示例16: create_table_available_language


//.........这里部分代码省略.........
           </td>
            <td>
              <?php 
            if (isset($options['uls_available_language_new_flags']) && isset($options['uls_available_language_new_flags'][$lang_name])) {
                ?>
                <input type="checkbox" name="uls_available_language_del_flags[<?php 
                echo $lang_name;
                ?>
]" value="" />
              <?php 
            }
            ?>
           </td>
          </tr>
        <?php 
        }
        ?>
      </tbody>
    </table>
    <input type="hidden" name="available_languages" value="available_languages" >

    <br/>

    <table id="menu-locations-table" class="">
      <thead>
        <tr>
          <th>Install Additional Languages</th>
        </tr>
      </thead>
      <tbody>
        <tr>
        <?php 
        require_once ABSPATH . '/wp-admin/includes/translation-install.php';
        $translations = wp_get_available_translations();
        uasort($translations, array(__CLASS__, 'sort_translations_callback'));
        // check the requirement to can download language
        $execute_languages = true;
        $zip_message = '';
        // meessage information
        $ssl_message = '';
        // meessage information
        if (!class_exists('ZipArchive')) {
            $zip_message = '<p class="bg-warning">';
            $zip_message .= __("Missing class ZipArchive. Please install and retry later.");
            $zip_message .= '</p>';
            $execute_languages = false;
        }
        if (!extension_loaded('openssl')) {
            $ssl_message = '<p class="bg-warning">';
            $ssl_message .= __("Missing extension openssl. Please enable openss extension in your php.ini and retry later.");
            $ssl_message .= '</p>';
            $execute_languages = false;
        }
        echo "<td>" . __('Select a language') . ": </td><td><select id='tblang'>";
        if ($execute_languages) {
            foreach ($translations as $language) {
                echo "<option value='" . $language['language'] . ";" . $language['package'] . ";" . $language['english_name'] . "'>";
                echo $language['english_name'] . " - " . $language['native_name'] . "</option>";
            }
        }
        echo "</select>";
        if ($execute_languages) {
            ?>
            <input type="button"
                   class="button-primary"
                   id="button-download-language"
开发者ID:Webilop,项目名称:user-language-switch,代码行数:67,代码来源:uls-options.php


示例17: wp_enqueue_style

/**
 * Display the Welcome page.
 *
 * @author  Studio 164a
 * @package Charitable/Admin View/Welcome Page
 * @since   1.0.0
 */
wp_enqueue_style('charitable-admin-pages');
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
$gateways = Charitable_Gateways::get_instance()->get_active_gateways_names();
$campaigns = wp_count_posts('campaign');
$campaigns_count = $campaigns->publish + $campaigns->draft + $campaigns->future + $campaigns->pending + $campaigns->private;
$emails = charitable_get_helper('emails')->get_enabled_emails_names();
$install = isset($_GET['install']) && $_GET['install'];
$languages = wp_get_available_translations();
$locale = get_locale();
$language = isset($languages[$locale]['native_name']) ? $languages[$locale]['native_name'] : $locale;
$currency = charitable_get_option('currency', 'AUD');
$extensions = array();
if ('en_ZA' == $locale || 'ZAR' == $currency) {
    $extensions['ambassadors'] = __('Peer to peer fundraising or crowdfunding', 'charitable');
    $extensions['payfast'] = __('Accept donations in South African Rand', 'charitable');
    $extensions['anonymous-donations'] = __('Let donors give anonymously', 'charitable');
    $extensions['user-avatar'] = __('Let your donors upload their own profile photo', 'charitable');
} elseif ('hi_IN' == $locale || 'INR' == $currency) {
    $extensions['ambassadors'] = __('Peer to peer fundraising or crowdfunding', 'charitable');
    $extensions['payu-money'] = __('Accept donations in Indian Rupees', 'charitable');
    $extensions['anonymous-donations'] = __('Let donors give anonymously', 'charitable');
    $extensions['user-avatar'] = __('Let your donors upload their own profile photo', 'charitable');
} elseif (class_exists('EDD')) {
开发者ID:helgatheviking,项目名称:Charitable,代码行数:30,代码来源:page.php


示例18: set_default_slug_and_name

 /**
  * Set default language title and slug
  * Filter for 'wp_insert_post_data'
  *
  * @from 1.0
  */
 public function set_default_slug_and_name($data, $postarr)
 {
     global $sublanguage_admin;
     if ($data['post_type'] == $sublanguage_admin->language_post_type) {
         if (isset($_POST['language_locale_dropdown']) && $_POST['language_locale_dropdown']) {
             require_once ABSPATH . 'wp-admin/includes/translation-install.php';
             $translations = wp_get_available_translations();
             $locale = $_POST['language_locale_dropdown'];
             $data['post_content'] = esc_attr($_POST['language_locale_dropdown']);
             if (isset($translations[$locale]['native_name'])) {
                 $data['post_title'] = $translations[$locale]['native_name'];
             }
             if (isset($translations[$locale]['iso'])) {
                 while (is_array($translations[$locale]['iso'])) {
                     $translations[$locale]['iso'] = array_shift($translations[$locale]['iso']);
                 }
                 $data['post_name'] = $translations[$locale]['iso'];
             }
         }
     }
     return $data;
 }
开发者ID:Blueprint-Marketing,项目名称:sublanguage,代码行数:28,代码来源:admin-languages.php


示例19: get_proper_db_collation

 private static function get_proper_db_collation()
 {
     global $wp_version;
     if ($wp_version >= 4.2) {
         $blog_charset = 'utf8mb4';
         $language = 'unicode';
     } else {
         $blog_charset = strtolower(str_replace('-', '', get_option('blog_charset')));
         $language = 'general';
         require_once ABSPATH . 'wp-admin/includes/translation-install.php';
         $translations = wp_get_available_translations();
         $locale = get_locale();
         if ('en_US' != $locale && isset($translations[$locale])) {
             $language = strtolower($translations[$locale]['english_name']);
         }
     }
     return $blog_charset . '_' . $language . '_ci';
 }
开发者ID:Angrycreative,项目名称:Angry-Creative-Inspector,代码行数:18,代码来源:db_collations.php


示例20: test_tran

 function test_tran()
 {
     require_once ABSPATH . 'wp-admin/includes/translation-install.php';
     print_r(wp_get_available_translations());
     print_r(get_available_languages());
 }
开发者ID:pbearne,项目名称:contrib2core,代码行数:6,代码来源:date_i18n.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_get_comment_status函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_get_audio_extensions函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap