Plugin Directory

Changeset 385352


Ignore:
Timestamp:
05/16/2011 08:48:13 AM (15 years ago)
Author:
stevevls
Message:

1.1.7:

  • Right-to-left language support.
  • Send plugin version with API Client requests so responses can be tailored (e.g. RTL language require 1.1.7+)
  • Minor bugfix where bloginfo('language') returned empty string when blog is in English.
  • Return locale name (per WP behavior) instead of language code from bloginfo('language').
  • Translate title text for categories and posts in WP nav menus.
  • No more 404 for non-nested pages when permalink consists of only the post name (no fix possible for nested pages).
  • Widget now rewrites links using virtual hosts when set.
  • Send 301 redirects to virtual host when a translated blog request comes in via any other host name.
Location:
gts-translation/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • gts-translation/trunk/Gts.php

    r373063 r385352  
    3737Plugin URI: http://gts-translation.com/
    3838Description: 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.6
     39Version: 1.1.7
    4040Author: Steve van Loben Sels
    4141Author URI: http://gts-translation.com/
  • gts-translation/trunk/GtsPlugin.php

    r369686 r385352  
    222222                (string) $language_xml->displayCountryCode,
    223223                (string) $language_xml->wordpressLocaleName,
     224                (string) $language_xml->textDirection,
    224225                $localization_strings
    225226            );
     
    389390        // get expanded into open/close tags.  therefore, we need to be able to differentiate.
    390391        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>";
    392393        }
    393394
  • gts-translation/trunk/lib/ApiClient.php

    r288004 r385352  
    8585            'Content-length: ' . strlen( $data ),
    8686            'X-Gts-Signature: ' . sha1( $data . $this->api_access_key ),
     87            'X-Gts-Plugin-Version: ' . GTS_PLUGIN_VERSION,
    8788        );
    8889
  • gts-translation/trunk/lib/Language.php

    r369686 r385352  
    5353    var $displayCountryCode;
    5454    var $wordpressLocaleName;
     55    var $textDirection;
    5556
    5657    var $localizationStrings;
    5758
    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 ) {
    5960        $this->code = $code;
    6061        $this->name = $name;
     
    6667        $this->displayCountryCode = $displayCountryCode;
    6768        $this->wordpressLocaleName = $wordpressLocaleName;
     69        $this->textDirection = $textDirection;
    6870        $this->localizationStrings = $localizationStrings;
    6971    }
  • gts-translation/trunk/readme.txt

    r373063 r385352  
    44Donate Link: http://www.gts-translation.com/
    55Requires at least: 2.9
    6 Tested up to: 3.1.1
    7 Stable tag: 1.1.6
     6Tested up to: 3.1.2
     7Stable tag: 1.1.7
    88
    99This plugin is guaranteed to drive more international traffic to your site by providing high quality translation, and SEO of your translated content.
     
    1818
    1919*   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 languages
     20*   Supports over 30 languages
    2121*   Uses private, secure translation server
    2222*   Publish translated content immediately or following review
     
    6464
    6565
    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 any
    68 of the public machine translations engines such as Google or Microsoft. This means that your content is secure and will
    69 not be shared with other companies or bloggers.
    70 
    7166= Are comments translated? =
    7267No. Comments are are passed through as-is.
     
    7570= Which languages are supported? =
    7671* 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.
    7873
    7974We're continually adding new languages, so for the latest list, click [here](http://translate.gts-translation.com/api/supportedLanguages).
     
    126121translate your posts, but won't properly display them.  Upgrade using your WP Admin panel, and you'll be good to go.
    127122
     123= How do I use the virtual host feature? =
     124Please see the *Virtual Host Setup* tab.
    128125
    129126= What is theme translation? =
     
    168165
    169166* ICanLocalize  (inserts invalid HTML into the post body)
     167* Recently Popular  (directly selects posts from the DB, so plugin hooks are bypassed)
    170168
    171169This list is a work in progress and may grow as we roll out to more users.
     
    173171
    174172= How secure is the system? =
    175 Please see the Security tab.
     173Please see the *Security* tab.
    176174
    177175
    178176== 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.
    179187
    180188= 1.1.6 =
     
    302310We have dedicated lots of thought to locking down this system, and we are very confident that it's secure.
    303311After 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
     317By 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,
     318the Spanish version of your site resolves to http://mywebsite.com/language/es.
     319
     320With the GTS Translation Plugin Virtual Host feature you can publish translated versions of yor website/blog under a separate subdomain or top-level
     321domain (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
     324To implement the virtual hosts feature, follow these steps:
     325
     326### 1. Configure DNS ###
     327
     328**For Top Level Domains:**
     329
     3301. Register your new domain (e.g. www.mywebsite.es.) with a recognized domain registrar.
     3311. 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
     3351. Create a CNAME alias for your web server (e.g. es.mywebsite.com)
     336
     337How 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
     341Please 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
     345Your 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
     346Root as your blog.
     347
     348**For Self-hosted Blogs:**
     349
     350These instructions are only valid for Apache.  If you use IIS or another web server, please consult the relevant documentation.
     351
     352First 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
     353virtual 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
     366If 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
     371This is the easiest part:
     372
     3731. Go to the "GTS Settings" admin page.
     3741. Enter the host name in the "Virtual Host" input next to the desired language.
     3751. Click the "Save Changes" button.
     376
     377Voila, translated links will point to your new host!
  • gts-translation/trunk/wordpress/GtsLinkRewriter.php

    r373232 r385352  
    319319        }
    320320
     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
    321326        // now do replacements for any of our translated slugs.
    322327        $this->replace_with_slug( $query_vars, 'tag' );
     
    325330        $this->replace_with_slug( $query_vars, 'term' );
    326331
    327         if( $query_vars[GtsLinkRewriter::$LANG_PARAM] && $query_vars['pagename'] ) {
     332        if( !$has_name && $query_vars[GtsLinkRewriter::$LANG_PARAM] && $query_vars['pagename'] ) {
    328333            $query_vars['pagename'] = $this->get_original_pagename( $query_vars['pagename'], $query_vars['gts_lang'] );
    329334        }
  • gts-translation/trunk/wordpress/GtsPluginWordpress.php

    r373063 r385352  
    5858        parent::__construct();
    5959
    60         global $wpdb, $wp_rewrite;
     60        global $wpdb;
    6161        $this->wpdb = $wpdb;
    6262
     
    7474                $this->theme_language = $matches[1];
    7575            }
     76
    7677            if( $this->target_hostname ) {
    7778                $this->theme_language = $this->language;
     
    8283        }
    8384
     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        }
    84104    }
    85105
     
    436456        // locale is loaded before query parameters are parsed, so like with the theme,
    437457        // 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;
    440467        }
    441468
     
    912939    function filter_translated_bloginfo( $bloginfo, $show ) {
    913940
    914         if($show == 'name') {
    915             $show = 'blogname';
    916         }
    917         else if($show == 'description') {
     941        if( $show == 'name' || $show == 'description' ) {
    918942            $show = "blog$show";
    919943        }
    920944
    921         if($this->language) {
    922             switch($show) {
     945        if( $this->language ) {
     946            switch( $show ) {
    923947                case 'language':
    924                     return $this->language;
     948                    return com_gts_Language::get_by_code( $this->theme_language )->wordpressLocaleName;
    925949                case 'blogname':
    926950                case 'blogdescription':
    927951                    $translated_option = $this->get_translated_named_option( $show, $this->language );
    928                     if($translated_option) {
     952                    if( $translated_option ) {
    929953                        return $translated_option->value;
    930954                    }
     
    11241148
    11251149        $post = $this->get_translated_blog_post( $post_id, $this->language );
     1150
     1151        // easy case...the post is valid and we return the title!
    11261152        if( $post ) {
    11271153            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
    11281177        }
    11291178
  • gts-translation/trunk/wordpress/GtsWidgets.php

    r373063 r385352  
    148148        if( !$wp_rewrite->permalink_structure ) {
    149149
    150             $link = $this->get_homed_url( $home, null );
     150            $link = $this->get_homed_url( $home );
    151151            if( $lang->code == $gts_plugin->config->source_language ) {
    152152                $link = remove_query_arg( "language", $link );
     
    161161            // of them boil down to running the link through the plugin with the language overridden.
    162162
    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 );
    164168            $interesting_part = substr( $homed_url, strlen( $home ) );
    165169
     
    291295
    292296
    293     function get_homed_url( $home, $lang ) {
     297    function get_homed_url( $home ) {
    294298
    295299        $home = untrailingslashit( $home );
Note: See TracChangeset for help on using the changeset viewer.