0

I've got an issue that must come from my side but turning me crazy :-p

When I'm in development environment, I've to put these lines in application.html.erb to have I18n.js working :

<%= javascript_include_tag "i18n" %>
<%= javascript_include_tag "translations" %>

The problem is that on production environment, it doesn't work (it doesn't found the i18n.js, 404, I know that's normal, due to the assets pipeline), I've to put these lines in application.js :

//= require i18n
//= require i18n/translations

But if I leave these like that, I've got an error in development environment : uninitialized constant SimplesIdeias

It works for all the rest of my scripts, only i18n.js got a problem to load.

What is the way to make them both works ? :p

Louis Borsu
  • 135
  • 1
  • 2
  • 10
  • 1
    Why are you using JavaScript to translate your website? Rails has a nice built-in i18n module. – Mulan Aug 26 '13 at 08:35
  • Because, I've one div that is completely generated by javascript. – Louis Borsu Aug 26 '13 at 18:13
  • that doesn't make any sense. Even if you're using JavaScript, you should still be using `I18n.t` to generate the content that the JavaScript is outputting. – Mulan Aug 26 '13 at 18:18
  • Yes, but I18n is a Ruby rails that doesn't work in `.js` files even if It use a `.js.erb` extension. Then I needed to have this function callable in Javascript, so I've added this script to can use `I18n.t` (a JS function) The Ruby gem is callable by `t('blabla')`. – Louis Borsu Aug 27 '13 at 08:06
  • It just sounds like you're doing something incredibly wrong. If you want to load content with JavaScript, just make an ajax request to the server, have the server respond with a piece of translated HTML, have JavaScript insert the HTML into the DOM. – Mulan Aug 27 '13 at 14:31
  • ps Your question is asking how to make your solution work when you should be asking how to solve your original problem. Show us code relevant to the issue you are trying to solve, not code for a solution you think will solve it. Example wrong question: "Why doesn't this regex work?"; correct question: "How to extract text from HTML?" – Mulan Aug 27 '13 at 14:44

0 Answers0