balazs-endresz / jquery-translate

Automatically exported from code.google.com/p/jquery-translate
5 stars 5 forks source link

not: and walk: false not working together #41

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Trying to translate a page using both "not:" and "walk: false" parameters in 
the same translate call.

What is the expected output? What do you see instead?
I expected elements excluded by the not: parameter to be left not translated, 
instead they get translated.

What version of the product are you using? On what operating system?
jquery.translate-1.4.6.min.js (with everything included)
jquery-1.4.2.min.js

Original issue reported on code.google.com by b.d.abko...@gmail.com on 8 Jul 2010 at 11:44

GoogleCodeExporter commented 9 years ago
Currently you have to add a "notranslate" class manually for those elements: 
http://googlewebmastercentral.blogspot.com/2008/10/helping-you-break-language-ba
rrier.html
either in the html or like this: 

//add "notranslate" classes only once
var $toTranslate = 
$(".toTranslate").find("exlude_these").addClass("notranslate").end();
//then translate it without the `not` option:
$toTranslate.translate(...)

Sure, it would be easier if this happened automatically, but that might impact 
performance unnecessarily.

Original comment by balazs.endresz on 8 Jul 2010 at 3:47

GoogleCodeExporter commented 9 years ago
Unfortunately, it does not seem to work. 
I have element:

<span class = "notranslate">raz dwa trzy</span>

and it gets translated to:

<span class="notranslate">one two three</span>

regardless of walk setting. It works only with walk: true and not: 
".notranslate".

My code:
    function translateTo(destLang)
    {
      $.cookie('trans', destLang);
      $('#language img').removeClass('hover');
      $('#'+destLang+' img').addClass('hover');
      $('body').translate( 'pl', destLang, 
      {
        //not:".notranslate",
        toggle: true,
        walk: false,
        complete: function()
        {

        }
      });
    }

Original comment by b.d.abko...@gmail.com on 9 Jul 2010 at 7:15

GoogleCodeExporter commented 9 years ago
Are you sure? Could you send a link to the page? It works for me.

Original comment by balazs.endresz on 9 Jul 2010 at 11:57

GoogleCodeExporter commented 9 years ago
The site is http://panoramy.pl/index_tr4.php

Please note the flag titles. The idea is to keep them in English. They are in a 
div with class="notranslate", but still get translated on language change. I 
also tried giving each img class="notranslate" but it didn't work either.

Don't get confused by the dropdown on the top staying in English. It's just a 
nasty hack forcing it to reload each time.

Thanks for your help.

Original comment by b.d.abko...@gmail.com on 9 Jul 2010 at 12:54

GoogleCodeExporter commented 9 years ago
It's a bug in the language API: it translates all attributes anyway:
google.language.translate('<span class="notranslate"><span title="raz dwa 
trzy"></span></span>', 'en', 'pl', function(r){alert(r.translation)});

Here you can file a bug: http://code.google.com/p/google-ajax-apis/issues/list

Also, this works as expected: 
google.language.translate('<span class="notranslate">raz dwa trzy</span>', 
'pl', 'en', function(r){alert(r.translation)});

Original comment by balazs.endresz on 9 Jul 2010 at 3:06

GoogleCodeExporter commented 9 years ago

Original comment by balazs.endresz on 9 Jul 2010 at 3:06

GoogleCodeExporter commented 9 years ago

Original comment by balazs.endresz on 9 Jul 2010 at 3:07

GoogleCodeExporter commented 9 years ago
In my last comment languages are in the wrong order, correctly:

the title here translates though it shouldn't:

google.language.translate('<span class="notranslate"><span title="raz dwa 
trzy"></span></span>', 'pl', 'en', function(r){alert(r.translation)});

this works as expected, the text is not translated: 

google.language.translate('<span class="notranslate">raz dwa trzy</span>', 
'pl', 'en', function(r){alert(r.translation)});

Original comment by balazs.endresz on 13 Jan 2011 at 10:09