Пример #1
0
    /**
     * Insert supported languages section in admin page
     * @param string $data
     */
    function tp_langs()
    {
        // we need some styles
        global $wp_locale;
        if ($wp_locale->text_direction == 'rtl') {
            echo '<style type="text/css">
	#sortable li, #default_lang li { float: right !important;}
        .logoicon {
            float:left !important;
        }
        </style>';
        }
        // this is the default language location
        list($langname, $langorigname, $flag) = explode(",", transposh_consts::$languages[$this->transposh->options->default_language]);
        echo '<div id="default_lang" style="overflow:auto;padding-bottom:10px;">';
        $this->header(__('Default Language (drag another language here to make it default)', TRANSPOSH_TEXT_DOMAIN), 'languages');
        echo '<ul id="default_list"><li id="' . $this->transposh->options->default_language . '" class="languages">' . transposh_utils::display_flag("{$this->transposh->transposh_plugin_url}/img/flags", $flag, $langorigname, false) . '<input type="hidden" name="languages[]" value="' . $this->transposh->options->default_language . '" />' . '&nbsp;<span class="langname">' . $langorigname . '</span><span class="langname hidden">' . $langname . '</span></li>';
        echo '</ul></div>';
        // list of languages
        echo '<div style="overflow:auto; clear: both;">';
        $this->header(__('Available Languages (Click to toggle language state - Drag to sort in the widget)', TRANSPOSH_TEXT_DOMAIN));
        $this->header(__('Only first five will be saved! Upgrade to full free version by choosing the option at the settings', TRANSPOSH_TEXT_DOMAIN));
        echo '<ul id="sortable">';
        foreach ($this->transposh->options->get_sorted_langs() as $langcode => $langrecord) {
            tp_logger($langcode, 5);
            list($langname, $langorigname, $flag) = explode(",", $langrecord);
            echo '<li id="' . $langcode . '" class="languages ' . ($this->transposh->options->is_active_language($langcode) || $this->transposh->options->is_default_language($langcode) ? "lng_active" : "") . '"><div style="float:' . $this->localeleft . '">' . transposh_utils::display_flag("{$this->transposh->transposh_plugin_url}/img/flags", $flag, false) . '<input type="hidden" name="languages[]" value="' . $langcode . ($this->transposh->options->is_active_language($langcode) ? ",v" : ",") . '" />' . '&nbsp;<span class="langname">' . $langorigname . '</span><span class="langname hidden">' . $langname . '</span></div>';
            if (in_array($langcode, transposh_consts::$google_languages)) {
                echo '<img width="16" height="16" alt="g" class="logoicon" title="' . esc_attr__('Language supported by google translate', TRANSPOSH_TEXT_DOMAIN) . '" src="' . $this->transposh->transposh_plugin_url . '/' . TRANSPOSH_DIR_IMG . '/googleicon.png"/>';
            }
            if (in_array($langcode, transposh_consts::$bing_languages)) {
                echo '<img width="16" height="16" alt="b" class="logoicon" title="' . esc_attr__('Language supported by bing translate', TRANSPOSH_TEXT_DOMAIN) . '" src="' . $this->transposh->transposh_plugin_url . '/' . TRANSPOSH_DIR_IMG . '/bingicon.png"/>';
            }
            if (in_array($langcode, transposh_consts::$apertium_languages)) {
                echo '<img width="16" height="16" alt="a" class="logoicon" title="' . esc_attr__('Language supported by apertium translate', TRANSPOSH_TEXT_DOMAIN) . '" src="' . $this->transposh->transposh_plugin_url . '/' . TRANSPOSH_DIR_IMG . '/apertiumicon.png"/>';
            }
            if (in_array($langcode, transposh_consts::$oht_languages)) {
                echo '<img width="16" height="16" alt="a" class="logoicon" title="' . esc_attr__('Language supported by one hour translation', TRANSPOSH_TEXT_DOMAIN) . '" src="' . $this->transposh->transposh_plugin_url . '/' . TRANSPOSH_DIR_IMG . '/ohticon.png"/>';
            }
            if (in_array($langcode, transposh_consts::$rtl_languages)) {
                echo '<img width="16" height="16" alt="r" class="logoicon" title="' . esc_attr__('Language is written from right to left', TRANSPOSH_TEXT_DOMAIN) . '" src="' . $this->transposh->transposh_plugin_url . '/' . TRANSPOSH_DIR_IMG . '/rtlicon.png"/>';
            }
            echo '</li>';
        }
        echo "</ul></div>";
        // options to play with
        echo '<div style="clear: both;">' . __('Display options:', TRANSPOSH_TEXT_DOMAIN) . '<br/><ul style="list-style-type: disc; margin-' . $this->localeleft . ':20px;font-size:11px">';
        echo '<li><a href="#" id="changename">' . __('Toggle names of languages between English and Original', TRANSPOSH_TEXT_DOMAIN) . '</a></li>';
        echo '<li><a href="#" id="selectall">' . __('Make all languages active', TRANSPOSH_TEXT_DOMAIN) . '</a></li>';
        echo '<li><a href="#" id="sortname">' . __('Sort by language name', TRANSPOSH_TEXT_DOMAIN) . '</a></li>';
        echo '<li><a href="#" id="sortiso">' . __('Sort by lSO code', TRANSPOSH_TEXT_DOMAIN) . '</a></li></ul>';
        echo '</div>';
    }
Пример #2
0
 /**
  * Modify post title to have language wrapping
  * @param string $text the post title text
  * @return string wrapped text
  */
 function post_wrap($text, $id = 0)
 {
     $id = is_object($id) ? $id->ID : $id;
     if (!$id) {
         return $text;
     }
     $lang = get_post_meta($id, 'tp_language', true);
     if ($lang) {
         if (strpos($_SERVER['REQUEST_URI'], 'wp-admin/edit') !== false) {
             tp_logger('iamhere?' . strpos($_SERVER['REQUEST_URI'], 'wp-admin/edit'));
             $plugpath = parse_url($this->transposh_plugin_url, PHP_URL_PATH);
             list($langeng, $langorig, $langflag) = explode(',', transposh_consts::$languages[$lang]);
             $text = transposh_utils::display_flag("{$plugpath}/img/flags", $langflag, $langorig, false) . ' ' . $text;
         } else {
             $text = "<span lang =\"{$lang}\">" . $text . "</span>";
         }
     }
     return $text;
 }