Changeset 385352
- Timestamp:
- 05/16/2011 08:48:13 AM (15 years ago)
- Location:
- gts-translation/trunk
- Files:
-
- 8 edited
-
Gts.php (modified) (1 diff)
-
GtsPlugin.php (modified) (2 diffs)
-
lib/ApiClient.php (modified) (1 diff)
-
lib/Language.php (modified) (2 diffs)
-
readme.txt (modified) (8 diffs)
-
wordpress/GtsLinkRewriter.php (modified) (2 diffs)
-
wordpress/GtsPluginWordpress.php (modified) (6 diffs)
-
wordpress/GtsWidgets.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gts-translation/trunk/Gts.php
r373063 r385352 37 37 Plugin URI: http://gts-translation.com/ 38 38 Description: This plugin is guaranteed to drive more international traffic to your site by providing high quality translation, and SEO of your translated content. 39 Version: 1.1. 639 Version: 1.1.7 40 40 Author: Steve van Loben Sels 41 41 Author URI: http://gts-translation.com/ -
gts-translation/trunk/GtsPlugin.php
r369686 r385352 222 222 (string) $language_xml->displayCountryCode, 223 223 (string) $language_xml->wordpressLocaleName, 224 (string) $language_xml->textDirection, 224 225 $localization_strings 225 226 ); … … 389 390 // get expanded into open/close tags. therefore, we need to be able to differentiate. 390 391 if ($m[5]) { 391 return "<shortcode-content-$tag$attr>$m[5]</shortcode-content-$tag >";392 return "<shortcode-content-$tag$attr>$m[5]</shortcode-content-$tag$attr>"; 392 393 } 393 394 -
gts-translation/trunk/lib/ApiClient.php
r288004 r385352 85 85 'Content-length: ' . strlen( $data ), 86 86 'X-Gts-Signature: ' . sha1( $data . $this->api_access_key ), 87 'X-Gts-Plugin-Version: ' . GTS_PLUGIN_VERSION, 87 88 ); 88 89 -
gts-translation/trunk/lib/Language.php
r369686 r385352 53 53 var $displayCountryCode; 54 54 var $wordpressLocaleName; 55 var $textDirection; 55 56 56 57 var $localizationStrings; 57 58 58 function __construct( $code, $name, $englishName, $input, $output, $latin, $recentlyAdded, $displayCountryCode, $wordpressLocaleName, $ localizationStrings ) {59 function __construct( $code, $name, $englishName, $input, $output, $latin, $recentlyAdded, $displayCountryCode, $wordpressLocaleName, $textDirection, $localizationStrings ) { 59 60 $this->code = $code; 60 61 $this->name = $name; … … 66 67 $this->displayCountryCode = $displayCountryCode; 67 68 $this->wordpressLocaleName = $wordpressLocaleName; 69 $this->textDirection = $textDirection; 68 70 $this->localizationStrings = $localizationStrings; 69 71 } -
gts-translation/trunk/readme.txt
r373063 r385352 4 4 Donate Link: http://www.gts-translation.com/ 5 5 Requires at least: 2.9 6 Tested up to: 3.1. 17 Stable tag: 1.1. 66 Tested up to: 3.1.2 7 Stable tag: 1.1.7 8 8 9 9 This plugin is guaranteed to drive more international traffic to your site by providing high quality translation, and SEO of your translated content. … … 18 18 19 19 * Guaranteed to increase your traffic by at least 30% after 2 months; some customers have seen over 100% increase in traffic 20 * Supports over 10 languages20 * Supports over 30 languages 21 21 * Uses private, secure translation server 22 22 * Publish translated content immediately or following review … … 64 64 65 65 66 = Do you outsource the machine translation? =67 The translation server used to do the machine translation is a private server which is owned by GTS. It does not use any68 of the public machine translations engines such as Google or Microsoft. This means that your content is secure and will69 not be shared with other companies or bloggers.70 71 66 = Are comments translated? = 72 67 No. Comments are are passed through as-is. … … 75 70 = Which languages are supported? = 76 71 * Input: English 77 * Output: Chinese (Simplified and Traditional), Finnish, French, German, Italian, Japanese, Portuguese, Russian, Spanish, and Swedish.72 * Output: Chinese (Simplified and Traditional), Dutch, Finnish, French, German, Hebrew, Italian, Japanese, Polish, Portuguese, Russian, Spanish, Swedish, Thai, and Turkish. 78 73 79 74 We're continually adding new languages, so for the latest list, click [here](http://translate.gts-translation.com/api/supportedLanguages). … … 126 121 translate your posts, but won't properly display them. Upgrade using your WP Admin panel, and you'll be good to go. 127 122 123 = How do I use the virtual host feature? = 124 Please see the *Virtual Host Setup* tab. 128 125 129 126 = What is theme translation? = … … 168 165 169 166 * ICanLocalize (inserts invalid HTML into the post body) 167 * Recently Popular (directly selects posts from the DB, so plugin hooks are bypassed) 170 168 171 169 This list is a work in progress and may grow as we roll out to more users. … … 173 171 174 172 = How secure is the system? = 175 Please see the Securitytab.173 Please see the *Security* tab. 176 174 177 175 178 176 == Changelog == 177 178 = 1.1.7 = 179 * Right-to-left language support. 180 * Send plugin version with API Client requests so responses can be tailored (e.g. RTL language require 1.1.7+) 181 * Minor bugfix where bloginfo('language') returned empty string when blog is in English. 182 * Return locale name (per WP behavior) instead of language code from bloginfo('language'). 183 * Translate title text for categories and posts in WP nav menus. 184 * No more 404 for non-nested pages when permalink consists of only the post name (no fix possible for nested pages). 185 * Widget now rewrites links using virtual hosts when set. 186 * Send 301 redirects to virtual host when a translated blog request comes in via any other host name. 179 187 180 188 = 1.1.6 = … … 302 310 We have dedicated lots of thought to locking down this system, and we are very confident that it's secure. 303 311 After reading this, we hope you will be too! 312 313 == Virtual Host Setup == 314 315 ### How to setup the Virtual Host feature on the GTS Plugin ### 316 317 By default, the translated versions of your website/blog resolves to a URL address which is a subdirectory of your site’s URL address. For example, 318 the Spanish version of your site resolves to http://mywebsite.com/language/es. 319 320 With the GTS Translation Plugin Virtual Host feature you can publish translated versions of yor website/blog under a separate subdomain or top-level 321 domain (TLD). So for example, if your blog is www.mywebsite.com you can serve the Spanish version from www.mywebsite.es. Alternately, you can use 322 subdomains (e.g. es.mywebsite.com) so that you don't have to buy a domain for each language. 323 324 To implement the virtual hosts feature, follow these steps: 325 326 ### 1. Configure DNS ### 327 328 **For Top Level Domains:** 329 330 1. Register your new domain (e.g. www.mywebsite.es.) with a recognized domain registrar. 331 1. In your DNS zone, set the A record for www.mywebsite.es to point to the IP address of your web server. 332 333 **For Subdomains:** 334 335 1. Create a CNAME alias for your web server (e.g. es.mywebsite.com) 336 337 How to complete these steps will depend on your hosting provider. If you get stuck, please follow up with your support team. 338 339 ### 2. Configure your Web Server ### 340 341 Please note that all of the translated blogs will be hosted from the same WordPress installation as your current blog. 342 343 **For Hosted Blogs:** 344 345 Your hosting provider will provide a control panel to map a hostname to a Document Root. For each translated host name, enter the exact same Document 346 Root as your blog. 347 348 **For Self-hosted Blogs:** 349 350 These instructions are only valid for Apache. If you use IIS or another web server, please consult the relevant documentation. 351 352 First off, you need to be set up with Name Based Virtual Hosts (http://httpd.apache.org/docs/2.0/vhosts/name-based.html). Once you have your blog's 353 virtual host set up, add the new hostname to the ServerAlias directive. 354 355 356 > <VirtualHost *:80> 357 > 358 > ServerName www.mywebsite.com 359 > ServerAlias www.mywebsite.es 360 > DocumentRoot /path/to/wordpress/install 361 > 362 > # Other configuration here... 363 > 364 > </VirtualHost> 365 366 If you have multiple aliases, remember that the ServerAlias can be a list or can include wildcards…it can save time! 367 368 369 ### 3. Configure the GTS Plugin ### 370 371 This is the easiest part: 372 373 1. Go to the "GTS Settings" admin page. 374 1. Enter the host name in the "Virtual Host" input next to the desired language. 375 1. Click the "Save Changes" button. 376 377 Voila, translated links will point to your new host! -
gts-translation/trunk/wordpress/GtsLinkRewriter.php
r373232 r385352 319 319 } 320 320 321 // HACK ALERT! : when we replace the slug, we'll set pagename and unset name if the post is actually a page. 322 // this can happen when the peramlink is only the post name...there are conflict for more than a single-word 323 // page name. so after replacing all the slugs, we'll rewrite the pagename only if we haven't already! 324 $has_name = $query_vars['name']; 325 321 326 // now do replacements for any of our translated slugs. 322 327 $this->replace_with_slug( $query_vars, 'tag' ); … … 325 330 $this->replace_with_slug( $query_vars, 'term' ); 326 331 327 if( $query_vars[GtsLinkRewriter::$LANG_PARAM] && $query_vars['pagename'] ) {332 if( !$has_name && $query_vars[GtsLinkRewriter::$LANG_PARAM] && $query_vars['pagename'] ) { 328 333 $query_vars['pagename'] = $this->get_original_pagename( $query_vars['pagename'], $query_vars['gts_lang'] ); 329 334 } -
gts-translation/trunk/wordpress/GtsPluginWordpress.php
r373063 r385352 58 58 parent::__construct(); 59 59 60 global $wpdb , $wp_rewrite;60 global $wpdb; 61 61 $this->wpdb = $wpdb; 62 62 … … 74 74 $this->theme_language = $matches[1]; 75 75 } 76 76 77 if( $this->target_hostname ) { 77 78 $this->theme_language = $this->language; … … 82 83 } 83 84 85 // now that all that is squared away, see if we need to redirect to a virtual host. if a virtual host is 86 // set, we want to avoid serving up content from any other hostname so that for SEO purposes we don't have 87 // the same page hosted in two places. 88 if( $this->theme_language ) { 89 90 $virtual_host = $this->config->target_hostnames[$this->theme_language]; 91 if( $virtual_host && $virtual_host != $_SERVER['HTTP_HOST'] ) { 92 93 $https = $_SERVER['HTTPS'] == 'on'; 94 $server_port = $_SERVER['SERVER_PORT']; 95 96 $protocol = 'http' . ($https ? 's' : ''); 97 $port = (!$https && $server_port == 80) || ($https && $server_port == 443) ? '' : ":$server_port"; 98 99 $url = "Location: $protocol://$virtual_host$port" . $_SERVER['REQUEST_URI']; 100 header($url, true, 301); 101 die(); 102 } 103 } 84 104 } 85 105 … … 436 456 // locale is loaded before query parameters are parsed, so like with the theme, 437 457 // we have to detect the language prior to parsing params. 438 if ( $this->theme_language != $this->config->source_language ) { 439 return com_gts_Language::get_by_code( $this->theme_language )->wordpressLocaleName; 458 if ( $this->theme_language && $this->theme_language != $this->config->source_language ) { 459 460 $lang_by_code = com_gts_Language::get_by_code($this->theme_language); 461 462 // this is also a good time to go about setting the text direction... 463 global $text_direction; 464 $text_direction = $lang_by_code->textDirection; 465 466 return $lang_by_code->wordpressLocaleName; 440 467 } 441 468 … … 912 939 function filter_translated_bloginfo( $bloginfo, $show ) { 913 940 914 if($show == 'name') { 915 $show = 'blogname'; 916 } 917 else if($show == 'description') { 941 if( $show == 'name' || $show == 'description' ) { 918 942 $show = "blog$show"; 919 943 } 920 944 921 if( $this->language) {922 switch( $show) {945 if( $this->language ) { 946 switch( $show ) { 923 947 case 'language': 924 return $this->language;948 return com_gts_Language::get_by_code( $this->theme_language )->wordpressLocaleName; 925 949 case 'blogname': 926 950 case 'blogdescription': 927 951 $translated_option = $this->get_translated_named_option( $show, $this->language ); 928 if( $translated_option) {952 if( $translated_option ) { 929 953 return $translated_option->value; 930 954 } … … 1124 1148 1125 1149 $post = $this->get_translated_blog_post( $post_id, $this->language ); 1150 1151 // easy case...the post is valid and we return the title! 1126 1152 if( $post ) { 1127 1153 return $post->post_title; 1154 } 1155 1156 // less easy case... this is a fix for WP menus, which do some really retarded 1157 // things with copying the data from the post around and sending the category through 1158 // here. it's ridiculous... 1159 if( !$post && !in_the_loop() && is_nav_menu_item( $post_id ) ) { 1160 1161 $post_type = get_post_meta( $post_id, '_menu_item_object' ); 1162 $original_post_id = get_post_meta( $post_id, '_menu_item_object_id' ); 1163 1164 if( $post_type[0] == 'page' ) { 1165 $post = $this->get_translated_blog_post( $original_post_id[0] , $this->language ); 1166 if( $post ) { 1167 return $post->post_title; 1168 } 1169 } 1170 else if( $post_type[0] == 'category' ) { 1171 $category = $this->get_translated_blog_term( $original_post_id[0], $this->language ); 1172 if( $category ) { 1173 return $category->name; 1174 } 1175 } 1176 1128 1177 } 1129 1178 -
gts-translation/trunk/wordpress/GtsWidgets.php
r373063 r385352 148 148 if( !$wp_rewrite->permalink_structure ) { 149 149 150 $link = $this->get_homed_url( $home , null);150 $link = $this->get_homed_url( $home ); 151 151 if( $lang->code == $gts_plugin->config->source_language ) { 152 152 $link = remove_query_arg( "language", $link ); … … 161 161 // of them boil down to running the link through the plugin with the language overridden. 162 162 163 $homed_url = $this->get_homed_url( $home, $lang->code ); 163 $home_url = parse_url( $home ); 164 $lang_url = parse_url( $gts_plugin->do_with_language( array($this, 'callback_get_home'), $lang->code ) ); 165 $home = str_replace( $home_url['host'], $lang_url['host'], $home ); 166 167 $homed_url = $this->get_homed_url( $home ); 164 168 $interesting_part = substr( $homed_url, strlen( $home ) ); 165 169 … … 291 295 292 296 293 function get_homed_url( $home , $lang) {297 function get_homed_url( $home ) { 294 298 295 299 $home = untrailingslashit( $home );
Note: See TracChangeset
for help on using the changeset viewer.