Changeset 664


Ignore:
Timestamp:
11/02/2011 11:17:01 PM (7 months ago)
Author:
ofer
Message:

Allow using your own MSN API Key, And setting up the Google API Key (not using yet)

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

Legend:

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

    r646 r664  
    3535    // transposh app_id for msn translate, now global 
    3636    t_jp.MSN_APPID = 'FACA8E2DF8DCCECE0DC311C6E57DA98EFEFA9BC6'; 
     37    if (t_jp.msn_key) { 
     38        t_jp.MSN_APPID = t_jp.msn_key; 
     39    } 
    3740    // set base uri for jQueryUI 
    38     t_jp.jQueryUI = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/'; 
     41    t_jp.jQueryUI = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/'; 
    3942 
    4043    // This function fixes the page, it gets a token and translation and fixes this, 
  • trunk/WordPress/plugin/transposh/transposh.php

    r659 r664  
    685685            'plugin_url' => $this->transposh_plugin_url, 
    686686            'lang' => $this->target_language, 
    687             //TODO - orig language? 
    688687            'olang' => $this->options->get_default_language(), 
    689688            // those two options show if the script can support said engines 
     
    691690            'preferred' => $this->options->get_preferred_translator() 
    692691        ); 
    693         if (in_array($this->target_language, transposh_consts::$bing_languages)) 
     692 
     693        if (in_array($this->target_language, transposh_consts::$bing_languages)) { 
    694694                $script_params['msn'] = 1; 
    695         if (in_array($this->target_language, transposh_consts::$google_languages)) 
     695                if ($this->options->get_msn_key()) { 
     696                    $script_params['msn_key'] = $this->options->get_msn_key(); 
     697                } 
     698        } 
     699        if (in_array($this->target_language, transposh_consts::$google_languages)) { 
    696700                $script_params['google'] = 1; 
     701                if ($this->options->get_google_key()) { 
     702                    $script_params['google_key'] = $this->options->get_google_key(); 
     703                } 
     704        } 
    697705        if (in_array($this->target_language, transposh_consts::$apertium_languages)) 
    698706                $script_params['apertium'] = 1; 
  • trunk/WordPress/plugin/transposh/wp/transposh_admin.php

    r660 r664  
    121121        $this->transposh->options->set_transposh_default_locale_override($_POST[TRANSPOSH_DEFAULT_LOCALE_OVERRIDE]); 
    122122        $this->transposh->options->set_preferred_translator($_POST[PREFERRED_TRANSLATOR]); 
     123        $this->transposh->options->set_msn_key($_POST[MSN_TRANSLATE_KEY]); 
     124        $this->transposh->options->set_google_key($_POST[GOOGLE_TRANSLATE_KEY]); 
    123125        $this->transposh->options->set_transposh_key($_POST[TRANSPOSH_KEY]); 
    124126 
     
    232234        } 
    233235 
    234         if (!(class_exists('Memcache') /*!!&& $this->memcache->connect(TP_MEMCACHED_SRV, TP_MEMCACHED_PORT)*/) && !function_exists('apc_fetch') && !function_exists('xcache_get') && !function_exists('eaccelerator_get')) { 
     236        if (!(class_exists('Memcache') /* !!&& $this->memcache->connect(TP_MEMCACHED_SRV, TP_MEMCACHED_PORT) */) && !function_exists('apc_fetch') && !function_exists('xcache_get') && !function_exists('eaccelerator_get')) { 
    235237            $this->add_warning('tp_cache_warning', __('We were not able to find a supported in-memory caching engine, installing one can improve performance.', TRANSPOSH_TEXT_DOMAIN) . ' <a href="http://transposh.org/faq#performance">' . __('Check Transposh FAQs', TRANSPOSH_TEXT_DOMAIN) . '</a>'); 
    236238        } 
     
    497499        __('Do automatic translation immediately after a post has been published', TRANSPOSH_TEXT_DOMAIN); 
    498500 
     501        /** 
     502         * Allow users to insert their own API keys 
     503         */ 
     504        echo '<h4>' . __('MSN API key', TRANSPOSH_TEXT_DOMAIN) . '</h4>'; 
     505        echo __('API Key', TRANSPOSH_TEXT_DOMAIN).': <input type="text" size="35" class="regular-text" value="' . $this->transposh->options->get_msn_key() . '" id="'.MSN_TRANSLATE_KEY.'" name="'.MSN_TRANSLATE_KEY.'"/>'; 
     506 
     507          /** 
     508         * Allow users to insert their own API keys 
     509         */ 
     510        echo '<h4>' . __('Google API key', TRANSPOSH_TEXT_DOMAIN) . '</h4>'; 
     511        echo __('API Key', TRANSPOSH_TEXT_DOMAIN).': <input type="text" size="35" class="regular-text" value="' . $this->transposh->options->get_google_key() . '" id="'.GOOGLE_TRANSLATE_KEY.'" name="'.GOOGLE_TRANSLATE_KEY.'"/>'; 
     512 
    499513        /* 
    500514         * Choose default translator... TODO (explain better in wiki) 
  • trunk/WordPress/plugin/transposh/wp/transposh_options.php

    r653 r664  
    2424define('OLD_ENABLE_MSN_TRANSLATE', 'enable_msntranslate'); 
    2525//Option to store the msn API key 
    26 define('OLD_MSN_TRANSLATE_KEY', 'msn_key'); 
     26define('MSN_TRANSLATE_KEY', 'msn_key'); 
     27//Option to store the msn API key 
     28define('GOOGLE_TRANSLATE_KEY', 'google_key'); 
    2729 
    2830//defines are used to avoid typos 
     
    115117        $this->set_default_option_value(WIDGET_REMOVE_LOGO_FOR_AD); 
    116118        $this->set_default_option_value(WIDGET_THEME, 'ui-lightness'); 
     119        $this->set_default_option_value(MSN_TRANSLATE_KEY); 
     120        $this->set_default_option_value(GOOGLE_TRANSLATE_KEY); 
    117121        $this->set_default_option_value(TRANSPOSH_KEY); 
    118122        $this->set_default_option_value(TRANSPOSH_BACKUP_SCHEDULE); 
     
    142146            unset($this->options[OLD_WIDGET_IN_LIST]); 
    143147            unset($this->options[OLD_WIDGET_STYLE]); 
    144             unset($this->options[OLD_MSN_TRANSLATE_KEY]); 
    145148            unset($this->options[OLD_ENABLE_MSN_TRANSLATE]); 
    146149            logger($this->options); 
     
    229232        // default is true 
    230233        return $this->options[ENABLE_AUTO_TRANSLATE]; 
     234    } 
     235 
     236    function get_msn_key() { 
     237        return $this->options[MSN_TRANSLATE_KEY]; 
     238    } 
     239 
     240    function get_google_key() { 
     241        return $this->options[GOOGLE_TRANSLATE_KEY]; 
    231242    } 
    232243 
     
    377388    } 
    378389 
     390      function set_msn_key($val) { 
     391        $this->set_value($val, $this->options[MSN_TRANSLATE_KEY]); 
     392    } 
     393 
     394          function set_google_key($val) { 
     395        $this->set_value($val, $this->options[GOOGLE_TRANSLATE_KEY]); 
     396    } 
     397 
    379398    function set_enable_auto_post_translate($val) { 
    380399        $val = ($val) ? 1 : 0; 
Note: See TracChangeset for help on using the changeset viewer.