berk / tr8n

This repository has moved to:
https://github.com/tr8n/tr8n
MIT License
280 stars 37 forks source link

Various JavaScript errors #42

Open hinrik opened 12 years ago

hinrik commented 12 years ago

I see you recently did a major overhaul of Tr8n's Javascript component. It looks like some things were broken by it.

I noticed that the app/views/tr8n/language/select.html.erb template (which is included by tr8n_language_selector_tag) has different content compared to the app/views/tr8n/language/_select.html.erb partial. I experimented with removing all the content from the template and just rendering the _select partial from there. That made the "Translation tools" link work, but it broke the "Enable inline translation" link even more (now I just get "hideLightbox is not defined").

iakona commented 12 years ago

For javascript, has anyone gotten dynamic translation working?

I've tried something along the lines of this where I have an anchor tag that when clicked does this function. I pass the text of what I want to be translated as a parameter.

function myFunction2(textToSay) { s = $("<%= tr("{text2Say}", "Message", {:text2Say => textToSay}, {:locale => "en-US"}) %>").text(); alert(s); }

Also wondering if anyone has buttons working

Right now I have something like this

The button name will be translated, and the name will be underlined when in-line is on, but when I right click on it, nothing happens

berk commented 12 years ago

hinrik, I am still working on the JavaScript. It is mostly done, but there are still a few minor things that need to be taken care of.

iakona, JavaScript Client SDK has the same tr method as the server side. So all you need to do is:

alert(tr("Hello World"));

In your example you are mixing server side code with client side - that wouldn't work.

I will document the JS Client SDK once i am done with all of the code changes.

Btw, those changes will now allow you to run tr8n as a separate server instance in parallel to your site. So you could translate more than one site using a single server instance. Or you can choose to continue running tr8n as a plugin.