Changeset 370 for trunk


Ignore:
Timestamp:
01/27/2010 10:09:19 AM (2 years ago)
Author:
ofer
Message:

Pre-calculate bing and google support for scripts

Location:
trunk/WordPress/plugin/transposh
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WordPress/plugin/transposh/js/transposh.js

    r367 r370  
    2828    source = 1, 
    2929    //Ajax translation 
    30     done_posted = 0, /*Timer for translation aggregation*/ timer, tokens = [], translations = [], 
     30    done_posted = 0, /*Timer for translation aggregation*/ timer, tokens = [], translations = [] 
    3131    // the languages supported externally 
    3232    // extracted using function above + he|zh-tw|pt that we know 
    33     google_langs = 'af|sq|ar|be|bg|ca|zh|zh-CN|zh-TW|hr|cs|da|nl|en|et|tl|fi|fr|gl|de|el|iw|hi|hu|is|id|ga|it|ja|ko|lv|lt|mk|ms|mt|no|fa|pl|pt-PT|ro|ru|sr|sk|sl|es|sw|sv|tl|th|tr|uk|vi|cy|yi|he|zh-tw|pt', 
     33    //google_langs = 'af|sq|ar|be|bg|ca|zh|zh-CN|zh-TW|hr|cs|da|nl|en|et|tl|fi|fr|gl|de|el|iw|hi|hu|is|id|ga|it|ja|ko|lv|lt|mk|ms|mt|no|fa|pl|pt-PT|ro|ru|sr|sk|sl|es|sw|sv|tl|th|tr|uk|vi|cy|yi|he|zh-tw|pt', 
    3434    // got this using Microsoft.Translator.GetLanguages() with added zh and zh-tw for our needs 
    35     bing_langs = 'ar,bg,zh-chs,zh-cht,cs,da,nl,en,ht,fi,fr,de,el,he,it,ja,ko,pl,pt,ru,es,sv,th,zh,zh-tw'; 
    36  
     35    //bing_langs = 'ar,bg,zh-chs,zh-cht,cs,da,nl,en,ht,fi,fr,de,el,he,it,ja,ko,pl,pt,ru,es,sv,th,zh,zh-tw'; 
     36    ; 
    3737    // This function fixes the page, it gets a token and translation and fixes this, 
    3838    // since here we only get the automated source, we use this to reduce the code size 
     
    234234            // we'll only auto-translate and load the stuff if we either have more than 5 candidate translations, or more than one at 4am, and this language is supported... 
    235235            if ((possibly_translateable > 5 || (now.getHours() === 4 && possibly_translateable > 0)) && 
    236                 (google_langs.indexOf(t_jp.lang) > -1 || bing_langs.indexOf(t_jp.lang) > -1)) { 
     236                (t_jp.google || t_jp.msn)) { 
    237237                // if we have a progress bar, we need to load the jqueryui before the auto translate, after the google was loaded, otherwise we can just go ahead 
    238238                langLoaded = function () { 
     
    259259                // we now start the chain that leads to auto-translate (with or without progress) 
    260260                //if supported in msn and msn is prefered or not supported in google than msn and we have the msn key 
    261                 if (((bing_langs.indexOf(t_jp.lang) > -1 && t_jp.preferred === 2) || (google_langs.indexOf(t_jp.lang) < 0)) &&  t_jp.msnkey !== '') { 
     261                if ((t_jp.msn && t_jp.preferred === 2) || !t_jp.google) { 
    262262                    source = 2; 
    263263                    getMSN = function () { 
  • trunk/WordPress/plugin/transposh/js/transposhedit.js

    r366 r370  
    1919// fetch translation from google translate... 
    2020(function () { // closure 
    21     var loadLang, langLoaded, 
    22     google_langs = 'af|sq|ar|be|bg|ca|zh|zh-CN|zh-TW|hr|cs|da|nl|en|et|tl|fi|fr|gl|de|el|iw|hi|hu|is|id|ga|it|ja|ko|lv|lt|mk|ms|mt|no|fa|pl|pt-PT|ro|ru|sr|sk|sl|es|sw|sv|tl|th|tr|uk|vi|cy|yi|he|zh-tw|pt', 
     21    var loadLang, langLoaded; 
     22    //google_langs = 'af|sq|ar|be|bg|ca|zh|zh-CN|zh-TW|hr|cs|da|nl|en|et|tl|fi|fr|gl|de|el|iw|hi|hu|is|id|ga|it|ja|ko|lv|lt|mk|ms|mt|no|fa|pl|pt-PT|ro|ru|sr|sk|sl|es|sw|sv|tl|th|tr|uk|vi|cy|yi|he|zh-tw|pt', 
    2323    // got this using Microsoft.Translator.GetLanguages() with added zh and zh-tw for our needs 
    24     bing_langs = 'ar,bg,zh-chs,zh-cht,cs,da,nl,en,ht,fi,fr,de,el,he,it,ja,ko,pl,pt,ru,es,sv,th,zh,zh-tw'; 
     24    //bing_langs = 'ar,bg,zh-chs,zh-cht,cs,da,nl,en,ht,fi,fr,de,el,he,it,ja,ko,pl,pt,ru,es,sv,th,zh,zh-tw'; 
    2525 
    2626    function fix_page_human(token, translation) { 
     
    175175        var tButtons = {}, hButtons = {}; 
    176176        //only add button is bing support is defined for the language (and we got some key) 
    177         if (bing_langs.indexOf(t_jp.lang) > -1 && t_jp.msnkey !== '') { 
     177        if (t_jp.msn) { 
    178178            //ar,zh-chs,zh-cht,nl,en,fr,de,he,it,ja,ko,pl,pt,ru,es 
    179179            tButtons['Suggest - Bing'] = function () { 
     
    183183 
    184184        // Only add button if google supports said language 
    185         if (google_langs.indexOf(t_jp.lang) > -1) { 
     185        if (t_jp.google) { 
    186186            tButtons['Suggest - Google'] = function () { 
    187187                getgt(); 
  • trunk/WordPress/plugin/transposh/transposh.php

    r364 r370  
    507507        //echo "t_jp.rtl=".(in_array ($this->target_language, $GLOBALS['rtl_languages'])? 'true' : 'false').";"; 
    508508        echo "t_jp.lang='{$this->target_language}';"; 
     509        // those two options show if the script can support said engines 
     510        echo "t_jp.msn=".(in_array($this->target_language,$GLOBALS['bing_languages']) && $this->options->get_msn_key()  ? 'true' : 'false').";"; 
     511        echo "t_jp.google=".(in_array($this->target_language,$GLOBALS['google_languages']) ? 'true' : 'false').";"; 
    509512        echo "t_jp.prefix='".SPAN_PREFIX."';"; 
    510513        echo "t_jp.msnkey='{$this->options->get_msn_key()}';"; 
Note: See TracChangeset for help on using the changeset viewer.