Closed chickensmitten closed 9 years ago
I'd try precompiling the assets and re-deploying.
RAILS_ENV=production bin/rake assets:precompile
If that doesn't help try inspecting the I18n
javascript object in console to see what you have there.
Mine looks like this:
> I18n
Object {defaultLocale: "en", fallbacks: true, defaultSeparator: ".", locale: "en"...}
> I18n.translations
Object {en: Object, de: Object, el: Object, es: Object, nl: Object…}
> I18n.translations.en
Object {date: Object, time: Object, support: Object, number: Object, errors: Object…}
So, I ran RAILS_ENV=production bin/rake assets:precompile in my OSX terminal, then commit to git and push to heroku, restart heroku and open. But problem persist.
As for the inspection method, I am not sure if I know how to do it, can you provide a guide on how to inspect the javascript object? Thank you for your patience.
Sure, open up dev tools and switch to console tab. https://developer.chrome.com/devtools
Then type in I18n
, hit enter, type in I18n.translations
, hit enter, type in I18n.translations.en
hit enter and paste here the result.
Just to be sure, did you git commit the changes before pushing to heroku?
Owh, right, web inspector. Cool, now I understand. Yeah, Have not really touched javascript other than bootstrap.
Yes, I have commit to git before pushing to heroku.
Here is my output.
I18n Object {defaultLocale: "en", fallbacks: true, defaultSeparator: ".", locale: "en", PLACEHOLDER: /(?:{{|%{)(.*?)(?:}}?)/gm…} I18n.translations Object {} I18n.translations.en undefined
Hi, any advise or references that will help to resolve this? Thanks.
No ida, but you can try my branch and see if that works for you:
https://github.com/hakunin/fulcrum
Try the master branch, or the digitalocean
one.
Tried both, problem persists. Will check for other sources for help.
I have the exact same issue as @chickensmitten. I will try to empty the cache as proposed in #226 and report back.
Hi baschtl, did you manage to resolve this?
@chickensmitten I cleared the cache and precompiled the assets again. But the issue remains. :-/
I think I somehow found the issue.
https://github.com/fulcrum-agile/fulcrum/blob/master/app/assets/javascripts/locales.js.erb#L1 should load the translations into a Javascript object. However, this object is empty as we have seen.
Hence, I looked into I18n.backend.send(:translations).to_json.html_safe
. To my surprise I18n.backend.translations
returned {}
. I then called I18n.backend.load_translations
. Then, I18n.backend.translations
was filled with actual translations.
Could someone double check this? Why does this work for some people and not for us?
Cheers
BTW
As a side note http://guides.rubyonrails.org/i18n.html mentions the following:
The backend will lazy-load these translations when a translation is looked up for the first time. This makes it possible to just swap the backend with something else even after translations have already been announced.
Is it possible that when this Javascript object I18n.translations
should be initialized the Rails I18n backend ha not yet loaded the translations because it does this in a lazy way?
Thats why I did this to make it work: https://github.com/fulcrum-agile/fulcrum/pull/235/files
Can you check out my branch to see if it helps?
@hakunin I have not tried it, yet. However, this should do the trick as init_translations
internally triggers load_translations
.
What I don't get is: why do you have to call it via send
? Can't we assume that the Simple
backend is present as a default (see https://github.com/svenfuchs/i18n/blob/master/lib/i18n/config.rb#L18)? Or is the default i18n backend overwritten somewhere in the fulcrum code?
I called it via send because it was private/protected.
You could also call the public method available_locales
on the Simple
backend which initializes the translations if not already done.
Closed by #235
Hi, I am new to Ruby and Rails.
Manage to setup Fulcrum locally and in Heroku. While the local fulcrum has no issues, the one deployed to Heroku has issue with english translation for labels. i.e. [missing "en.velocity" translation]
Googled and only found one possible lead, https://github.com/fulcrum-agile/fulcrum/issues/226 Followed it, but the problem persist.
Is there something I am missing?