Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

I18n translation for email/login-format-validation not working in production #184

Open
lichtamberg opened this Issue · 6 comments

7 participants

@lichtamberg

Hey...

The I18n translation isnt working for the email/login-format validation in PRODUCTION-ENVIRONMENT... It always shows me the english default messages (beside my correctly working german validation messages!)... Even if I try to set the locale in an configuration block it doesnt find the right translation.

f.e. :
# user.rb
acts_as_authentic do |a|
I18n.locale = :de
I18n.default_locale = :de
a.merge_validates_format_of_login_field_options(:with => LOGIN_REGEXP)
end

# de.yml
de:
  authlogic:
    error_messages:
      email_invalid: "muss eine E-Mailadresse sein"
      login_invalid: "darf nur Buchstaben und Zahlen enthalten"

in my environment.rb the default_locale is set to :de
...

Can anyone confirm that? Its very nasty... And I didnt found a solution until yet...

@elciok

I'm having the exact same problem. I'm using Authlogic 2.1.6, Rails 3.0.3 and Ruby 1.9.2.
I was able to figure out a quick workaround to make it work, and hopefully this might help finding what exactly is wrong so it can be fixed.

# in user.rb
acts_as_authentic do |a|
    a.validates_format_of_login_field_options = {:with => LOGIN_REGEXP}
    a.validates_format_of_email_field_options = {:with => EMAIL_REGEXP}
end

This won't work if you use merge_validates_format_of_login_field_options instead.

@marcusg

any updates here? i still have the same problem...

@STRd6

I'm also experiencing this problem using a custom message for en email validation. My other custom messages are working fine, just email isn't working in staging and production. It also fails when running locally in development until I make a change to my locales en.yml file.

@ceringa

I have the same problem, but even in development mode. The problem of login_invalid message may be found here:

# in login.rb
def validates_format_of_login_field_options(value = nil)
  rw_config(:validates_format_of_login_field_options, value, {:with => Authlogic::Regex.login, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")})
end

it works for me with a proc call for the translation:

# in login.rb
def validates_format_of_login_field_options(value = nil)
  rw_config(:validates_format_of_login_field_options, value, {:with => Authlogic::Regex.login, :message => Proc.new{I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}})
end
@nlevchuk

@ceringa you are right. This method must use Proc object for the :message parameter, because it has dynamic behavior and depends on change locale. Can you do a pull request for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.