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

Translations do not update in rails 5 #404

Closed
steventen opened this Issue May 14, 2016 · 13 comments

Comments

Projects
None yet
5 participants
@steventen
Copy link

steventen commented May 14, 2016

Hi,
I'm using this gem in rails 5 rc1, and I'm using the Asset Pipeline setup.

In my local development, the translations couldn't update automatically after I update the content in locale yml files. I tried to restart the server and it won't work.

Right now, I have to manually run rake tmp:clear to make it work.

@tilsammans

This comment has been minimized.

Copy link

tilsammans commented Jun 23, 2016

Hi @steventen it's a known issue with this plugin #306 and rake tmp:clear is the current best way of dealing with this.

In production I actually update the asset version in order to expire all caches. It's the only way that works reliably for me.

@AubinWinddle

This comment has been minimized.

Copy link
Contributor

AubinWinddle commented Jul 15, 2016

@tilsammans sorry but your response is false. This is only on Rails 5. It is due to the using_asset_pipeline? method which check only for Rails4 and Rails3 and return always false on Rails5. I will post a PR which cover this issue

@tilsammans

This comment has been minimized.

Copy link

tilsammans commented Jul 15, 2016

@dbackeus

This comment has been minimized.

Copy link

dbackeus commented Sep 7, 2016

We still have this problem after upgrading to Rails 5 even using rc14.

Have to clear tmp after every change to our translation yml files. Also production deploy does not build any new translation file.

@PikachuEXE

This comment has been minimized.

Copy link
Collaborator

PikachuEXE commented Sep 8, 2016

Besides rails 5 can you provide details about other asset related dependencies?
Like sprockets (with versions)

A more advanced (maybe not very easy for the first time but easier for debugging)
Is to checkout the master, change Gemfile to point to local path
Add debugging code (like puts) and see if there is anything output

But you need to clear the assets cache though, like rake assets:clobber
I the the above method when testing #418

@dbackeus

This comment has been minimized.

Copy link

dbackeus commented Sep 8, 2016

Tested with both sprockets-rails 3.1.1 and 3.2.0, sprockets is at 3.7.0.

Currently we've patched it by creating our own translations javascript file with explicit depend_on declaration for our languages ymls followed by I18n.translations = <%= I18n::JS.filtered_translations.to_json %>.

If I get some time today will revert the hack and see if i18n-js master works out 👍

@PikachuEXE

This comment has been minimized.

Copy link
Collaborator

PikachuEXE commented Sep 8, 2016

Thanks
Let me know the result :)

@dbackeus

This comment has been minimized.

Copy link

dbackeus commented Sep 8, 2016

Ok got some info on this.

Apparently JS::Dependencies.sprockets_supports_register_preprocessor? is nil at the time of engine initialization due to Sprockets still being undefined (https://github.com/fnando/i18n-js/blob/master/lib/i18n/js/engine.rb#L12).

So it's a load order problem.

By explicitly adding require "sprockets/railtie" to application.rb before Bundler.require(*Rails.groups) it works out.

Would be nice if the developer wouldn't have to bother about such details, if possible. You probably know more than me about this stuff since I've never written a railtie myself :)

@PikachuEXE

This comment has been minimized.

Copy link
Collaborator

PikachuEXE commented Sep 9, 2016

I guess the gem can try to require sprockets file(s) on that line? (and resuce LoadError)
Problem is I don't know what files should be required
sprockets/railtie seems only for rails 4.x only.
So I prefer adding a note in README over trying to require the "right" files in the gem.

What do you think?

@dbackeus

This comment has been minimized.

Copy link

dbackeus commented Sep 9, 2016

@PikachuEXE yes I think an entry in the README would suffice.

I think we were a bit of an edge case since rails usually generates an application.rb with an explicit require "sprockets/railtie" if you generate it with any of the skip options (such as --skip-active-record). And if you have the generic require "rails/all" I'm guessing that sprockets would be included in that already.

@PikachuEXE

This comment has been minimized.

Copy link
Collaborator

PikachuEXE commented Sep 26, 2016

Please see the change in
4e1737a
And see if that's clear enough
Thanks

@dbackeus

This comment has been minimized.

Copy link

dbackeus commented Sep 26, 2016

Perfect 👍

@PikachuEXE

This comment has been minimized.

Copy link
Collaborator

PikachuEXE commented Sep 26, 2016

@steventen
If you are satisfied please kindly close this issue
Thanks

@steventen steventen closed this Oct 3, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.