# Strange problem with I18n

**URL:** <https://www.ruby-forum.com/t/strange-problem-with-i18n/181052>\
**Category:** Rails\
**Created:** [January 4, 2010, 4:34pm UTC](https://www.ruby-forum.com/t/strange-problem-with-i18n/181052 "2010-01-04T16:34:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![inprogs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/8491ac/32.png) [@inprogs](https://www.ruby-forum.com/u/inprogs)\
**Post date:** [January 4, 2010, 4:34pm UTC](https://www.ruby-forum.com/t/strange-problem-with-i18n/181052/1 "2010-01-04T16:34:36Z")

</div>

So… I have got little problem with I18N on my production server…

Development server using webrick when I make POST request (Sending  
form) with not existing translation I have got result like:

# translation missing: es, surname translation missing: es,

invalid\_field\_with\_e\_end

# translation missing: es, email translation missing: es,

invalid\_email\_format

# translation missing: es, contact\_phone translation missing: es,

invalid\_field\_with\_y\_end

It is ok because I dont have this translation…

On Production server using mongrel\_cluster… I make SAME request…  
and result is translated fields in DEFAULT locale…

To add a sickness … it is only problem with a HALF of a form…  
so… I got:

# translation missing: es, surname translation missing: es,

invalid\_field\_with\_e\_end

# Your email has got Invalid email format

# translation missing: es, contact\_phone translation missing: es,

invalid\_field\_with\_y\_end

Can someone tell me why ? It is important because when I have got two  
languages pl and en I have got half of my form translated in pl and  
half in en… a bit sick…

default is pl  
using pl/controller/action I got proper form  
using en/controller/action I got only a half proper form… (and  
whole good on webrick 😑 )

I am using nested attributes and base class is ACCOUNT and this  
problem appears exactly with its fields…  
COMPANY works FINE !!!

class Account \< ActiveRecord::Base  
belongs\_to :company

accepts\_nested\_attributes\_for :company

attr\_accessor :password

validates\_uniqueness\_of :email  
validates\_presence\_of :surname, :name, :message =\> I18n.t  
(:invalid\_field\_with\_e\_end)  
validates\_presence\_of :email, :contact\_phone, :message =\> I18n.t  
(:invalid\_field\_with\_y\_end)  
validates\_length\_of :email, :maximum =\> 100, :message =\> I18n.t  
(:invalid\_email\_length)  
validates\_format\_of :email, :with =\> /^([^@\s]+)@((?:[-a-z0-9]+.)+  
[a-z]{2,})$/i, :message =\> I18n.t(:invalid\_email\_format)  
validates\_length\_of :password, :minimum =\> 8, :message =\> I18n.t  
(:invalid\_password\_length), :on =\> :update

HUMAN\_ATTRIBUTES = {  
:email =\> I18n.t(:email),  
:name =\> I18n.t(:name),  
:surname =\> I18n.t(:surname),  
:password =\> I18n.t(:password),  
:contact\_phone =\> I18n.t(:contact\_phone)  
}  
end

and…

class Company \< ActiveRecord::Base  
has\_one :account  
belongs\_to :city

accepts\_nested\_attributes\_for :city

validates\_uniqueness\_of :nip, :regon  
validates\_presence\_of :name, :message =\> I18n.t  
(:invalid\_field\_with\_a\_end)

validates\_presence\_of :nip, :regon, :postal\_code, :address, :message  
=\> I18n.t(:invalid\_field\_with\_y\_end)

HUMAN\_ATTRIBUTES = {  
:name =\> I18n.t(:company\_name),  
:postal\_code =\> I18n.t(:postal\_code),  
:address =\> I18n.t(:address),  
:nip =\> I18n.t(:nip),  
:regon =\> I18n.t(:regon)  
}

def self.human\_attribute\_name(attr)  
HUMAN\_ATTRIBUTES[attr.to\_sym] || super  
end  
end

my environment  
config.i18n.load\_path += Dir[File.join(RAILS\_ROOT, ‘config’,  
‘locales’, ‘\*\*’, ‘\*.{rb,yml}’)]  
config.i18n.default\_locale = :pl

my application\_controller.rb  
before\_filter :set\_locale  
def set\_locale  
I18n.locale = params[:locale]  
end

my routes.rb  
map.connect ‘:locale/:controller/:action/:id’, :controller =\>  
“home”, :action =\> “index”  
map.connect ‘:locale/:controller/:action/:id.:format’

So… mongrel and webrick are handling locales atrribute in different  
way ?

regards  
Piotr MÄ…sior

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
