balazs-endresz / jquery-translate

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

Only one request #72

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
jquery-translate version: trunk
jQuery version: 1.5
browser: FF5
OS: WinXP

I have quite a large page I am trying to translate.
The code I use:
  jQuery(document).ready(function() {
    jQuery.translate.load('XXXXXXX')
    jQuery('#content').translateTextNodes('pl','en', {async:true});
  });

The problem is, only one request to the translating service gets send each time 
I open the page, this means that translation doeas work, but it only translates 
one fragments, in my case header and first row of a table, not the rest of the 
page.

Tried both Google and Bing, read through wiki and issues but I can't seem to 
get the solution.

Am I missing something? How do I translate entire page, revursively, using 
multiple requests to the trasnlation service.

Thank you for your time, and for this great plugin, I just hope I'll get it 
work as I expect.

Original issue reported on code.google.com by jacek.ko...@dyrygent.pl on 24 Sep 2011 at 1:50

GoogleCodeExporter commented 9 years ago
Sorry, but without seeing the actual page I can't say too much. You can email 
it to me if it's not public.

Original comment by balazs.endresz on 24 Sep 2011 at 2:38

GoogleCodeExporter commented 9 years ago
Thank you for such a quick reply.

http://realcorp.pl/translate/

I made a static copy of an example page from the site. Stripped down all the 
CSS and JS.
The original site is Joomla! generated, but I don't think that has anything to 
do with the issue, since inside Joomla! the problem is exactly the same - only 
header of te table gets translated.

Original comment by jacek.ko...@dyrygent.pl on 24 Sep 2011 at 2:46

GoogleCodeExporter commented 9 years ago
This issue has already come up before, it looks like haven't fixed it yet. The 
< signs cause some problems because the plugin needs to detect if there's some 
broken html tags in the text because then it has to be cut before those, in 
order to stay below the per request character limit. Now that's actually more 
complicated than it sounds, and I couldn't find a way around it yet.

For your page something like this should work though:

jQuery(".auction_price_bold").each(function(){
  var $this = jQuery(this);
  $this.text( $this.text().replace("<","") );
});

jQuery("body").translateTextNodes("pl", "en", function(){
  jQuery(".auction_price_bold").each(function(){
    var $this = jQuery(this);
    $this.text( "<" + $this.text() );
  });
});

or maybe just this: 

jQuery("body").translate("pl", "en", {not:".auction_price_bold"});

But there's an exception thrown, and I don't why because the JavaScript is 
minified on the page!

Original comment by balazs.endresz on 24 Sep 2011 at 4:53

GoogleCodeExporter commented 9 years ago
Thank you very much! It's a lifesaver.

Original comment by jacek.ko...@dyrygent.pl on 26 Sep 2011 at 9:04