当前位置: 首页>>代码示例>>PHP>>正文


PHP unload_textdomain函数代码示例

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


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

示例1: wpcf7_load_textdomain

function wpcf7_load_textdomain($locale = null)
{
    global $l10n;
    $domain = 'contact-form-7';
    if (get_locale() == $locale) {
        $locale = null;
    }
    if (empty($locale)) {
        if (is_textdomain_loaded($domain)) {
            return true;
        } else {
            return load_plugin_textdomain($domain, false, $domain . '/languages');
        }
    } else {
        $mo_orig = $l10n[$domain];
        unload_textdomain($domain);
        $mofile = $domain . '-' . $locale . '.mo';
        $path = WP_PLUGIN_DIR . '/' . $domain . '/languages';
        if ($loaded = load_textdomain($domain, $path . '/' . $mofile)) {
            return $loaded;
        } else {
            $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
            return load_textdomain($domain, $mofile);
        }
        $l10n[$domain] = $mo_orig;
    }
    return false;
}
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:28,代码来源:l10n.php

示例2: test_is_textdomain_loaded_for_no_translations

 /**
  * @ticket 21319
  */
 function test_is_textdomain_loaded_for_no_translations()
 {
     $this->assertFalse(load_textdomain('wp-tests-domain', DIR_TESTDATA . '/non-existent-file'));
     $this->assertFalse(is_textdomain_loaded('wp-tests-domain'));
     $this->assertInstanceOf('NOOP_Translations', get_translations_for_domain('wp-tests-domain'));
     // Ensure that we don't confuse NOOP_Translations to be a loaded text domain.
     $this->assertFalse(is_textdomain_loaded('wp-tests-domain'));
     $this->assertFalse(unload_textdomain('wp-tests-domain'));
 }
开发者ID:boonebgorges,项目名称:wp,代码行数:12,代码来源:l10n.php

示例3: test_load_unload_textdomain

 function test_load_unload_textdomain()
 {
     $this->assertFalse(is_textdomain_loaded('wp-tests-domain'));
     $this->assertFalse(unload_textdomain('wp-tests-domain'));
     $file = DIR_TESTDATA . '/pomo/simple.mo';
     $this->assertTrue(load_textdomain('wp-tests-domain', $file));
     $this->assertTrue(is_textdomain_loaded('wp-tests-domain'));
     $this->assertTrue(unload_textdomain('wp-tests-domain'));
     $this->assertFalse(is_textdomain_loaded('wp-tests-domain'));
 }
开发者ID:nkeat12,项目名称:dv,代码行数:10,代码来源:l10n.php

示例4: test_theme_translation_should_be_translated_without_calling_load_theme_textdomain

 /**
  * @ticket 34114
  */
 public function test_theme_translation_should_be_translated_without_calling_load_theme_textdomain()
 {
     add_filter('locale', array($this, 'filter_set_locale_to_german'));
     switch_theme('internationalized-theme');
     include_once get_stylesheet_directory() . '/functions.php';
     $is_textdomain_loaded_before = is_textdomain_loaded('internationalized-theme');
     $expected_output = i18n_theme_test();
     $is_textdomain_loaded_after = is_textdomain_loaded('internationalized-theme');
     unload_textdomain('internationalized-theme');
     remove_filter('locale', array($this, 'filter_set_locale_to_german'));
     $this->assertFalse($is_textdomain_loaded_before);
     $this->assertSame('Das ist ein Dummy Theme', $expected_output);
     $this->assertTrue($is_textdomain_loaded_after);
 }
开发者ID:ntwb,项目名称:wordpress-travis,代码行数:17,代码来源:loadTextdomainJustInTime.php

示例5: set_language

 public function set_language($lang)
 {
     global $sitepress, $woocommerce;
     $sitepress->switch_lang($lang, true);
     $this->locale = $sitepress->get_locale($lang);
     add_filter('plugin_locale', array($this, 'set_locale'), 10, 2);
     unload_textdomain('woocommerce');
     unload_textdomain('woocommerce-germanized');
     unload_textdomain('woocommerce-germanized-pro');
     unload_textdomain('default');
     $woocommerce->load_plugin_textdomain();
     WC_germanized()->load_plugin_textdomain();
     do_action('woocommerce_gzd_wpml_lang_changed', $lang);
     load_default_textdomain();
     global $wp_locale;
     $wp_locale = new WP_Locale();
 }
开发者ID:ronzeiller,项目名称:woocommerce-germanized,代码行数:17,代码来源:class-wc-gzd-wpml-helper.php

示例6: load_textdomain

 /**
  * Bootstrap localisation of self
  */
 public static function load_textdomain($locale = null)
 {
     if (is_null($locale)) {
         $locale = get_locale();
     }
     if (!$locale || 0 === strpos($locale, 'en')) {
         self::$locale and unload_textdomain(Loco::NS);
         $locale = 'en_US';
     } else {
         if (self::$locale !== $locale) {
             $plugin_rel_path = basename(self::basedir());
             load_plugin_textdomain(Loco::NS, false, $plugin_rel_path . '/languages');
         }
     }
     // detect changes in plugin locale, binding once only
     isset(self::$locale) or add_filter('plugin_locale', array(__CLASS__, 'filter_plugin_locale'), 10, 2);
     self::$locale = $locale;
 }
开发者ID:josejoaosantos,项目名称:wp-loco,代码行数:21,代码来源:loco-boot.php

示例7: test_switches_to_es

 function test_switches_to_es()
 {
     // We need to something in order to set the Global $l10n
     $file = DIR_TESTDATA . '/pomo/simple.mo';
     load_textdomain('wp-tests-domain', $file);
     $this->assertEquals('es_ES', switch_to_locale('es_ES'));
     $this->assertEquals('es_ES', get_locale());
     $this->assertEquals('en_GB', switch_to_locale('en_GB'));
     $this->assertEquals('en_GB', get_locale());
     // return early if you try to switch to the same locale
     $this->assertEquals('en_GB', switch_to_locale('en_GB'));
     $this->assertEquals('en_GB', get_locale());
     $this->assertEquals('es_ES', restore_locale());
     $this->assertEquals('es_ES', get_locale());
     $this->assertEquals('en_US', restore_locale(true));
     $this->assertEquals('en_US', get_locale());
     $this->assertEquals('xx_XX', switch_to_locale('xx_XX'));
     $this->assertEquals('xx_XX', get_locale());
     // tidy up
     unload_textdomain('wp-tests-domain');
     global $l10n;
     $l10n = null;
 }
开发者ID:pbearne,项目名称:contrib2core,代码行数:23,代码来源:class-wp-switch-locale.php

示例8: k12nn_locale_func

function k12nn_locale_func($atts, $content = null)
{
    $a = shortcode_atts(array('locale' => 'en_US'), $atts);
    global $k12nn_locale;
    global $k12nn_previous_locale;
    $k12nn_previous_locale = get_locale();
    $k12nn_locale = $a['locale'];
    add_filter('locale', 'k12nn_redefine_locale');
    setlocale(LC_ALL, $k12nn_locale);
    if (function_exists('dk_speakout_translate')) {
        unload_textdomain('dk_speakout');
        dk_speakout_translate();
    }
    $return = do_shortcode($content);
    $k12nn_locale = $k12nn_previous_locale;
    remove_filter('locale', 'k12nn_redefine_locale');
    setlocale(LC_ALL, $k12nn_locale);
    if (function_exists('dk_speakout_translate')) {
        unload_textdomain('dk_speakout');
        dk_speakout_translate();
    }
    return $return;
}
开发者ID:k12newsnetwork,项目名称:k12nn-locale,代码行数:23,代码来源:k12nn-locale.php

示例9: trim

         $value = null;
         if (isset($_POST[$option])) {
             $value = $_POST[$option];
             if (!is_array($value)) {
                 $value = trim($value);
             }
             $value = wp_unslash($value);
         }
         update_option($option, $value);
     }
     // Switch translation in case WPLANG was changed.
     $language = get_option('WPLANG');
     if ($language) {
         load_default_textdomain($language);
     } else {
         unload_textdomain('default');
     }
 }
 /**
  * Handle settings errors and return to options page
  */
 // If no settings errors were registered add a general 'updated' message.
 if (!count(get_settings_errors())) {
     add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
 }
 set_transient('settings_errors', get_settings_errors(), 30);
 /**
  * Redirect back to the settings page that was submitted
  */
 $goback = add_query_arg('settings-updated', 'true', wp_get_referer());
 wp_redirect($goback);
开发者ID:hadywisam,项目名称:WordPress,代码行数:31,代码来源:options.php

示例10: create_missing_store_pages

 /**
  * create missing pages
  */
 function create_missing_store_pages()
 {
     global $sitepress, $wp_rewrite, $woocommerce_wpml, $woocommerce;
     $miss_lang = $this->get_missing_store_pages();
     //dummy array for names
     $names = array(__('Cart', 'woocommerce-multilingual'), __('Checkout', 'woocommerce-multilingual'), __('Checkout → Pay', 'woocommerce-multilingual'), __('Order Received', 'woocommerce-multilingual'), __('My Account', 'woocommerce-multilingual'), __('Change Password', 'woocommerce-multilingual'), __('Edit My Address', 'woocommerce-multilingual'), __('Logout', 'woocommerce-multilingual'), __('Lost Password', 'woocommerce-multilingual'), __('View Order', 'woocommerce-multilingual'), __('Shop', 'woocommerce-multilingual'));
     if (isset($miss_lang['codes'])) {
         $wp_rewrite = new WP_Rewrite();
         $check_pages = $this->get_wc_pages();
         $default_language = $sitepress->get_default_language();
         if (in_array($default_language, $miss_lang['codes'])) {
             $miss_lang['codes'] = array_merge(array($default_language), array_diff($miss_lang['codes'], array($default_language)));
         }
         foreach ($miss_lang['codes'] as $mis_lang) {
             $args = array();
             unload_textdomain('woocommerce-multilingual');
             $sitepress->switch_lang($mis_lang);
             load_textdomain('woocommerce-multilingual', WCML_LOCALE_PATH . '/woocommerce-multilingual-' . $sitepress->get_locale($mis_lang) . '.mo');
             foreach ($check_pages as $page) {
                 $orig_id = get_option($page);
                 $trid = $sitepress->get_element_trid($orig_id, 'post_page');
                 $translations = $sitepress->get_element_translations($trid, 'post_page', true);
                 if (!isset($translations[$mis_lang]) || !is_null($translations[$mis_lang]->element_id) && get_post_status($translations[$mis_lang]->element_id) != 'publish') {
                     $orig_page = get_post($orig_id);
                     switch ($page) {
                         case 'woocommerce_shop_page_id':
                             $page_title = __('Shop', 'woocommerce-multilingual');
                             break;
                         case 'woocommerce_cart_page_id':
                             $page_title = __('Cart', 'woocommerce-multilingual');
                             break;
                         case 'woocommerce_checkout_page_id':
                             $page_title = __('Checkout', 'woocommerce-multilingual');
                             break;
                         case 'woocommerce_myaccount_page_id':
                             $page_title = __('My Account', 'woocommerce-multilingual');
                             break;
                         default:
                             $page_title = __($orig_page->post_title, 'woocommerce-multilingual');
                             break;
                     }
                     $args['post_title'] = $page_title;
                     $args['post_type'] = $orig_page->post_type;
                     $args['post_content'] = $orig_page->post_content;
                     $args['post_excerpt'] = $orig_page->post_excerpt;
                     $args['post_status'] = isset($translations[$mis_lang]->element_id) && get_post_status($translations[$mis_lang]->element_id) != 'publish' ? 'publish' : $orig_page->post_status;
                     $args['menu_order'] = $orig_page->menu_order;
                     $args['ping_status'] = $orig_page->ping_status;
                     $args['comment_status'] = $orig_page->comment_status;
                     $post_parent = apply_filters('translate_object_id', $orig_page->post_parent, 'page', false, $mis_lang);
                     $args['post_parent'] = is_null($post_parent) ? 0 : $post_parent;
                     $new_page_id = wp_insert_post($args);
                     if (isset($translations[$mis_lang]->element_id) && get_post_status($translations[$mis_lang]->element_id) == 'trash' && $mis_lang == $default_language) {
                         update_option($page, $new_page_id);
                     }
                     if (isset($translations[$mis_lang]->element_id) && !is_null($translations[$mis_lang]->element_id)) {
                         $sitepress->set_element_language_details($translations[$mis_lang]->element_id, 'post_page', false, $mis_lang);
                     }
                     $trid = $sitepress->get_element_trid($orig_id, 'post_page');
                     $sitepress->set_element_language_details($new_page_id, 'post_page', $trid, $mis_lang);
                 }
             }
             unload_textdomain('woocommerce-multilingual');
             $sitepress->switch_lang($default_language);
             load_textdomain('woocommerce-multilingual', WCML_LOCALE_PATH . '/woocommerce-multilingual-' . $sitepress->get_locale($default_language) . '.mo');
         }
         wp_redirect(admin_url('admin.php?page=wpml-wcml'));
         exit;
     }
 }
开发者ID:helgatheviking,项目名称:woocommerce-multilingual,代码行数:73,代码来源:store-pages.class.php

示例11: wp_timezone_choice

/**
 * Gives a nicely-formatted list of timezone strings.
 *
 * @since 2.9.0
 * @since 4.7.0 Added the `$locale` parameter.
 *
 * @staticvar bool $mo_loaded
 * @staticvar string $locale_loaded
 *
 * @param string $selected_zone Selected timezone.
 * @param string $locale        Optional. Locale to load the timezones in. Default current site locale.
 * @return string
 */
function wp_timezone_choice($selected_zone, $locale = null)
{
    static $mo_loaded = false, $locale_loaded = null;
    $continents = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
    // Load translations for continents and cities.
    if (!$mo_loaded || $locale !== $locale_loaded) {
        $locale_loaded = $locale ? $locale : get_locale();
        $mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
        unload_textdomain('continents-cities');
        load_textdomain('continents-cities', $mofile);
        $mo_loaded = true;
    }
    $zonen = array();
    foreach (timezone_identifiers_list() as $zone) {
        $zone = explode('/', $zone);
        if (!in_array($zone[0], $continents)) {
            continue;
        }
        // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
        $exists = array(0 => isset($zone[0]) && $zone[0], 1 => isset($zone[1]) && $zone[1], 2 => isset($zone[2]) && $zone[2]);
        $exists[3] = $exists[0] && 'Etc' !== $zone[0];
        $exists[4] = $exists[1] && $exists[3];
        $exists[5] = $exists[2] && $exists[3];
        $zonen[] = array('continent' => $exists[0] ? $zone[0] : '', 'city' => $exists[1] ? $zone[1] : '', 'subcity' => $exists[2] ? $zone[2] : '', 't_continent' => $exists[3] ? translate(str_replace('_', ' ', $zone[0]), 'continents-cities') : '', 't_city' => $exists[4] ? translate(str_replace('_', ' ', $zone[1]), 'continents-cities') : '', 't_subcity' => $exists[5] ? translate(str_replace('_', ' ', $zone[2]), 'continents-cities') : '');
    }
    usort($zonen, '_wp_timezone_choice_usort_callback');
    $structure = array();
    if (empty($selected_zone)) {
        $structure[] = '<option selected="selected" value="">' . __('Select a city') . '</option>';
    }
    foreach ($zonen as $key => $zone) {
        // Build value in an array to join later
        $value = array($zone['continent']);
        if (empty($zone['city'])) {
            // It's at the continent level (generally won't happen)
            $display = $zone['t_continent'];
        } else {
            // It's inside a continent group
            // Continent optgroup
            if (!isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) {
                $label = $zone['t_continent'];
                $structure[] = '<optgroup label="' . esc_attr($label) . '">';
            }
            // Add the city to the value
            $value[] = $zone['city'];
            $display = $zone['t_city'];
            if (!empty($zone['subcity'])) {
                // Add the subcity to the value
                $value[] = $zone['subcity'];
                $display .= ' - ' . $zone['t_subcity'];
            }
        }
        // Build the value
        $value = join('/', $value);
        $selected = '';
        if ($value === $selected_zone) {
            $selected = 'selected="selected" ';
        }
        $structure[] = '<option ' . $selected . 'value="' . esc_attr($value) . '">' . esc_html($display) . "</option>";
        // Close continent optgroup
        if (!empty($zone['city']) && (!isset($zonen[$key + 1]) || isset($zonen[$key + 1]) && $zonen[$key + 1]['continent'] !== $zone['continent'])) {
            $structure[] = '</optgroup>';
        }
    }
    // Do UTC
    $structure[] = '<optgroup label="' . esc_attr__('UTC') . '">';
    $selected = '';
    if ('UTC' === $selected_zone) {
        $selected = 'selected="selected" ';
    }
    $structure[] = '<option ' . $selected . 'value="' . esc_attr('UTC') . '">' . __('UTC') . '</option>';
    $structure[] = '</optgroup>';
    // Do manual UTC offsets
    $structure[] = '<optgroup label="' . esc_attr__('Manual Offsets') . '">';
    $offset_range = array(-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14);
    foreach ($offset_range as $offset) {
        if (0 <= $offset) {
            $offset_name = '+' . $offset;
        } else {
            $offset_name = (string) $offset;
        }
        $offset_value = $offset_name;
        $offset_name = str_replace(array('.25', '.5', '.75'), array(':15', ':30', ':45'), $offset_name);
        $offset_name = 'UTC' . $offset_name;
        $offset_value = 'UTC' . $offset_value;
        $selected = '';
        if ($offset_value === $selected_zone) {
//.........这里部分代码省略.........
开发者ID:johnpbloch,项目名称:wordpress,代码行数:101,代码来源:functions.php

示例12: wcml_refresh_text_domain

 function wcml_refresh_text_domain()
 {
     global $woocommerce;
     $domain = 'woocommerce';
     unload_textdomain($domain);
     $woocommerce->load_plugin_textdomain();
 }
开发者ID:heaptrace,项目名称:onlineshop,代码行数:7,代码来源:products.class.php

示例13: change_email_language

 function change_email_language($lang)
 {
     global $sitepress, $woocommerce;
     $sitepress->switch_lang($lang, true);
     $this->locale = $sitepress->get_locale($lang);
     unload_textdomain('woocommerce');
     unload_textdomain('default');
     $woocommerce->load_plugin_textdomain();
     load_default_textdomain();
     global $wp_locale;
     $wp_locale = new WP_Locale();
 }
开发者ID:helgatheviking,项目名称:woocommerce-multilingual,代码行数:12,代码来源:emails.class.php

示例14: switchLanguage

 /**
  * Reload text domains with order locale.
  *
  * @param string $language Language slug (e.g. en, de )
  */
 public function switchLanguage($language)
 {
     if (class_exists('Polylang')) {
         global $locale, $polylang, $woocommerce;
         static $cache;
         // Polylang string translations cache object to avoid loading the same translations object several times
         // Cache object not found. Create one...
         if (empty($cache)) {
             $cache = new \PLL_Cache();
         }
         //$current_language = pll_current_language( 'locale' );
         // unload plugin's textdomains
         unload_textdomain('default');
         unload_textdomain('woocommerce');
         // set locale to order locale
         $locale = apply_filters('locale', $language);
         $polylang->curlang->locale = $language;
         // Cache miss
         if (false === ($mo = $cache->get($language))) {
             $mo = new \PLL_MO();
             $mo->import_from_db($GLOBALS['polylang']->model->get_language($language));
             $GLOBALS['l10n']['pll_string'] =& $mo;
             // Add to cache
             $cache->set($language, $mo);
         }
         // (re-)load plugin's textdomain with order locale
         load_default_textdomain($language);
         $woocommerce->load_plugin_textdomain();
         $wp_locale = new \WP_Locale();
     }
 }
开发者ID:hyyan,项目名称:woo-poly-integration,代码行数:36,代码来源:Emails.php

示例15: twitter_api_load_textdomain

/**
 * Enable localisation
 * @internal
 */
function twitter_api_load_textdomain($locale = null, $domain = 'twitter-api')
{
    static $current_locale;
    if (is_null($locale)) {
        $locale = get_locale();
    }
    if (!$locale || 0 === strpos($locale, 'en')) {
        $current_locale and unload_textdomain($domain);
        $locale = 'en_US';
    } else {
        if ($current_locale !== $locale) {
            // purposefully not calling load_plugin_textdomain, due to symlinking
            // and not knowing what plugin this could be called from.
            $mofile = realpath(twitter_api_basedir() . '/lang/' . $domain . '-' . $locale . '.mo');
            if (!load_textdomain($domain, $mofile)) {
                $mofile = WP_LANG_DIR . '/plugins/' . $domain . '-' . $locale . '.mo';
                load_textdomain($domain, $mofile);
            }
        }
    }
    // detect changes in plugin locale, binding once only
    if (!isset($current_locale)) {
        add_filter('plugin_locale', '_twitter_api_filter_plugin_locale', 10, 2);
    }
    $current_locale = $locale;
}
开发者ID:shellygraham,项目名称:green-building-services,代码行数:30,代码来源:twitter-api.php


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