I use before_filter in ApplicationController to set locale for my application:
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
def set_locale
I18n.locale = request.compatible_language_from ["uk", "ru", "de", "en"]
end
end
It works for controllers that are written by me. But all devise's messages are still English.
Setting config.i18n.default_locale = "uk"
(or other) in config/application.rb
works, so I guess that the trouble is that devise's controller does not use my before_filter (possibly, it does not inherit ApplicationController
at all (?)).
How to resolve this problem? How to make devise use my locale?
Take a look at Devise Wiki https://github.com/plataformatec/devise/wiki/I18n They have lots of YML file samples.
If you still wanna write your own, try using something like this in your I18n files
en:
devise:
sessions:
signed_in: 'Signed in successfully.'
More info on GitHub https://github.com/plataformatec/devise#i18n
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With