Andrei S
Andrei S

Reputation: 6516

can't figure out how to do i18n on Devise

in my rails3 app, i'm using devise for authentication

now i'm trying to do i18n. for that i saw a devise.en.yml in config/locales, and thought all i got to do is make an devise.ro.yml to translate it in my other language. but if the devise.ro.yml is present, everything is in ro, no matter the language i use

for changing language, i use a locale param in my urls. for that i set up in the application controller something like this:

before_filter :set_locale

def set_locale
  I18n.locale=params[:locale]
end

def default_url_options(options={})
   { :locale => I18n.locale }
end

everything in my app is translated ok, except the devise part

am I missing something here?

Upvotes: 5

Views: 5483

Answers (4)

mcasimir
mcasimir

Reputation: 678

Devise views do not use i18n by default, from now on you can use https://github.com/mcasimir/devise-i18n-views to add I18n support to Devise views and mails. (see https://github.com/plataformatec/devise/pull/1989)

Upvotes: 1

Tilo
Tilo

Reputation: 33732

devise.ro.yml should work.

as a side-note:

I had similar problems, and used this trick to debug / find out where/what Rails is trying to lookup for translations:

http://unixgods.org/~tilo/Rails/which_l10n_strings_is_rails_trying_to_lookup.html

Upvotes: 0

Mirko
Mirko

Reputation: 5286

First you need to generate Devise views with: rails generate devise:views, then you can translate each of those to suite your locale needs.

devise.en.yml is only for flash messages.

Upvotes: 1

shingara
shingara

Reputation: 46914

I can suppose you do in top of you devise.ro.yml ro instead of en ?

Upvotes: 3

Related Questions