Google AJAX Translation onto your blog. This plugin enables your blog readers translate your blog posts or comments into other languages. Author: Libin Pan and Michael Klein Version: 0.3.1 Stable tag: 0.3.1 Author URI: http://libinpan.com Installation: 1. Download the plugin and unzip it (didn't you already do this?). 2. Put the 'google-ajax-translation' folder into your wp-content/plugins/ directory. 3. Go to the Plugins page in your WordPress Administration area and click 'Activate' next to Google AJAX Translation. 4. Have fun with your blog readers. 5. Change the settings from Setting -> Google Translation Admin Page Notes: - Right now only support translating the first 500 characters of your blog comments - I am using Google Ajax Translation to detect your text languages. It may not be 100% right, but close. - If you want to use it with your post too, please comment out line 84. But please notice all the html tag will be filtered out as google will translate the content inside of tags, which could mess your blog. - If you want to do some changes and want to share with all of us, please feel free to contact me @ libinpan@gmail.com or leave comments TODO: - Keep the format of post and comment - Support more than 500 characters? Version history: - .4.0 . Add Enable/Disable Page Translation option - .3.1 . fixed some html-bugs (missing alt-Tags, etc.) (Michael Klein) - .3.0 . encapsulate the plugin in a class. No global vars needed anymore, faster code (Michael Klein) . Better support of capabilities-model (WP 2.6) - .2.0 Thanks Michael Klein from alquanto.de for: . Add Flag ICONs link style . Add Flag ICONs Others changes: Add Admin Configuration Page . Link Style: Text and Image . Enable/Disable Post Translation . Choose languages from the whole list - .1.1 Small updates: . Working on Admin/Comments pages too . Fixed the comment format problem found by Sean - .1 Initial Release This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ if (!class_exists('GoogleTranslation')) { class GoogleTranslation { var $optionPrefix = 'google_translation_'; var $version = '0.3.1'; var $pluginUrl = 'http://wordpress.org/extend/plugins/google-ajax-translation/'; var $authorUrl = 'http://blog.libinpan.com/2008/08/04/google-ajax-translation-wordpress-plugin/'; var $languages = array( 'en' => 'English', 'zh-CN' => 'Chinese(S)', 'zh-TW' => 'Chinese(T)', 'fr' => 'French', 'ar' => 'Arabic', 'bg' => 'Bulgarian', 'hr' => 'Croatian', 'cs' => 'Czech', 'da' => 'Danish', 'nl' => 'Dutch', 'fi' => 'Finnish', 'de' => 'German', 'el' => 'Greek', 'hi' => 'Hindi', 'it' => 'Italian', 'ja' => 'Japanese', 'ko' => 'Korean', 'no' => 'Norwegian', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ro' => 'Romanian', 'ru' => 'Russian', 'es' => 'Spanish', 'sv' => 'Swedish' ); var $options = array( // default values for options 'linkStyle' => 'images', 'postEnable' => false, 'pageEnable' => false, 'languages' => array() ); var $textDomain = 'wpgt'; var $languageFileLoaded = false; var $pluginRoot = ''; function getPluginUrl() { $path = dirname(__FILE__); $path = str_replace("\\","/",$path); $path = trailingslashit(get_bloginfo('wpurl')) . trailingslashit(substr($path,strpos($path,"wp-content/"))); return $path; } function GoogleTranslation() { // Constructor $this->pluginRoot = $this->getPluginUrl(); foreach ($this->options as $k=>$v) { // get options from DB $this->options[$k] = get_option($this->optionPrefix.$k); } // Add action and filter hooks to WordPress add_action('admin_menu', array(&$this, 'addOptionsPage')); add_action('wp_footer', array(&$this, 'insertJs')); add_action('admin_footer', array(&$this, 'insertJs')); add_filter('comment_text', array(&$this, 'processComment')); if ($this->options['postEnable']) { add_filter('the_content',array(&$this, 'processContent')); } } function addOptionsPage(){ add_options_page('Google Translation', 'Google Translation', 'manage_options', basename(__FILE__), array(&$this, 'outputOptionsPanel')); } function loadLanguageFile() { // loads language files according to locale if(!$this->languageFileLoaded) { load_plugin_textdomain($this->textDomain, $this->pluginRoot.'languages'); $this->languageFileLoaded = true; } } function outputOptionsPanel() { $a = array(); $p = $this->optionPrefix; foreach ($this->options as $k=>$v) $a[] = $p.$k; // prefix all option-vars $page_options = join(',', $a); echo '
'.__('Version').' '.$this->version; echo ' | Homepage'; echo ' | Plugin Homepage'; echo ' | Donate'; echo '
'; echo 'View this Post in:'.$this->getLanguageLinks('post', $id).'
'; } return $content; } function processComment($content = '') { global $comment; $id = $comment->comment_ID; return 'View this Comment in:'.$this->getLanguageLinks('comment', $id).'
'; } function insertJs() { echo <<