コード例 #1
0
function qtrans_getLanguageName($lang = '')
{
    global $q_config;
    if ($lang == '' || !qtrans_isEnabled($lang)) {
        $lang = $q_config['language'];
    }
    return $q_config['language_name'][$lang];
}
コード例 #2
0
 /**
  * Fetch the prefix for the current language if one is set and we are not
  * hiding the default language.
  *
  * @return string|false
  */
 function get_prefix()
 {
     $language = $this->config['language'];
     if (qtrans_isEnabled($language)) {
         if (!$this->config['hide_default_language'] || $language != $this->config['default_language']) {
             return $language;
         }
     }
     return false;
 }
コード例 #3
0
ファイル: i18n.php プロジェクト: EliasGoldberg/troop-sim
/**
 * Get all langs to display in admin bar for qTranslate
 *
 * @since 1.3.5
 *
 * @return array $langlinks List of active languages
 */
function get_rocket_qtranslate_langs_for_admin_bar()
{
    global $q_config;
    $langlinks = array();
    $currentlang = array();
    foreach ($q_config['enabled_languages'] as $lang) {
        $langlinks[$lang] = array('code' => $lang, 'anchor' => $q_config['language_name'][$lang], 'flag' => '<img src="' . trailingslashit(WP_CONTENT_URL) . $q_config['flag_location'] . $q_config['flag'][$lang] . '" alt="' . $q_config['language_name'][$lang] . '" width="18" height="12" />');
    }
    if (isset($_GET['lang']) && qtrans_isEnabled($_GET['lang'])) {
        $currentlang[$_GET['lang']] = $langlinks[$_GET['lang']];
        unset($langlinks[$_GET['lang']]);
        $langlinks = $currentlang + $langlinks;
    }
    return $langlinks;
}
コード例 #4
0
function qs_service()
{
    global $q_config, $qs_public_key, $qs_error_messages;
    if (!isset($_REQUEST['post'])) {
        echo '<script type="text/javascript">document.location="edit.php";</script>';
        printf(__('To translate a post, please go to the <a href="%s">edit posts overview</a>.', 'qtranslate'), 'edit.php');
        exit;
    }
    $post_id = intval($_REQUEST['post']);
    $translate_from = '';
    if (isset($_REQUEST['source_language']) && qtrans_isEnabled($_REQUEST['source_language'])) {
        $translate_from = $_REQUEST['source_language'];
    }
    if (isset($_REQUEST['target_language']) && qtrans_isEnabled($_REQUEST['target_language'])) {
        $translate_to = $_REQUEST['target_language'];
    }
    if ($translate_to == $translate_from) {
        $translate_to = '';
    }
    $post =& get_post($post_id);
    if (!$post) {
        printf(__('Post with id "%s" not found!', 'qtranslate'), $post_id);
        return;
    }
    $default_service = intval(get_option('qs_default_service'));
    $service_settings = get_option('qs_service_settings');
    // Detect available Languages and possible target languages
    $available_languages = qtrans_getAvailableLanguages($post->post_content);
    if (sizeof($available_languages) == 0) {
        $error = __('The requested Post has no content, no Translation possible.', 'qtranslate');
    }
    // try to guess source and target language
    if (!in_array($translate_from, $available_languages)) {
        $translate_from = '';
    }
    $missing_languages = array_diff($q_config['enabled_languages'], $available_languages);
    if (empty($translate_from) && in_array($q_config['default_language'], $available_languages) && $translate_to != $q_config['default_language']) {
        $translate_from = $q_config['default_language'];
    }
    if (empty($translate_to) && sizeof($missing_languages) == 1) {
        $translate_to = $missing_languages[0];
    }
    if (in_array($translate_to, $available_languages)) {
        $message = __('The Post already has content for the selected target language. If a translation request is send, the current text for the target language will be overwritten.', 'qtranslate');
    }
    if (sizeof($available_languages) == 1) {
        if ($available_languages[0] == $translate_to) {
            $translate_to = '';
        }
        $translate_from = $available_languages[0];
    } elseif ($translate_from == '' && sizeof($available_languages) > 1) {
        $languages = qtrans_getSortedLanguages();
        foreach ($languages as $language) {
            if ($language != $translate_to && in_array($language, $available_languages)) {
                $translate_from = $language;
                break;
            }
        }
    }
    // link to current page with get variables
    $url_link = add_query_arg('post', $post_id);
    if (!empty($translate_to)) {
        $url_link = add_query_arg('target_language', $translate_to, $url_link);
    }
    if (!empty($translate_from)) {
        $url_link = add_query_arg('source_language', $translate_from, $url_link);
    }
    // get correct title and content
    $post_title = qtrans_use($translate_from, $post->post_title);
    $post_content = qtrans_use($translate_from, $post->post_content);
    if (isset($translate_from) && isset($translate_to)) {
        $title = sprintf('Translate &quot;%1$s&quot; from %2$s to %3$s', htmlspecialchars($post_title), $q_config['language_name'][$translate_from], $q_config['language_name'][$translate_to]);
    } elseif (isset($translate_from)) {
        $title = sprintf('Translate &quot;%1$s&quot; from %2$s', htmlspecialchars($post_title), $q_config['language_name'][$translate_from]);
    } else {
        $title = sprintf('Translate &quot;%1$s&quot;', htmlspecialchars($post_title));
    }
    // Check data
    if (isset($_POST['service_id'])) {
        $service_id = intval($_POST['service_id']);
        $default_service = $service_id;
        update_option('qs_default_service', $service_id);
        $order_key = substr(md5(time() . AUTH_KEY), 0, 20);
        $request = array('order_service_id' => $service_id, 'order_url' => get_option('home'), 'order_key' => $order_key, 'order_title' => $post_title, 'order_text' => $post_content, 'order_source_language' => $translate_from, 'order_source_locale' => $q_config['locale'][$translate_from], 'order_target_language' => $translate_to, 'order_target_locale' => $q_config['locale'][$translate_to]);
        // check for additional fields
        if (is_array($service_settings[$service_id])) {
            $request['order_required_field'] = array();
            foreach ($service_settings[$service_id] as $setting => $value) {
                $request['order_required_field'][$setting] = $value;
            }
        }
        $answer = qs_queryQS(QS_INIT_TRANSLATION, $request);
        if (isset($answer['error'])) {
            $error = sprintf(__('An error occured: %s', 'qtranslate'), $qs_error_messages[$answer['error']]);
            if ($answer['message'] != '') {
                $error .= '<br />' . sprintf(__('Additional information: %s', 'qtranslate'), qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($answer['message']));
            }
        }
        if (isset($answer['order_id'])) {
            $orders = get_option('qs_orders');
            if (!is_array($orders)) {
                $orders = array();
            }
            $orders[] = array('post_id' => $post_id, 'service_id' => $service_id, 'source_language' => $translate_from, 'target_language' => $translate_to, 'order' => array('order_key' => $order_key, 'order_id' => $answer['order_id']));
            update_option('qs_orders', $orders);
            if (empty($answer['message'])) {
                $order_completed_message = '';
            } else {
                $order_completed_message = htmlspecialchars($answer['message']);
            }
            qs_UpdateOrder($answer['order_id']);
        }
    }
    if (isset($error)) {
        ?>
<div class="wrap">
<h2><?php 
        _e('qTranslate Services', 'qtranslate');
        ?>
</h2>
<div id="message" class="error fade"><p><?php 
        echo $error;
        ?>
</p></div>
<p><?php 
        printf(__('An serious error occured and qTranslate Services cannot proceed. For help, please visit the <a href="%s">Support Forum</a>', 'qtranslate'), 'http://www.qianqin.de/qtranslate/forum/');
        ?>
</p>
</div>
<?php 
        return;
    }
    if (isset($order_completed_message)) {
        ?>
<div class="wrap">
<h2><?php 
        _e('qTranslate Services', 'qtranslate');
        ?>
</h2>
<div id="message" class="updated fade"><p><?php 
        _e('Order successfully sent.', 'qtranslate');
        ?>
</p></div>
<p><?php 
        _e('Your translation order has been successfully transfered to the selected service.', 'qtranslate');
        ?>
</p>
<?php 
        if (!empty($order_completed_message)) {
            ?>
<p><?php 
            printf(__('The service returned this message: %s', 'qtranslate'), $order_completed_message);
            ?>
</p>
<?php 
        }
        ?>
<p><?php 
        _e('Feel free to choose an action:', 'qtranslate');
        ?>
</p>
<ul>
	<li><a href="<?php 
        echo add_query_arg('target_language', null, $url_link);
        ?>
"><?php 
        _e('Translate this post to another language.', 'qtranslate');
        ?>
</a></li>
	<li><a href="edit.php"><?php 
        _e('Translate a different post.', 'qtranslate');
        ?>
</a></li>
	<li><a href="options-general.php?page=qtranslate#qtranslate_service_settings"><?php 
        _e('View all open orders.', 'qtranslate');
        ?>
</a></li>
	<li><a href="options-general.php?page=qtranslate&qs_cron=true#qtranslate_service_settings"><?php 
        _e('Let qTranslate Services check if any open orders are finished.', 'qtranslate');
        ?>
</a></li>
	<li><a href="<?php 
        echo get_permalink($post_id);
        ?>
 "><?php 
        _e('View this post.', 'qtranslate');
        ?>
</a></li>
</ul>
</div>
<?php 
        return;
    }
    ?>
<div class="wrap">
<h2><?php 
    _e('qTranslate Services', 'qtranslate');
    ?>
</h2>
<?php 
    if (!empty($message)) {
        ?>
<div id="message" class="updated fade"><p><?php 
        echo $message;
        ?>
</p></div>
<?php 
    }
    ?>
<h3><?php 
    echo $title;
    ?>
</h3>
<form action="edit.php?page=qtranslate_services" method="post" id="qtranslate-services-translate">
<p><?php 
    if (sizeof($available_languages) > 1) {
        $available_languages_name = array();
        foreach (array_diff($available_languages, array($translate_from)) as $language) {
            $available_languages_name[] = '<a href="' . add_query_arg('source_language', $language, $url_link) . '">' . $q_config['language_name'][$language] . '</a>';
        }
        $available_languages_names = join(", ", $available_languages_name);
        printf(__('Your article is available in multiple languages. If you do not want to translate from %1$s, you can switch to one of the following languages: %2$s', 'qtranslate'), $q_config['language_name'][$translate_from], $available_languages_names);
    }
    ?>
</p>
<input type="hidden" name="post" value="<?php 
    echo $post_id;
    ?>
"/>
<input type="hidden" name="source_language" value="<?php 
    echo $translate_from;
    ?>
"/>
<?php 
    if (empty($translate_to)) {
        ?>
<p><?php 
        _e('Please choose the language you want to translate to:', 'qtranslate');
        ?>
</p>
<ul>
<?php 
        foreach ($q_config['enabled_languages'] as $language) {
            if ($translate_from == $language) {
                continue;
            }
            ?>
	<li><label><input type="radio" name="target_language" value="<?php 
            echo $language;
            ?>
" /> <?php 
            echo $q_config['language_name'][$language];
            ?>
</li>
<?php 
        }
        ?>
</ul>
	<p class="submit">
		<input type="submit" name="submit" class="button-primary" value="<?php 
        _e('Continue', 'qtranslate');
        ?>
" />
	</p>
<?php 
    } else {
        ?>
<p><?php 
        printf(__('Please review your article and <a href="%s">edit</a> it if needed.', 'qtranslate'), 'post.php?action=edit&post=' . $post_id);
        ?>
</p>
<textarea name="qs_content_preview" id="qs_content_preview" readonly="readonly"><?php 
        echo $post_content;
        ?>
</textarea>
<?php 
        $timestamp = time();
        if ($timestamp != qs_queryQS(QS_VERIFY, $timestamp)) {
            ?>
<p class="error"><?php 
            _e('ERROR: Could not connect to qTranslate Services. Please try again later.', 'qtranslate');
            ?>
</p>
<?php 
            return;
        }
        ?>
<h4><?php 
        _e('Use the following Translation Service:', 'qtranslate');
        ?>
</h4>
<ul>
<?php 
        if ($services = qs_queryQS(QS_GET_SERVICES)) {
            foreach ($services as $service_id => $service) {
                // check if we have data for all required fields
                $requirements_matched = true;
                foreach ($service['service_required_fields'] as $field) {
                    if (!isset($service_settings[$service_id][$field['name']]) || $service_settings[$service_id][$field['name']] == '') {
                        $requirements_matched = false;
                    }
                }
                if (!$requirements_matched) {
                    ?>
<li>
	<label><input type="radio" name="service_id" disabled="disabled" /> <b><?php 
                    echo qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($service['service_name']);
                    ?>
</b> ( <a href="<?php 
                    echo $service['service_url'];
                    ?>
" target="_blank"><?php 
                    _e('Website', 'qtranslate');
                    ?>
</a> )</label>
	<p class="error"><?php 
                    printf(__('Cannot use this service, not all <a href="%s">required fields</a> filled in for this service.', 'qtranslate'), 'options-general.php?page=qtranslate#qs_service_' . $service_id);
                    ?>
</p>
	<p class="service_description"><?php 
                    echo qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($service['service_description']);
                    ?>
</p>
</li>
<?php 
                } else {
                    ?>
<li><label><input type="radio" name="service_id" <?php 
                    if ($default_service == $service['service_id']) {
                        echo 'checked="checked"';
                    }
                    ?>
 value="<?php 
                    echo $service['service_id'];
                    ?>
" /> <b><?php 
                    echo qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($service['service_name']);
                    ?>
</b> ( <a href="<?php 
                    echo $service['service_url'];
                    ?>
" target="_blank"><?php 
                    _e('Website', 'qtranslate');
                    ?>
</a> )</label><p class="service_description"><?php 
                    echo qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($service['service_description']);
                    ?>
</p></li>
<?php 
                }
            }
            ?>
</ul>
<p><?php 
            _e('Your article will be SSL encrypted and securly sent to qTranslate Services, which will forward your text to the chosen Translation Service. Once qTranslate Services receives the translated text, it will automatically appear on your blog.', 'qtranslate');
            ?>
</p>
	<p class="submit">
		<input type="hidden" name="target_language" value="<?php 
            echo $translate_to;
            ?>
"/>
		<input type="submit" name="submit" class="button-primary" value="<?php 
            _e('Request Translation', 'qtranslate');
            ?>
" />
	</p>
<?php 
        }
    }
    ?>
</div>
</form>
<?php 
}
コード例 #5
0
function qtrans_use($lang, $text, $show_available = false)
{
    global $q_config;
    // return full string if language is not enabled
    if (!qtrans_isEnabled($lang)) {
        return $text;
    }
    if (is_array($text)) {
        // handle arrays recursively
        foreach ($text as $key => $t) {
            $text[$key] = qtrans_use($lang, $text[$key], $show_available);
        }
        return $text;
    }
    if (is_object($text) || @get_class($text) == '__PHP_Incomplete_Class') {
        foreach (get_object_vars($text) as $key => $t) {
            $text->{$key} = qtrans_use($lang, $text->{$key}, $show_available);
        }
        return $text;
    }
    // prevent filtering weird data types and save some resources
    if (!is_string($text) || $text == '') {
        return $text;
    }
    // get content
    $content = qtrans_split($text);
    // find available languages
    $available_languages = array();
    foreach ($content as $language => $lang_text) {
        $lang_text = trim($lang_text);
        if (!empty($lang_text)) {
            $available_languages[] = $language;
        }
    }
    // if no languages available show full text
    if (sizeof($available_languages) == 0) {
        return $text;
    }
    // if content is available show the content in the requested language
    if (!empty($content[$lang])) {
        return $content[$lang];
    }
    // content not available in requested language (bad!!) what now?
    if (!$show_available) {
        // check if content is available in default language, if not return first language found. (prevent empty result)
        if ($lang != $q_config['default_language']) {
            return "(" . $q_config['language_name'][$q_config['default_language']] . ") " . qtrans_use($q_config['default_language'], $text, $show_available);
        }
        foreach ($content as $language => $lang_text) {
            $lang_text = trim($lang_text);
            if (!empty($lang_text)) {
                return "(" . $q_config['language_name'][$language] . ") " . $lang_text;
            }
        }
    }
    // display selection for available languages
    $available_languages = array_unique($available_languages);
    $language_list = "";
    if (preg_match('/%LANG:([^:]*):([^%]*)%/', $q_config['not_available'][$lang], $match)) {
        $normal_seperator = $match[1];
        $end_seperator = $match[2];
        // build available languages string backward
        $i = 0;
        foreach ($available_languages as $language) {
            if ($i == 1) {
                $language_list = $end_seperator . $language_list;
            }
            if ($i > 1) {
                $language_list = $normal_seperator . $language_list;
            }
            $language_list = "<a href=\"" . qtrans_convertURL('', $language) . "\">" . $q_config['language_name'][$language] . "</a>" . $language_list;
            $i++;
        }
    }
    return "<p>" . preg_replace('/%LANG:([^:]*):([^%]*)%/', $language_list, $q_config['not_available'][$lang]) . "</p>";
}
コード例 #6
0
function qtranslate_conf()
{
    global $q_config, $wpdb;
    // do redirection for dashboard
    if (isset($_GET['godashboard'])) {
        echo '<h2>' . __('Switching Language', 'qtranslate') . '</h2>' . sprintf(__('Switching language to %1$s... If the Dashboard isn\'t loading, use this <a href="%2$s" title="Dashboard">link</a>.', 'qtranslate'), $q_config['language_name'][qtrans_getLanguage()], admin_url()) . '<script type="text/javascript">document.location="' . admin_url() . '";</script>';
        exit;
    }
    // init some needed variables
    $error = '';
    $original_lang = '';
    $language_code = '';
    $language_name = '';
    $language_locale = '';
    $language_date_format = '';
    $language_time_format = '';
    $language_na_message = '';
    $language_flag = '';
    $language_default = '';
    $altered_table = false;
    $message = apply_filters('qtranslate_configuration_pre', '');
    // check for action
    if (isset($_POST['qtranslate_reset']) && isset($_POST['qtranslate_reset2'])) {
        $message = __('qTranslate has been reset.', 'qtranslate');
    } elseif (isset($_POST['default_language'])) {
        // save settings
        qtrans_checkSetting('default_language', true, QT_LANGUAGE);
        qtrans_checkSetting('flag_location', true, QT_URL);
        qtrans_checkSetting('ignore_file_types', true, QT_STRING);
        qtrans_checkSetting('detect_browser_language', true, QT_BOOLEAN);
        qtrans_checkSetting('hide_untranslated', true, QT_INTEGER);
        qtrans_checkSetting('use_strftime', true, QT_INTEGER);
        qtrans_checkSetting('url_mode', true, QT_INTEGER);
        qtrans_checkSetting('auto_update_mo', true, QT_BOOLEAN);
        qtrans_checkSetting('hide_default_language', true, QT_BOOLEAN);
        if (isset($_POST['update_mo_now']) && $_POST['update_mo_now'] == '1' && qtrans_updateGettextDatabases(true)) {
            $message = __('Gettext databases updated.', 'qtranslate');
        }
    }
    if (isset($_POST['original_lang'])) {
        // validate form input
        if ($_POST['language_na_message'] == '') {
            $error = __('The Language must have a Not-Available Message!', 'qtranslate');
        }
        if (strlen($_POST['language_locale']) < 2) {
            $error = __('The Language must have a Locale!', 'qtranslate');
        }
        if ($_POST['language_name'] == '') {
            $error = __('The Language must have a name!', 'qtranslate');
        }
        if (strlen($_POST['language_code']) != 2) {
            $error = __('Language Code has to be 2 characters long!', 'qtranslate');
        }
        if ($_POST['original_lang'] == '' && $error == '') {
            // new language
            if (isset($q_config['language_name'][$_POST['language_code']])) {
                $error = __('There is already a language with the same Language Code!', 'qtranslate');
            }
        }
        if ($_POST['original_lang'] != '' && $error == '') {
            // language update
            if ($_POST['language_code'] != $_POST['original_lang'] && isset($q_config['language_name'][$_POST['language_code']])) {
                $error = __('There is already a language with the same Language Code!', 'qtranslate');
            } else {
                // remove old language
                unset($q_config['language_name'][$_POST['original_lang']]);
                unset($q_config['flag'][$_POST['original_lang']]);
                unset($q_config['locale'][$_POST['original_lang']]);
                unset($q_config['date_format'][$_POST['original_lang']]);
                unset($q_config['time_format'][$_POST['original_lang']]);
                unset($q_config['not_available'][$_POST['original_lang']]);
                if (in_array($_POST['original_lang'], $q_config['enabled_languages'])) {
                    // was enabled, so set modified one to enabled too
                    for ($i = 0; $i < sizeof($q_config['enabled_languages']); $i++) {
                        if ($q_config['enabled_languages'][$i] == $_POST['original_lang']) {
                            $q_config['enabled_languages'][$i] = $_POST['language_code'];
                        }
                    }
                }
                if ($_POST['original_lang'] == $q_config['default_language']) {
                    // was default, so set modified the default
                    $q_config['default_language'] = $_POST['language_code'];
                }
            }
        }
        if (get_magic_quotes_gpc()) {
            if (isset($_POST['language_date_format'])) {
                $_POST['language_date_format'] = stripslashes($_POST['language_date_format']);
            }
            if (isset($_POST['language_time_format'])) {
                $_POST['language_time_format'] = stripslashes($_POST['language_time_format']);
            }
        }
        if ($error == '') {
            // everything is fine, insert language
            $q_config['language_name'][$_POST['language_code']] = $_POST['language_name'];
            $q_config['flag'][$_POST['language_code']] = $_POST['language_flag'];
            $q_config['locale'][$_POST['language_code']] = $_POST['language_locale'];
            $q_config['date_format'][$_POST['language_code']] = $_POST['language_date_format'];
            $q_config['time_format'][$_POST['language_code']] = $_POST['language_time_format'];
            $q_config['not_available'][$_POST['language_code']] = $_POST['language_na_message'];
        }
        if ($error != '' || isset($_GET['edit'])) {
            // get old values in the form
            $original_lang = $_POST['original_lang'];
            $language_code = $_POST['language_code'];
            $language_name = $_POST['language_name'];
            $language_locale = $_POST['language_locale'];
            $language_date_format = $_POST['language_date_format'];
            $language_time_format = $_POST['language_time_format'];
            $language_na_message = $_POST['language_na_message'];
            $language_flag = $_POST['language_flag'];
            $language_default = $_POST['language_default'];
        }
    } elseif (isset($_GET['convert'])) {
        // update language tags
        global $wpdb;
        $wpdb->show_errors();
        foreach ($q_config['enabled_languages'] as $lang) {
            $wpdb->query('UPDATE ' . $wpdb->posts . ' set post_title = REPLACE(post_title, "[lang_' . $lang . ']","<!--:' . $lang . '-->")');
            $wpdb->query('UPDATE ' . $wpdb->posts . ' set post_title = REPLACE(post_title, "[/lang_' . $lang . ']","<!--:-->")');
            $wpdb->query('UPDATE ' . $wpdb->posts . ' set post_content = REPLACE(post_content, "[lang_' . $lang . ']","<!--:' . $lang . '-->")');
            $wpdb->query('UPDATE ' . $wpdb->posts . ' set post_content = REPLACE(post_content, "[/lang_' . $lang . ']","<!--:-->")');
        }
        $message = "Database Update successful!";
    } elseif (isset($_GET['markdefault'])) {
        // update language tags
        global $wpdb;
        $wpdb->show_errors();
        $result = $wpdb->get_results('SELECT ID, post_title, post_content FROM ' . $wpdb->posts . ' WHERE NOT (post_content LIKE "%<!--:-->%" OR post_title LIKE "%<!--:-->%")');
        foreach ($result as $post) {
            $content = qtrans_split($post->post_content);
            $title = qtrans_split($post->post_title);
            foreach ($q_config['enabled_languages'] as $language) {
                if ($language != $q_config['default_language']) {
                    $content[$language] = "";
                    $title[$language] = "";
                }
            }
            $content = qtrans_join($content);
            $title = qtrans_join($title);
            $wpdb->query('UPDATE ' . $wpdb->posts . ' set post_content = "' . mysql_escape_string($content) . '", post_title = "' . mysql_escape_string($title) . '" WHERE ID=' . $post->ID);
        }
        $message = "All Posts marked as default language!";
    } elseif (isset($_GET['edit'])) {
        $original_lang = $_GET['edit'];
        $language_code = $_GET['edit'];
        $language_name = $q_config['language_name'][$_GET['edit']];
        $language_locale = $q_config['locale'][$_GET['edit']];
        $language_date_format = $q_config['date_format'][$_GET['edit']];
        $language_time_format = $q_config['time_format'][$_GET['edit']];
        $language_na_message = $q_config['not_available'][$_GET['edit']];
        $language_flag = $q_config['flag'][$_GET['edit']];
    } elseif (isset($_GET['delete'])) {
        // validate delete (protect code)
        if ($q_config['default_language'] == $_GET['delete']) {
            $error = 'Cannot delete Default Language!';
        }
        if (!isset($q_config['language_name'][$_GET['delete']]) || strtolower($_GET['delete']) == 'code') {
            $error = 'No such language!';
        }
        if ($error == '') {
            // everything seems fine, delete language
            qtrans_disableLanguage($_GET['delete']);
            unset($q_config['language_name'][$_GET['delete']]);
            unset($q_config['flag'][$_GET['delete']]);
            unset($q_config['locale'][$_GET['delete']]);
            unset($q_config['date_format'][$_GET['delete']]);
            unset($q_config['time_format'][$_GET['delete']]);
            unset($q_config['not_available'][$_GET['delete']]);
        }
    } elseif (isset($_GET['enable'])) {
        // enable validate
        if (!qtrans_enableLanguage($_GET['enable'])) {
            $error = __('Language is already enabled or invalid!', 'qtranslate');
        }
    } elseif (isset($_GET['disable'])) {
        // enable validate
        if ($_GET['disable'] == $q_config['default_language']) {
            $error = __('Cannot disable Default Language!', 'qtranslate');
        }
        if (!qtrans_isEnabled($_GET['disable'])) {
            if (!isset($q_config['language_name'][$_GET['disable']])) {
                $error = __('No such language!', 'qtranslate');
            }
        }
        // everything seems fine, disable language
        if ($error == '' && !qtrans_disableLanguage($_GET['disable'])) {
            $error = __('Language is already disabled!', 'qtranslate');
        }
    } elseif (isset($_GET['moveup'])) {
        $languages = qtrans_getSortedLanguages();
        $message = __('No such language!', 'qtranslate');
        foreach ($languages as $key => $language) {
            if ($language == $_GET['moveup']) {
                if ($key == 0) {
                    $message = __('Language is already first!', 'qtranslate');
                    break;
                }
                $languages[$key] = $languages[$key - 1];
                $languages[$key - 1] = $language;
                $q_config['enabled_languages'] = $languages;
                $message = __('New order saved.', 'qtranslate');
                break;
            }
        }
    } elseif (isset($_GET['movedown'])) {
        $languages = qtrans_getSortedLanguages();
        $message = __('No such language!', 'qtranslate');
        foreach ($languages as $key => $language) {
            if ($language == $_GET['movedown']) {
                if ($key == sizeof($languages) - 1) {
                    $message = __('Language is already last!', 'qtranslate');
                    break;
                }
                $languages[$key] = $languages[$key + 1];
                $languages[$key + 1] = $language;
                $q_config['enabled_languages'] = $languages;
                $message = __('New order saved.', 'qtranslate');
                break;
            }
        }
    }
    $everything_fine = (isset($_POST['submit']) || isset($_GET['delete']) || isset($_GET['enable']) || isset($_GET['disable']) || isset($_GET['moveup']) || isset($_GET['movedown'])) && $error == '';
    if ($everything_fine) {
        // settings might have changed, so save
        qtrans_saveConfig();
        if (empty($message)) {
            $message = __('Options saved.', 'qtranslate');
        }
    }
    if ($q_config['auto_update_mo']) {
        if (!is_dir(WP_LANG_DIR) || !($ll = @fopen(trailingslashit(WP_LANG_DIR) . 'qtranslate.test', 'a'))) {
            $error = sprintf(__('Could not write to "%s", Gettext Databases could not be downloaded!', 'qtranslate'), WP_LANG_DIR);
        } else {
            @fclose($ll);
            @unlink(trailingslashit(WP_LANG_DIR) . 'qtranslate.test');
        }
    }
    // don't accidently delete/enable/disable twice
    $clean_uri = preg_replace("/&(delete|enable|disable|convert|markdefault|moveup|movedown)=[^&#]*/i", "", $_SERVER['REQUEST_URI']);
    $clean_uri = apply_filters('qtranslate_clean_uri', $clean_uri);
    // Generate XHTML
    if ($message) {
        ?>
<div id="message" class="updated fade"><p><strong><?php 
        echo $message;
        ?>
</strong></p></div>
<?php 
    }
    if ($error != '') {
        ?>
<div id="message" class="error fade"><p><strong><?php 
        echo $error;
        ?>
</strong></p></div>
<?php 
    }
    ?>

<?php 
    if (isset($_GET['edit'])) {
        ?>
<div class="wrap">
<h2><?php 
        _e('Edit Language', 'qtranslate');
        ?>
</h2>
<form action="" method="post" id="qtranslate-edit-language">
<?php 
        qtranslate_language_form($language_code, $language_code, $language_name, $language_locale, $language_date_format, $language_time_format, $language_flag, $language_na_message, $language_default, $original_lang);
        ?>
<p class="submit"><input type="submit" name="submit" value="<?php 
        _e('Save Changes &raquo;', 'qtranslate');
        ?>
" /></p>
</form>
</div>
<?php 
    } else {
        ?>
<div class="wrap">
<h2><?php 
        _e('Language Management (qTranslate Configuration)', 'qtranslate');
        ?>
</h2> 
<div class="tablenav"><?php 
        printf(__('For help on how to configure qTranslate correctly, take a look at the <a href="%1$s">qTranslate FAQ</a> and the <a href="%2$s">Support Forum</a>.', 'qtranslate'), 'http://www.qianqin.de/qtranslate/faq/', 'http://www.qianqin.de/qtranslate/forum/viewforum.php?f=3');
        ?>
</div>
	<form action="<?php 
        echo $clean_uri;
        ?>
" method="post">
		<h3><?php 
        _e('General Settings', 'qtranslate');
        ?>
</h3>
		<table class="form-table">
			<tr>
				<th scope="row"><?php 
        _e('Default Language / Order', 'qtranslate');
        ?>
</th>
				<td>
					<fieldset><legend class="hidden"><?php 
        _e('Default Language', 'qtranslate');
        ?>
</legend>
				<?php 
        foreach (qtrans_getSortedLanguages() as $key => $language) {
            echo "\t<label title='" . $q_config['language_name'][$language] . "'><input type='radio' name='default_language' value='" . $language . "'";
            if ($language == $q_config['default_language']) {
                echo " checked='checked'";
            }
            echo ' />';
            echo ' <a href="' . add_query_arg('moveup', $language, $clean_uri) . '"><img src="' . WP_PLUGIN_URL . '/' . basename(__DIR__) . '/arrowup.png" alt="up" /></a>';
            echo ' <a href="' . add_query_arg('movedown', $language, $clean_uri) . '"><img src="' . WP_PLUGIN_URL . '/' . basename(__DIR__) . '/arrowdown.png" alt="down" /></a>';
            echo ' <img src="' . trailingslashit(WP_CONTENT_URL) . $q_config['flag_location'] . $q_config['flag'][$language] . '" alt="' . $q_config['language_name'][$language] . '" /> ';
            echo ' ' . $q_config['language_name'][$language] . "</label><br />\n";
        }
        ?>
					</br>
					<?php 
        printf(__('Choose the default language of your blog. This is the language which will be shown on %s. You can also change the order the languages by clicking on the arrows above.', 'qtranslate'), get_bloginfo('url'));
        ?>
					</fieldset>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Untranslated Content', 'qtranslate');
        ?>
</th>
				<td>
					<fieldset><legend class="hidden"><?php 
        _e('URL Modification Mode', 'qtranslate');
        ?>
</legend>
						<label title="Hide untranslated"><input type="radio" name="hide_untranslated" value="<?php 
        echo QT_UNTRANSLATED_HIDE;
        ?>
" <?php 
        echo $q_config['hide_untranslated'] == QT_UNTRANSLATED_HIDE ? "checked=\"checked\"" : "";
        ?>
 /> <?php 
        _e('Hide Content which is not available for the selected language.', 'qtranslate');
        ?>
</label><br />
						<label title="Show messages"><input type="radio" name="hide_untranslated" value="<?php 
        echo QT_UNTRANSLATED_MESSAGE;
        ?>
" <?php 
        echo $q_config['hide_untranslated'] == QT_UNTRANSLATED_MESSAGE ? "checked=\"checked\"" : "";
        ?>
 /> <?php 
        _e('Display a message showing all the languages the content is available in.', 'qtranslate');
        ?>
</label><br />
						<label title="Show default language"><input type="radio" name="hide_untranslated" value="<?php 
        echo QT_UNTRANSLATED_DEFAULT;
        ?>
" <?php 
        echo $q_config['hide_untranslated'] == QT_UNTRANSLATED_DEFAULT ? "checked=\"checked\"" : "";
        ?>
 /> <?php 
        _e('Display the content in default language (or the first available language)', 'qtranslate');
        ?>
</label><br />
					</fieldset><br/>
					<?php 
        _e('This function will not work correctly if you installed qTranslate on a blog with existing entries. In this case you will need to take a look at "Convert Database" under "Advanced Settings".', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Detect Browser Language', 'qtranslate');
        ?>
</th>
				<td>
					<label for="detect_browser_language"><input type="checkbox" name="detect_browser_language" id="detect_browser_language" value="1"<?php 
        echo $q_config['detect_browser_language'] ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Detect the language of the browser and redirect accordingly.', 'qtranslate');
        ?>
</label>
					<br/>
					<?php 
        _e('When the frontpage is visited via bookmark/external link/type-in, the visitor will be forwarded to the correct URL for the language specified by his browser.', 'qtranslate');
        ?>
				</td>
			</tr>
		</table>
		<h3><?php 
        _e('Advanced Settings', 'qtranslate');
        ?>
<span id="qtranslate-show-advanced" style="display:none"> (<a name="advanced_settings" href="#advanced_settings" onclick="showAdvanced();"><?php 
        _e('Show', 'qtranslate');
        ?>
</a>)</span></h3>
		<table class="form-table" id="qtranslate-advanced">
			<tr>
				<th scope="row"><?php 
        _e('URL Modification Mode', 'qtranslate');
        ?>
</th>
				<td>
					<fieldset><legend class="hidden"><?php 
        _e('URL Modification Mode', 'qtranslate');
        ?>
</legend>
						<label title="Query Mode"><input type="radio" name="url_mode" value="<?php 
        echo QT_URL_QUERY;
        ?>
" <?php 
        echo $q_config['url_mode'] == QT_URL_QUERY ? "checked=\"checked\"" : "";
        ?>
 /> <?php 
        _e('Use Query Mode (?lang=en)', 'qtranslate');
        ?>
</label><br />
						<label title="Pre-Path Mode"><input type="radio" name="url_mode" value="<?php 
        echo QT_URL_PATH;
        ?>
" <?php 
        echo $q_config['url_mode'] == QT_URL_PATH ? "checked=\"checked\"" : "";
        ?>
 /> <?php 
        _e('Use Pre-Path Mode (Default, puts /en/ in front of URL)', 'qtranslate');
        ?>
</label><br />
						<label title="Pre-Domain Mode"><input type="radio" name="url_mode" value="<?php 
        echo QT_URL_DOMAIN;
        ?>
" <?php 
        echo $q_config['url_mode'] == QT_URL_DOMAIN ? "checked=\"checked\"" : "";
        ?>
 /> <?php 
        _e('Use Pre-Domain Mode (uses http://en.yoursite.com)', 'qtranslate');
        ?>
</label><br />
					</fieldset><br/>
					<?php 
        _e('Pre-Path and Pre-Domain mode will only work with mod_rewrite/pretty permalinks. Additional Configuration is needed for Pre-Domain mode!', 'qtranslate');
        ?>
<br/>
					<label for="hide_default_language"><input type="checkbox" name="hide_default_language" id="hide_default_language" value="1"<?php 
        echo $q_config['hide_default_language'] ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Hide URL language information for default language.', 'qtranslate');
        ?>
</label>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Flag Image Path', 'qtranslate');
        ?>
</th>
				<td>
					<?php 
        echo trailingslashit(WP_CONTENT_URL);
        ?>
<input type="text" name="flag_location" id="flag_location" value="<?php 
        echo $q_config['flag_location'];
        ?>
" style="width:50%"/>
					<br/>
					<?php 
        _e('Path to the flag images under wp-content, with trailing slash. (Default: plugins/qtranslate/flags/)', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Ignore Links', 'qtranslate');
        ?>
</th>
				<td>
					<input type="text" name="ignore_file_types" id="ignore_file_types" value="<?php 
        echo $q_config['ignore_file_types'];
        ?>
" style="width:100%"/>
					<br/>
					<?php 
        _e('Don\'t convert Links to files of the given file types. (Default: gif,jpg,jpeg,png,pdf,swf,tif,rar,zip,7z,mpg,divx,mpeg,avi,css,js)', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Update Gettext Databases', 'qtranslate');
        ?>
</th>
				<td>
					<label for="auto_update_mo"><input type="checkbox" name="auto_update_mo" id="auto_update_mo" value="1"<?php 
        echo $q_config['auto_update_mo'] ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Automatically check for .mo-Database Updates of installed languages.', 'qtranslate');
        ?>
</label>
					<br/>
					<label for="update_mo_now"><input type="checkbox" name="update_mo_now" id="update_mo_now" value="1" /> <?php 
        _e('Update Gettext databases now.', 'qtranslate');
        ?>
</label>
					<br/>
					<?php 
        _e('qTranslate will query the Wordpress Localisation Repository every week and download the latest Gettext Databases (.mo Files).', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Date / Time Conversion', 'qtranslate');
        ?>
</th>
				<td>
					<label><input type="radio" name="use_strftime" value="<?php 
        echo QT_DATE;
        ?>
" <?php 
        echo $q_config['use_strftime'] == QT_DATE ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Use emulated date function.', 'qtranslate');
        ?>
</label><br />
					<label><input type="radio" name="use_strftime" value="<?php 
        echo QT_DATE_OVERRIDE;
        ?>
" <?php 
        echo $q_config['use_strftime'] == QT_DATE_OVERRIDE ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Use emulated date function and replace formats with the predefined formats for each language.', 'qtranslate');
        ?>
</label><br />
					<label><input type="radio" name="use_strftime" value="<?php 
        echo QT_STRFTIME;
        ?>
" <?php 
        echo $q_config['use_strftime'] == QT_STRFTIME ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Use strftime instead of date.', 'qtranslate');
        ?>
</label><br />
					<label><input type="radio" name="use_strftime" value="<?php 
        echo QT_STRFTIME_OVERRIDE;
        ?>
" <?php 
        echo $q_config['use_strftime'] == QT_STRFTIME_OVERRIDE ? ' checked="checked"' : '';
        ?>
/> <?php 
        _e('Use strftime instead of date and replace formats with the predefined formats for each language.', 'qtranslate');
        ?>
</label><br />
					<?php 
        _e('Depending on the mode selected, additional customizations of the theme may be needed.', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
        _e('Reset qTranslate', 'qtranslate');
        ?>
</th>
				<td>
					<label for="qtranslate_reset"><input type="checkbox" name="qtranslate_reset" id="qtranslate_reset" value="1"/> <?php 
        _e('Check this box and click Save Changes to reset all qTranslate settings.', 'qtranslate');
        ?>
</label>
					<br/>
					<label for="qtranslate_reset2"><input type="checkbox" name="qtranslate_reset2" id="qtranslate_reset2" value="1"/> <?php 
        _e('Yes, I really want to reset qTranslate.', 'qtranslate');
        ?>
</label>
					<br/>
					<label for="qtranslate_reset3"><input type="checkbox" name="qtranslate_reset3" id="qtranslate_reset3" value="1"/> <?php 
        _e('Also delete Translations for Categories/Tags/Link Categories.', 'qtranslate');
        ?>
</label>
					<br/>
					<?php 
        _e('If something isn\'t working correctly, you can always try to reset all qTranslate settings. A Reset won\'t delete any posts but will remove all settings (including all languages added).', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr>
				<th scope="row"><?php 
        _e('Convert Database', 'qtranslate');
        ?>
</th>
				<td>
					<?php 
        printf(__('If you are updating from qTranslate 1.x or Polyglot, <a href="%s">click here</a> to convert posts to the new language tag format.', 'qtranslate'), $clean_uri . '&convert=true');
        ?>
					<?php 
        printf(__('If you have installed qTranslate for the first time on a Wordpress with existing posts, you can either go through all your posts manually and save them in the correct language or <a href="%s">click here</a> to mark all existing posts as written in the default language.', 'qtranslate'), $clean_uri . '&markdefault=true');
        ?>
					<?php 
        _e('Both processes are <b>irreversible</b>! Be sure to make a full database backup before clicking one of the links.', 'qtranslate');
        ?>
				</td>
			</tr>
			<tr>
				<th scope="row"><?php 
        _e('Debugging Information', 'qtranslate');
        ?>
</th>
				<td>
					<p><?php 
        printf(__('If you encounter any problems and you are unable to solve them yourself, you can visit the <a href="%s">Support Forum</a>. Posting the following Content will help other detect any misconfigurations.', 'qtranslate'), 'http://www.qianqin.de/qtranslate/forum/');
        ?>
</p>
					<textarea readonly="readonly" id="qtranslate_debug"><?php 
        $q_config_copy = $q_config;
        // remove information to keep data anonymous and other not needed things
        unset($q_config_copy['url_info']);
        unset($q_config_copy['js']);
        unset($q_config_copy['windows_locale']);
        unset($q_config_copy['pre_domain']);
        unset($q_config_copy['term_name']);
        echo htmlspecialchars(print_r($q_config_copy, true));
        ?>
</textarea>
				</td>
			</tr>
		</table>
		<script type="text/javascript">
		// <![CDATA[
			function showAdvanced() {
				document.getElementById('qtranslate-advanced').style.display='block';
				document.getElementById('qtranslate-show-advanced').style.display='none';
				return false;
			}
			
			if(location.hash!='#advanced_settings') {
					document.getElementById('qtranslate-show-advanced').style.display='inline';
					document.getElementById('qtranslate-advanced').style.display='none';
			}
		// ]]>
		</script>
<?php 
        do_action('qtranslate_configuration', $clean_uri);
        ?>
		<p class="submit">
			<input type="submit" name="submit" class="button-primary" value="<?php 
        _e('Save Changes', 'qtranslate');
        ?>
" />
		</p>
	</form>

</div>
<div class="wrap">

<h2><?php 
        _e('Languages', 'qtranslate');
        ?>
</h2>
<div id="col-container">

<div id="col-right">
<div class="col-wrap">

<table class="widefat">
	<thead>
	<tr>
<?php 
        print_column_headers('language');
        ?>
	</tr>
	</thead>

	<tfoot>
	<tr>
<?php 
        print_column_headers('language', false);
        ?>
	</tr>
	</tfoot>

	<tbody id="the-list" class="list:cat">
<?php 
        foreach ($q_config['language_name'] as $lang => $language) {
            if ($lang != 'code') {
                ?>
	<tr>
		<td><img src="<?php 
                echo trailingslashit(WP_CONTENT_URL) . $q_config['flag_location'] . $q_config['flag'][$lang];
                ?>
" alt="<?php 
                echo $language;
                ?>
 Flag"></td>
		<td><?php 
                echo $language;
                ?>
</td>
		<td><?php 
                if (in_array($lang, $q_config['enabled_languages'])) {
                    ?>
<a class="edit" href="<?php 
                    echo $clean_uri;
                    ?>
&disable=<?php 
                    echo $lang;
                    ?>
"><?php 
                    _e('Disable', 'qtranslate');
                    ?>
</a><?php 
                } else {
                    ?>
<a class="edit" href="<?php 
                    echo $clean_uri;
                    ?>
&enable=<?php 
                    echo $lang;
                    ?>
"><?php 
                    _e('Enable', 'qtranslate');
                    ?>
</a><?php 
                }
                ?>
</td>
		<td><a class="edit" href="<?php 
                echo $clean_uri;
                ?>
&edit=<?php 
                echo $lang;
                ?>
"><?php 
                _e('Edit', 'qtranslate');
                ?>
</a></td>
		<td><?php 
                if ($q_config['default_language'] == $lang) {
                    _e('Default', 'qtranslate');
                } else {
                    ?>
<a class="delete" href="<?php 
                    echo $clean_uri;
                    ?>
&delete=<?php 
                    echo $lang;
                    ?>
"><?php 
                    _e('Delete', 'qtranslate');
                    ?>
</a><?php 
                }
                ?>
</td>
	</tr>
<?php 
            }
        }
        ?>
	</tbody>
</table>
<p><?php 
        _e('Enabling a language will cause qTranslate to update the Gettext-Database for the language, which can take a while depending on your server\'s connection speed.', 'qtranslate');
        ?>
</p>
</div>
</div><!-- /col-right -->

<div id="col-left">
<div class="col-wrap">
<div class="form-wrap">
<h3><?php 
        _e('Add Language', 'qtranslate');
        ?>
</h3>
<form name="addcat" id="addcat" method="post" class="add:the-list: validate">
<?php 
        qtranslate_language_form($language_code, $language_code, $language_name, $language_locale, $language_date_format, $language_time_format, $language_flag, $language_default, $language_na_message);
        ?>
<p class="submit"><input type="submit" name="submit" value="<?php 
        _e('Add Language &raquo;', 'qtranslate');
        ?>
" /></p>
</form></div>
</div>
</div><!-- /col-left -->

</div><!-- /col-container -->
<?php 
    }
}
コード例 #7
0
ファイル: mqtranslate_core.php プロジェクト: Roman921/Step-21
function qtrans_use($lang, $text, $show_available = false)
{
    global $q_config;
    // return full string if language is not enabled
    if (!qtrans_isEnabled($lang) || is_string($text) && !preg_match('/(<!--:[a-z]{2}-->|\\[:[a-z]{2}\\])/', $text)) {
        return $text;
    }
    if (is_array($text)) {
        // handle arrays recursively
        foreach ($text as &$t) {
            $t = qtrans_use($lang, $t, $show_available);
        }
        return $text;
    }
    if (is_object($text) || $text instanceof __PHP_Incomplete_Class) {
        foreach ($text as &$t) {
            $t = qtrans_use($lang, $t, $show_available);
        }
        return $text;
    }
    // prevent filtering weird data types and save some resources
    if (!is_string($text) || $text == '') {
        return $text;
    }
    // get content
    $content = qtrans_split($text);
    // find available languages
    $available_languages = array();
    foreach ($content as $language => &$lang_text) {
        $lang_text = trim($lang_text);
        if (!empty($lang_text)) {
            $available_languages[] = $language;
        }
    }
    unset($lang_text);
    // if no languages available show full text
    if (empty($available_languages)) {
        return $text;
    }
    // if content is available show the content in the requested language
    if (!empty($content[$lang])) {
        return $content[$lang];
    }
    // content not available in requested language (bad!!) what now?
    if (!$show_available) {
        // check if content is available in default language, if not return first language found. (prevent empty result)
        if ($lang != $q_config['default_language'] && !empty($content[$q_config['default_language']])) {
            $str = $content[$q_config['default_language']];
            if ($q_config['show_displayed_language_prefix']) {
                $str = "(" . $q_config['language_name'][$q_config['default_language']] . ") " . $str;
            }
            return $str;
        }
        foreach ($content as $language => $lang_text) {
            if (!empty($lang_text)) {
                $str = $lang_text;
                if ($q_config['show_displayed_language_prefix']) {
                    $str = "(" . $q_config['language_name'][$language] . ") " . $str;
                }
                return $str;
            }
        }
    }
    // display selection for available languages
    $available_languages = array_unique($available_languages);
    $language_list = "";
    if (preg_match('/%LANG:([^:]*):([^%]*)%/S', $q_config['not_available'][$lang], $match)) {
        $normal_seperator = $match[1];
        $end_seperator = $match[2];
        // build available languages string backward
        foreach ($available_languages as $k => $language) {
            if ($k == 1) {
                $language_list = $end_seperator . $language_list;
            } else {
                if ($k > 1) {
                    $language_list = $normal_seperator . $language_list;
                }
            }
            $language_list = "<a href=\"" . qtrans_convertURL('', $language) . "\">" . $q_config['language_name'][$language] . "</a>" . $language_list;
        }
    }
    return "<p>" . preg_replace('/%LANG:([^:]*):([^%]*)%/S', $language_list, $q_config['not_available'][$lang]) . "</p>";
}
コード例 #8
0
 function language_isenabled($language = null)
 {
     $enabled = false;
     if (!empty($language)) {
         global $slideshow_languageplugin, ${'slideshow_languageenabled_' . $language};
         if (!empty(${'slideshow_languageenabled_' . $language})) {
             return ${'slideshow_languageenabled_' . $language};
         }
         switch ($slideshow_languageplugin) {
             case 'qtranslate':
                 $enabled = qtrans_isEnabled($language);
                 break;
             case 'qtranslate-x':
                 $enabled = qtranxf_isEnabled($language);
                 break;
             case 'wpml':
                 if (function_exists('icl_get_languages')) {
                     $languages = icl_get_languages();
                     if (!empty($languages[$language])) {
                         $enabled = true;
                     }
                 }
                 break;
         }
     }
     ${'slideshow_languageenabled_' . $language} = $enabled;
     return $enabled;
 }