-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add i18n-js gem #97
Add i18n-js gem #97
Conversation
a279325
to
415b895
Compare
415b895
to
59d8af0
Compare
lib/i18n_js.rb
Outdated
|
||
# Ignore i18n.js generated files | ||
/vendor/assets/javascripts/i18n.js | ||
/app/assets/javascripts/translations/translations.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rosle For this config, when we want to deploy the project to Heroku we can't push those files to Heroku.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more comment regarding deployment on Heroku 🚀
@olivierobert I checked with @anduonghien about the i18n-js. The language switching does not work out of the box. We will need to set the current locale like we do in Rails part (that we read locale from param and set it in the controller). For javascript part, What we did for other project is we set So currently, we're not sure if we should include all that setup here or we let the developer implement it for each project. 💭 I try to check for other template but I don't find anyone including that. |
d218f54
to
db85977
Compare
@rosle How about we generate the
and put it in the |
@rosle Since it's used in all projects without any exceptions, I would recommend to add the whole setup in this PR. We should move the controller code into a concern (as done on Braive) so that it's easy to isolate the localization code. |
@olivierobert @anduonghien I added the script to generate initial 18n setup on controller and js. After the project creation, it will look like this application_controller.rb
application.js
And also add the lang attribute on the page for js to setup the locale |
As discussed the only remaining change is not to include the |
@olivierobert @anduonghien I updated the i18n to be included in layout instead. layouts/application.html.erb
Need to precompile new assets in
|
What happened
✅ Add
I18n-js
gem✅ Add
devise-i18n
andrails-i18n
gems that is optional for including many languages translations for Devise and Rails (Suggested by Yutna 👍)Insight
Due to issue #6 , we would like to add the i18n-js by default because we use it on most of the project.
I18n Configurations
The files locate at:
vendor/assets/javascripts/i18n.js
app/assets/javascripts/translations/translations.js
On
config/development.rb
, addconfig.middleware.use I18n::JS::Middleware
, so it will regenerate translations file.For production we should run
rake i18n:js:export
before deployment.Proof Of Work
Configuration added:
config/development.rb
app/assets/javascripts/application.js
The translation file gets generated when running the site on development

I create a simple page for test and alert a translation key.


