分类: 系统运维
2010-07-11 14:36:12
var bfplugin = {//never change this line //BabelFish compatibility: minBFVersion: '1.86', //Your plugin edit version: pluginVersion: '1.2', //Author: pluginAuthor: 'NettiCat', //Display name of your service: service3Name: 'Google', service2Name: 'Yahoo', service1Name: 'GoogleDic', detectionName: 'Google', //URL to get the text translation (enclose in outer single '' AND inner double ""): //placeholder for the text to translate is %s //placeholder for source language code is %from //placeholder for target language code is %to service3URL: '"%s&langpair=%from%7C%to"', service2URL: '"%from_%to&text=%s"', service1URL: '"%s&langpair=%from%7C%to"', //URL to translate a whole page (enclose in outer single '' AND inner double ""): //placeholder for the site to translate is %url //placeholder for source language code is %from //placeholder for target language code is %to //placeholder for browser language code is %nl service1SiteURL: '"%nl&langpair=%from|%to&u=%url"', service2SiteURL: '"%from_%to&trurl=%url"', //URL to detect a language (enclose in outer single '' AND inner double ""): //placeholder for the text is %s detectionURL: '"%s"', //Maximum text-length accepted by service, otherwise text is splitted: service1MaxLength: 300, service2MaxLength: 1000, //Language codes used in the service URL (with %from or %to): //Remove languages not supported by your service //Change the short language codes on the right to those used by your service service3LanguageCodes : { 'auto' : '', 'Albanian' : 'sq', 'Arabic' : 'ar', 'Bulgarian' : 'bg', 'Catalan' : 'ca', 'Chinese[S]' : 'zh-CN', 'Chinese[T]' : 'zh-TW', 'Croatian' : 'hr', 'Czech' : 'cs', 'Danish' : 'da', 'Dutch' : 'nl', 'English' : 'en', 'Estonian' : 'et', 'Filipino' : 'tl', 'Finnish' : 'fi', 'French' : 'fr', 'Galician' : 'gl', 'German' : 'de', 'Greek' : 'el', 'Hebrew' : 'iw', 'Hindi' : 'hi', 'Hungarian' : 'hu', 'Indonesian' : 'id', 'Italian' : 'it', 'Japanese' : 'ja', 'Korean' : 'ko', 'Latvian' : 'lv', 'Lithuanian' : 'lt', 'Maltese' : 'mt', 'Norwegian' : 'no', 'Polish' : 'pl', 'Portuguese' : 'pt', 'Romanian' : 'ro', 'Russian' : 'ru', 'Serbian' : 'sr', 'Slovak' : 'sk', 'Slovenian' : 'sl', 'Swedish' : 'sv', 'Spanish' : 'es', 'Thai' : 'th', 'Turkish' : 'tr', 'Ukrainian' : 'uk', 'Vietnamese' : 'vi' }, service2LanguageCodes : { 'Chinese[S]' : 'zh', 'Chinese[T]' : 'zt', 'Dutch' : 'nl', 'English' : 'en', 'French' : 'fr', 'German' : 'de', 'Greek' : 'el', 'Italian' : 'it', 'Japanese' : 'ja', 'Korean' : 'ko', 'Portuguese' : 'pt', 'Russian' : 'ru', 'Spanish' : 'es' }, service1LanguageCodes : { 'Albanian' : 'sq', 'Arabic' : 'ar', 'Bulgarian' : 'bg', 'Catalan' : 'ca', 'Chinese[S]' : 'zh-CN', 'Chinese[T]' : 'zh-TW', 'Croatian' : 'hr', 'Czech' : 'cs', 'Danish' : 'da', 'Dutch' : 'nl', 'English' : 'en', 'Estonian' : 'et', 'Filipino' : 'tl', 'Finnish' : 'fi', 'French' : 'fr', 'Galician' : 'gl', 'German' : 'de', 'Greek' : 'el', 'Hebrew' : 'iw', 'Hindi' : 'hi', 'Hungarian' : 'hu', 'Indonesian' : 'id', 'Italian' : 'it', 'Japanese' : 'ja', 'Korean' : 'ko', 'Latvian' : 'lv', 'Lithuanian' : 'lt', 'Maltese' : 'mt', 'Norwegian' : 'no', 'Polish' : 'pl', 'Portuguese' : 'pt', 'Romanian' : 'ro', 'Russian' : 'ru', 'Serbian' : 'sr', 'Slovak' : 'sk', 'Slovenian' : 'sl', 'Swedish' : 'sv', 'Spanish' : 'es', 'Thai' : 'th', 'Turkish' : 'tr', 'Ukrainian' : 'uk', 'Vietnamese' : 'vi' }, service3ProcessResponse: function(response){ //your regex rules go here... response = eval( "(" + String(response) + ")" ); if(!response.responseData || !response.responseData.translatedText) return ''; response = response.responseData.translatedText; //...your regex rules end return response; }, service2ProcessResponse: function(response){ //your regex rules go here... response = response.match(/v style="padding:0.6em;">[^<]+/mi); if(!response) return ''; response = response[0].replace(/.*>/m, ""); //remove remaining HTML //...your regex rules end return response; }, service1ProcessResponse: function(response){ //your regex rules go here... var answer = response.match(/"dct\-em"[^<]+([^<]+)/gmi); if(!answer) answer = response.match(/([^<]+)/gmi); if(!answer) return ''; answer = answer.join(","); answer = answer.replace(/("dct\-em"[^<]+)?<[^>]+>/gm, " "); //remove remaining HTML, insert spaces //...your regex rules end return answer; }, /* //User defined function //To use this function anywhere above you would address it with bfplugin.extraFunction(...) extraFunction: function(input){ var output = input; // return output; }, */ //Language codes used by language detection: //Change the short language codes on the right to those sent by your language detection service detectionLanguageCodes : { 'AFRIKAANS' : 'af', 'ALBANIAN' : 'sq', 'AMHARIC' : 'am', 'ARABIC' : 'ar', 'ARMENIAN' : 'hy', 'AZERBAIJANI' : 'az', 'BASQUE' : 'eu', 'BELARUSIAN' : 'be', 'BENGALI' : 'bn', 'BIHARI' : 'bh', 'BULGARIAN' : 'bg', 'BURMESE' : 'my', 'CATALAN' : 'ca', 'CHEROKEE' : 'chr', 'CHINESE' : 'zh', 'CHINESE[S]' : 'zh-CN', 'CHINESE[T]' : 'zh-TW', 'CROATIAN' : 'hr', 'CZECH' : 'cs', 'DANISH' : 'da', 'DHIVEHI' : 'dv', 'DUTCH': 'nl', 'ENGLISH' : 'en', 'ESPERANTO' : 'eo', 'ESTONIAN' : 'et', 'FILIPINO' : 'tl', 'FINNISH' : 'fi', 'FRENCH' : 'fr', 'GALICIAN' : 'gl', 'GEORGIAN' : 'ka', 'GERMAN' : 'de', 'GREEK' : 'el', 'GUARANI' : 'gn', 'GUJARATI' : 'gu', 'HEBREW' : 'iw', 'HINDI' : 'hi', 'HUNGARIAN' : 'hu', 'ICELANDIC' : 'is', 'INDONESIAN' : 'id', 'INUKTITUT' : 'iu', 'ITALIAN' : 'it', 'JAPANESE' : 'ja', 'KANNADA' : 'kn', 'KAZAKH' : 'kk', 'KHMER' : 'km', 'KOREAN' : 'ko', 'KURDISH': 'ku', 'KYRGYZ': 'ky', 'LAOTHIAN': 'lo', 'LATVIAN' : 'lv', 'LITHUANIAN' : 'lt', 'MACEDONIAN' : 'mk', 'MALAY' : 'ms', 'MALAYALAM' : 'ml', 'MALTESE' : 'mt', 'MARATHI' : 'mr', 'MONGOLIAN' : 'mn', 'NEPALI' : 'ne', 'NORWEGIAN' : 'no', 'ORIYA' : 'or', 'PASHTO' : 'ps', 'PERSIAN' : 'fa', 'POLISH' : 'pl', 'PORTUGUESE' : 'pt-PT', 'PUNJABI' : 'pa', 'ROMANIAN' : 'ro', 'RUSSIAN' : 'ru', 'SANSKRIT' : 'sa', 'SERBIAN' : 'sr', 'SINDHI' : 'sd', 'SINHALESE' : 'si', 'SLOVAK' : 'sk', 'SLOVENIAN' : 'sl', 'SPANISH' : 'es', 'SWAHILI' : 'sw', 'SWEDISH' : 'sv', 'TAJIK' : 'tg', 'TAMIL' : 'ta', 'TAGALOG' : 'tl', 'TELUGU' : 'te', 'THAI' : 'th', 'TIBETAN' : 'bo', 'TURKISH' : 'tr', 'UKRAINIAN' : 'uk', 'URDU' : 'ur', 'UZBEK' : 'uz', 'UIGHUR' : 'ug', 'VIETNAMESE' : 'vi', 'UNKNOWN' : '' }, };//never change this line |