PDA

View Full Version : I need technical help with adding a dictionary



GaryFifer
2nd August 2009, 01:52
As mentioned in computer help Babel fish can be useful for looking up tagalog words. They use Google, Yahoo. Can I somehow program the definitions below to include the tagalog dictionary source http://www.tagalog-dictionary.com/


var bfplugin = {//never change this line



//BabelFish compatibility:
minBFVersion: '1.80',
//Your plugin edit version:
pluginVersion: '1.1',
//Author:
pluginAuthor: 'NettiCat',


//Display name of your service:
service1Name: 'Google',
service2Name: 'Yahoo',
service3Name: 'GoogleDic',



//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
service1URL: '"http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=%s&langpair=%from%7C%to"',
service2URL: '"http://babelfish.yahoo.com/translate_txt?ei=UTF-8&lp=%from_%to&text=%s"',
service3URL: '"http://www.google.com/dictionary?aq=f&hl=en&q=%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: '"http://translate.google.com/translate?hl=%nl&langpair=%from|%to&u=%url"',
service2SiteURL: '"http://babelfish.yahoo.com/translate_url?doit=done&tt=url&intl=1&fr=bf-home&btnTrUrl=Translate&lp=%from_%to&trurl=%url"',



//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
service1LanguageCodes : {
'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'
},



service3LanguageCodes : {
'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'
},



service1ProcessResponse: 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;
},



service3ProcessResponse: function(response){
//your regex rules go here...

response = response.match(/<span class="mn">([^<]+)/gmi);
if(!response)
return '';
response = response.join(",");
response = response.replace(/<[^>]+>/gm, " "); //remove remaining HTML, insert spaces

//...your regex rules end
return response;
},



/*
//User defined function
//To use this function anywhere above you would address it with bfplugin.extraFunction(...)
extraFunction: function(input){
var output = input; //
return output;
},
*/



};//never change this line