Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various JavaScript errors #42

Open
hinrik opened this issue May 22, 2012 · 2 comments
Open

Various JavaScript errors #42

hinrik opened this issue May 22, 2012 · 2 comments

Comments

@hinrik
Copy link
Contributor

hinrik commented May 22, 2012

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

  • When I toggle inline translations in the language selector, I get the lightbox telling me that it enabled inline translation and then the page reloads. However, inline translations are not actually enabled. The page looks exactly the same and the link in the language selector still says "Enable inline translation".
  • The "Translation tools" link in the language selector does not work anymore. Firebug's console gives me "Tr8n.UI.LanguageSelector.showDashboard is not a function".

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
Copy link

iakona commented Jun 6, 2012

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

<%= tr("Hello World") %>

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
Copy link
Owner

berk commented Jun 25, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants