balazs-endresz / jquery-translate

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

Cannot get a search-field translated multiple times #38

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have at search-field, that i would like to translate before the search 
is submitted. On the server, the search-string and the translated search-
string are to be combined.

The search is submitted into a html-div using jQuery. 
This means that there is no reloading of the page.

What steps will reproduce the problem?
1. Go to http://dev.scanpix.eu/spdk/index_translate_eksperiment.pl
2. Enter a few words in the search-field (labeled "Søg i nordens største 
billeddatabase - klik her...").
3. Trigger the onChange event by leaving the field.
4. The words are now put into the "In english:" field to the right, and 
translated to english.

5. Change the words in the search-field, and trigger the event again.

What is the expected output? What do you see instead?
I expected the new search-string to be translated. 
Instead no translation seems to happen.

What version of the product are you using? On what operating system?
version: "1.3.9"

Please provide any additional information below.
I've added data: false, and tried adding both fromOriginal : false and 
toggle : false. But none of them seemed to do the trick.

Original issue reported on code.google.com by pierre.husted on 22 Apr 2010 at 10:25

GoogleCodeExporter commented 9 years ago
That's really strange, it didn't work for me either but after reloading the 
page it worked as 
it should then stopped working again.

Could you please include the non-minified version of the plugin?

Here's a quick fix until then:

$('#sog1_trans_en').translate("da","en",{fromOriginal:false, toggle:false, 
complete: 
function(el){
el.val(el.data("translation").en.value);
}})

Original comment by balazs.endresz on 22 Apr 2010 at 2:15

GoogleCodeExporter commented 9 years ago
Did you get it to work more than once without reloading the page??

I'll include the non-minofied tomorrow, and post here when itøs done.

By the way - impressive response-time!!  Thanks!!  :)

Original comment by pierre.husted on 22 Apr 2010 at 3:00

GoogleCodeExporter commented 9 years ago
I've included the non-minified version instead.

Made a new page with your fix - and it WORKS!  :)
http://dev.scanpix.eu/spdk/index_translate_eksperiment2.pl

My first test-page is still there, if you want to have a look
http://dev.scanpix.eu/spdk/index_translate_eksperiment.pl

Let me know (here) if you fix the problem in a future release. 
Otherwise I'll use your fix.

Thanks again!!

Original comment by pierre.husted on 23 Apr 2010 at 1:14

GoogleCodeExporter commented 9 years ago
The problem is that if the new translation has the same language as the 
previous one then the value 
won't be replaced and the `$.translate.replace` functions returns earlier.
I'll add an option for this in the next release sometime, because usually this 
is a good thing, but 
in this case it's certainly not.

If you just remove this:

if(lang === to)
    return;

from that function then it works!

And, btw, in such a simple case, you don't have to include the 
`nodesContainingText` module, the one 
called `nct-adapter` with the `core` works without it as well (or at least I 
hope it still does :).

Original comment by balazs.endresz on 23 Apr 2010 at 2:20

GoogleCodeExporter commented 9 years ago
The fix works great.
And not including nodesContainingText boosted the speed quite a bit.

Thanks a lot once mote.
Great help, great module!!

Original comment by pierre.husted on 26 Apr 2010 at 11:31

GoogleCodeExporter commented 9 years ago

Original comment by balazs.endresz on 19 Aug 2010 at 8:10

GoogleCodeExporter commented 9 years ago
Fixed in v1.4.7, so now on you can just set the `alwaysReplace` option to true.

Original comment by balazs.endresz on 20 Aug 2010 at 8:26

GoogleCodeExporter commented 9 years ago
Issue 58 has been merged into this issue.

Original comment by balazs.endresz on 29 Nov 2010 at 4:06