Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Missing English Translation #242

Closed
chickensmitten opened this issue Oct 24, 2014 · 17 comments
Closed

Missing English Translation #242

chickensmitten opened this issue Oct 24, 2014 · 17 comments

Comments

@chickensmitten
Copy link

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, #226
Followed it, but the problem persist.

Is there something I am missing?

@hakunin
Copy link
Contributor

hakunin commented Oct 24, 2014

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…}

@chickensmitten
Copy link
Author

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.

@hakunin
Copy link
Contributor

hakunin commented Oct 24, 2014

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?

@chickensmitten
Copy link
Author

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

@chickensmitten
Copy link
Author

Hi, any advise or references that will help to resolve this? Thanks.

@hakunin
Copy link
Contributor

hakunin commented Oct 27, 2014

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.

@chickensmitten
Copy link
Author

Tried both, problem persists. Will check for other sources for help.

@baschtl
Copy link

baschtl commented Oct 27, 2014

I have the exact same issue as @chickensmitten. I will try to empty the cache as proposed in #226 and report back.

@chickensmitten
Copy link
Author

Hi baschtl, did you manage to resolve this?

@baschtl
Copy link

baschtl commented Nov 2, 2014

@chickensmitten I cleared the cache and precompiled the assets again. But the issue remains. :-/

@baschtl
Copy link

baschtl commented Nov 5, 2014

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

@baschtl
Copy link

baschtl commented Nov 5, 2014

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?

@hakunin
Copy link
Contributor

hakunin commented Nov 6, 2014

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?

@baschtl
Copy link

baschtl commented Nov 6, 2014

@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?

@hakunin
Copy link
Contributor

hakunin commented Nov 6, 2014

I called it via send because it was private/protected.

@baschtl
Copy link

baschtl commented Nov 6, 2014

You could also call the public method available_locales on the Simple backend which initializes the translations if not already done.

@malclocke
Copy link

Closed by #235

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

No branches or pull requests

4 participants