Pengguna:Endo999/GoogleTrans.js: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
Endo999 (bicara | kontrib)
new languages, including sundanese and javanese as well as Indonesian
Endo999 (bicara | kontrib)
Membalikkan revisi 8341235 oleh Endo999 (bicara)link problem
Baris 43:
var SCLanguageDefaultTo = SCLanguageTo;
var SCLanguageDefaultFrom='id';
 
var SCRomanisationUrl = "https://www.securecottage.com/cgi-bin/pinyin.cgi";
 
if(document.location.protocol.match(/http:/i))
SCRomanisationUrl = "http://www.securecottage.com/cgi-bin/pinyin.cgi"; // jive with the http/https scheme of the url
 
// if your wiki language doesn't use the roman alphabet you may want to turn SCdoRomanisation to true. However, every request will be going to
// the third party script above. It is quite helpful to know the Roman pronounciation of a word in a NonRoman alphabet at times.
// this will mostly effect Asian languages.
var SCdoRomanisation = false;
 
var SCGoogleTransPersistString = 'GoogleTrans';
Baris 110 ⟶ 99:
 
var SCbIsIE11 = false;
if(navigator.appVersion.match(/Trident.*rv[: ]([0-9][0-9])\./i))
{
var version1 = new Number(RegExp.$1);
Baris 267 ⟶ 256:
// list made 8/10/2011
// may have to remake list if Indian regional languages become supported.
// manipulating the following 4 arrays is all that is necessary to add a Google language to the GoogleTrans gadget
 
// keep alphabetic
 
var SCGoogleLanguageNames = [
'Afrikaans',
Baris 284 ⟶ 269:
'Catalan',
'Cebuano',
 
'Chickewa',
'Chinese (traditional)',
'Chinese (simplified)',
Baris 317 ⟶ 300:
'Javanese',
'Kannada',
 
'Kazakh',
'Khmer',
'Korean',
Baris 326 ⟶ 307:
'Lithuanian',
'Macedonian',
 
'Malagasy',
'Malay',
 
'Malayalam',
'Maltese',
'Marathi',
'Maori',
'Mongolian',
 
'Myanmar',
'Nepali',
'Norwegian',
Baris 346 ⟶ 321:
'Russian',
'Serbian',
 
'Sesotho',
 
'Sinhala',
'Slovak',
'Slovenian',
'Somali',
'Spanish',
 
'Sundanese',
'Swahili',
'Swedish',
 
'Tajik',
'Tamil',
'Telugu',
Baris 366 ⟶ 333:
'Ukrainian',
'Urdu',
 
'Uzbek',
'Vietnamese',
'Welsh',
Baris 374 ⟶ 339:
'Zulu'
];
 
// this array must be in the same order as the array above (SCGoogleLanguageNames)
// that is, the language code in this array must have the same index as the language name in SCGoogleLanguageNames
var SCGoogleLanguageCodes = [
'af',
Baris 390 ⟶ 352:
'ca',
'ceb',
'ny',
'zh-TW',
'zh-CN',
Baris 421 ⟶ 382:
'ja',
'jv',
 
'kn',
'kk',
'km',
'ko',
Baris 431 ⟶ 390:
'lt',
'mk',
 
'mg',
 
'ms',
 
'ml',
 
'mt',
'mr',
'mi',
'mn',
 
'my',
'ne',
'no',
Baris 453 ⟶ 404:
'ru',
'sr',
 
'st',
'si',
 
'sk',
'sl',
'so',
'es',
 
'su',
'sw',
'sv',
 
'tg',
'ta',
'te',
Baris 473 ⟶ 416:
'uk',
'ur',
 
'uz',
'vi',
'cy',
Baris 481 ⟶ 422:
'zu'
];
 
// keep alphabetic by language name
var SCnewoptions =
'<option value="af">Afrikaans</option>'+
Baris 496 ⟶ 435:
'<option value="ca">Catalan</option>'+
'<option value="ceb">Cebuano</option>'+
'<option value="ny">Chickewa</option>'+
'<option value="zh-TW">Chinese (traditional)</option>'+
'<option value="zh-CN">Chinese (simplified)</option>'+
Baris 528 ⟶ 466:
'<option value="jv">Javanese</option>'+
'<option value="kn">Kannada</option>' +
'<option value="kk">Kazakh</option>'+
'<option value="km">Khmer</option>' +
'<option value="ko">Korean</option>' +
Baris 536 ⟶ 473:
'<option value="lt">Lithuanian</option>'+
'<option value="mk">Macedonian</option>'+
'<option value="mg">Malagasy</option>'+
'<option value="ms">Malay</option>'+
'<option value="ml">Malayalam</option>'+
'<option value="mt">Maltese</option>'+
'<option value="mi">Maori</option>'+
'<option value="mr">Marathi</option>'+
'<option value="mn">Mongolian</option>'+
'<option value="my">Myanmar</option>'+
'<option value="ne">Nepali</option>'+
'<option value="no">Norwegian</option>'+
Baris 553 ⟶ 487:
'<option value="ru">Russian</option>'+
'<option value="sr">Serbian</option>'+
'<option value="st">Sesotho</option>'+
'<option value="si">Sinhali</option>'+
'<option value="sk">Slovak</option>'+
'<option value="sl">Slovenian</option>'+
'<option value="es">Spanish</option>'+
'<option value="so">Somali</option>'+
'<option value="su">Sundanese</option>'+
'<option value="sw">Swahili</option>'+
'<option value="sv">Swedish</option>'+
'<option value="tg">Tajik</option>'+
'<option value="ta">Tamil</option>' +
'<option value="te">Telugu</option>' +
Baris 569 ⟶ 499:
'<option value="uk">Ukrainian</option>'+
'<option value="ur">Urdu</option>'+
'<option value="uz">Uzbek</option>'+
'<option value="vi">Vietnamese</option>'+
'<option value="cy">Welsh</option>'+
Baris 577 ⟶ 506:
;
 
// doesn't have to be alphabetic, can just dump new language codes at end of array
var SCTranslateableLanguages = [
'af',
Baris 659 ⟶ 587:
'so',
'yo',
'zu',
'ny',
'kk',
'mg',
'ml',
'my',
'st',
'si',
'su',
'tg',
'uz'
];
 
// if romanisation is on this array is consulted to see whether the language is of the roman alphabet. if so, romansation is not performed.
var SCRomanAlphabetLanguages = [
'en',
'af',
'sq',
'bg',
'bs',
'ca',
'ceb',
'hr',
'cs',
'da',
'nl',
'eo',
'et',
'tl',
'fi',
'fr',
'gl',
'ka',
'de',
'ht',
'ha',
'hmn',
'hu',
'is',
'ig',
'id',
'ga',
'it',
'jv',
'la',
'lv',
'lt',
'mk',
'ms',
'mt',
'mi',
'no',
'pl',
'pt',
'ro',
'sk',
'sl',
'so',
'es',
'sw',
'sv',
'tr',
'vi',
'cy',
'yo',
'zu',
 
'ny',
'mg',
'st',
'su',
'uz'
 
];
function SCIsRomanAlphabetLanguage(lang)
{
var i;
for(i=0;i<SCRomanAlphabetLanguages.length;i++)
{
if(lang == SCRomanAlphabetLanguages[i])
return true;
}
return false;
}
 
function SCMakeGoogleLanguages()
Baris 1.065 ⟶ 909:
}
SCbIsIE11 = false;
if(navigator.appVersion.match(/Trident.*rv[: ]([0-9][0-9])\./i))
{
var version1 = new Number(RegExp.$1);
Baris 3.533 ⟶ 3.377:
}
}
var SCTranslatedFromLanguage="";
 
 
var SCTranslatedFromLanguage="";
function SCTranslatedText(response) {
// if (result.translation||result.error)
if(response.error && SCtranslateFrom!=SCTranslatedFromLanguage )
{
SCGoogleDetectV2(SCtext);
if(SCtranslateFrom != SCTranslatedFromLanguage)
{
SCtranslateFrom = SCTranslatedFromLanguage;
SCgoogleLookup(SCtext,SClabel);
}
return;
}
else if(response.error)
return;
{
var nbspstr = "";
var i;
var SClanguagestrlength = SCGetGoogleLanguage(SCtranslateTo).length + 10;
if(SClanguagestrlength < SCSourcestrlength)
SClanguagestrlength = SCSourcestrlength+10;
// if(result.translation)
{
for(i=response.data.translations[0].translatedText.length;i<SClanguagestrlength;i++)
{
nbspstr+="&nbsp;";
}
}
var pretranslatedword = "";
var numofwords = SClinkword.split(/\s/).length;
if(response.data && response.data.translations)
{
SCTranslatedFromLanguage=response.data.translations[0].detectedSourceLanguage;
if(SCdoRomanisation && !SCIsRomanAlphabetLanguage(SCTranslatedFromLanguage))
SCimportScriptURI(SCRomanisationUrl+"?label="+SClabel+"&lang="+SCTranslatedFromLanguage+"&words="+encodeURIComponent(SClinkword));
if(SCdoRomanisation && !SCIsRomanAlphabetLanguage(SCtranslateTo))
SCimportScriptURI(SCRomanisationUrl+"?label="+SClabel+"&lang="+SCtranslateTo+"&words="+encodeURIComponent(SCtext));
}
if(numofwords == 1)
pretranslatedword = SClinkword + ": ";
// var insertstring = SClabel + '|' + SCtext + '|' +
var insertstring = SClanguageprompt1 + '-> ' + SCGetGoogleLanguage(SCtranslateTo) + SClanguageprompt2 + SCgooglereference2 + SClabel + SCgooglereference3;
var respDiv = $( '<div class="SCxText"></div>' );
var respText = ((response.data) ? (pretranslatedword + response.data.translations[0].translatedText) : response.error.message);
respDiv.text( respText );
insertstring += respDiv.wrap('<div></div>')[0].outerHTML;
insertstring += '<div><br>' + SCgooglereference4 + SCgooglereference1 + SCgoogletranslate + SCgooglereference1a + ((numofwords > 1) ? SCnextsentencestr : "") + '</div>';
SCInsertTranslation(SClabel,SCtext,insertstring);
}
}
 
function SColdTranslatedText(response) {
// if (result.translation||result.error)
Baris 3.631 ⟶ 3.411:
var pretranslatedword = "";
var numofwords = SClinkword.split(/\s/).length;
 
 
 
 
if(numofwords == 1)
pretranslatedword = SClinkword + ": ";