balazs-endresz/jquery-translate

Bing API ID Throwing Error

GoogleCodeExporter opened this issue · 4 comments

jquery-translate version: jquery.translate-1.4.7-debug-all
jQuery version: jQuery JavaScript Library v1.6.1
browser: Opera, but others as well
OS: Windows 7


URL of the page, with non-minified JavaScript, http://jsfiddle.net/qV9zx/
can be used too: www.twfarmreport.com

Is it due to me using the minified version? (jquery.min.js)

What steps will reproduce the problem?
1.Go To www.twfarmreport.com
2.Choose a different language from the flag drop down on the right hand side.
3. Click OK to the pop to translate, translation doesn't happen.

What is the expected output? What do you see instead?

Currently only set to translated (To Test):
"What is this site trying to accomplish? Increasing your tribal wars farming 
efficiency to get more resources per hour! 
 If you have a problem or find a bug please check out the help pages and forums for help. If you love this site please donate!"

Doesn't translate, nothing happens and I cannot see an error in the debug 
console.

Please provide any additional information below.

My Script Is:
$.getScript('http://www.twfarmreport.com/jquery.min.js', function(){
$.getScript('http://www.twfarmreport.com/jquery.translate-1.4.7-debug-all.js', 
function(){
var lang1 = $("#ctrlUserMenu_imgFlag").attr('alt');
var lang2 = 'text';
var lang3 = localStorage.getItem("lang");
var lang4 = localStorage.getItem("lang2");
var tran = localStorage.getItem("trans");
var n = '1';
if (lang1 == 'en' | lang1 == 'uk' | lang1 == 'us' | lang1 == 'zz' | lang1 == 
'ts') {lang2 = 'en';n = '0';}
else if (lang1 == 'br') {lang2 = 'pt';}
else if (lang1 == 'ae') {lang2 = 'ar';}
else if (lang1 == 'ch') {lang2 = 'de';}
else if (lang1 == 'gr') {lang2 = 'el';}
else if (lang1 == 'kr') {lang2 = 'ko';}
else if (lang1 == 'dk') {lang2 = 'da';}
else if (lang1 == 'ba') {lang2 = 'sr';}
else if (lang1 == 'si') {lang2 = 'sl';}
else if (lang1 == 'il') {lang2 = 'iw';}
else if (lang1 == 'jp') {lang2 = 'ja';}
else {lang2 = lang1;}
url = document.URL;
if (url.search(/Login/i) != -1){localStorage.clear();}
if (tran != 'true' && lang4 != lang2  && lang3 == 'en'){localStorage.clear();}
if (tran != 'false' && lang3 != lang2){localStorage.clear();}
if (n == '1')
    { 
    if (localStorage.getItem("lang") == null)
        {
         if (!confirm('Translate To Server Language?')) 
            {
            localStorage.setItem("lang2", lang2);
            lang2 = 'en';
            localStorage.setItem("trans", 'false');
            localStorage.setItem("lang", lang2);
            }
         else
            {
             localStorage.setItem("trans", 'true');
             localStorage.setItem("lang", lang2);
            }
        }
    else 
        {
        localStorage.setItem("lang", lang3);
        lang2 = lang3;
        }
    }
bing='301C79ACA55C1ECCD790B3131DE91DFA1205895A';$.translate.load(bing);
$('.ctrlGreeting_lblDefaultInstructions').translate('en', lang2);    

                   });
});

If I use:
$.translate.load(301C79ACA55C1ECCD790B3131DE91DFA1205895A);
Jquery throws the following error:identifier starts immediately after numeric 
literal

Original issue reported on code.google.com by twfarmre...@gmail.com on 3 Dec 2011 at 10:12

To try and get it working with the bing API I simplified it back to one of your 
previous examples:

$.getScript('http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', 
function(){
$.getScript('http://code.google.com/p/jquery-translate/source/browse/trunk/jquer
y.translate-debug-all.js', function(){ 

$.translate.load('301C79ACA55C1ECCD790B3131DE91DFA1205895A');

$.translate(function(){
  $.translate('some text to translate', 'en', 'de', function(translation){ alert(translation); })
})

});
});

This gives me the following error:

$.translate is undefined
[Break On This Error] 
$.translate.load('301C79ACA55C1ECCD790B3131DE91DFA1205895A'); 

Not sure what I am doing wrong now :(

Original comment by twfarmre...@gmail.com on 5 Dec 2011 at 8:27

[deleted comment]
Use the latest version from the trunk!

And this: $.translate.load(301C79ACA55C1ECCD790B3131DE91DFA1205895A);
is not valid JavaScript, you have to put the ID in quotes.

Also, you can map the language codes more easily like this:

//keys must be lower case, and values must equal to a 
//language code specified in the Language API
$.extend($.translate.languageCodeMap, {
  "ae": "ar",
  "ch": "de"
});

Original comment by balazs.endresz on 5 Dec 2011 at 12:24

  • Changed state: Invalid
You are loading jQuery with an other version of jQuery, you should skip that 
step.

Original comment by balazs.endresz on 6 Dec 2011 at 7:34