I use rails-engine as a plugin of the application and I want to localize
the validate message from the plugin:
validates_length_of :login, :within => 3…40, :on => :create, :message
=> N_("%{fn} is too short (min is %d characters)")
It can not display the according language,where should i set it?
I have tried to add
require ‘gettext/rails’
GetText.bindtextdomain(“myd2d”)
to init_engine.rb or somewhere else,it can not work still.
Thanks
Charlie
Hi charlie,
At first, did you fix your previous problem?
http://www.ruby-forum.com/topic/64942#new
If not, fix the problem first.
Because it may cause this problem.
Then,
a similer problem that “validates_lenth_of doesn’t translate anything”
are reported by other person today. So I’ll investigate it ASAP.
But if you have other informations about this.
Report it more detail as you can, please.
For example, validation in your model(not plugins) works,
or every other messages are localized correctly, etc.
On Tue May 09 14:36:51 JST 2006
Hi, the previous problem you mentioned has been fixed,I use cookie to
set local and it can work,however if i directly set local using the api
that i used before,it can not work.
I am still working this problem,and now I am clear that it is the reason
of validates_lenth_of 's not working well,but other validates can work
in
PLUGINS,eg:validates_uniqueness_of,validates_confirmation_of,validates_presence_of
sometimes validates_lenth_of can translate,but sometimes not,i am still
summarizing the rules.
unknown wrote:
Hi charlie,
At first, did you fix your previous problem?
Gettext not worked in firefox,but done well under IE - Rails - Ruby-Forum
If not, fix the problem first.
Because it may cause this problem.
Then,
a similer problem that “validates_lenth_of doesn’t translate anything”
are reported by other person today. So I’ll investigate it ASAP.
I have tested the validates_lenth_of translation both in activemodels
and plugins,and i think it has some bugs:
validates_length_of :login, :minimum => 5, :on => :create, :message =>
N_("%{fn} is too short (min is %d characters)")
if the string above include “%d”,then validates_length_of string will
not be translated by gettext,or else it can be done.
Thanks
Charlie
charlie wrote:
Hi, the previous problem you mentioned has been fixed,I use cookie to
set local and it can work,however if i directly set local using the api
that i used before,it can not work.
I am still working this problem,and now I am clear that it is the reason
of validates_lenth_of 's not working well,but other validates can work
in
PLUGINS,eg:validates_uniqueness_of,validates_confirmation_of,validates_presence_of
sometimes validates_lenth_of can translate,but sometimes not,i am still
summarizing the rules.
Masao M. wrote:
Hi,
Thanks for reporting.
I fixed them. Could you try it and report the result?
Hi,I have tested ant it works well now,very grateful!
Charlie
Hi,
On Tue, 9 May 2006 09:49:15 +0200
charlie [email protected] wrote:
I have tested the validates_lenth_of translation both in activemodels
and plugins,and i think it has some bugs:
validates_length_of :login, :minimum => 5, :on => :create, :message =>
N_(“%{fn} is too short (min is %d characters)”)
if the string above include “%d”,then validates_length_of string will
not be translated by gettext,or else it can be done.
Thanks for reporting.
I fixed them. Could you try it and report the result?
-
Get the newest rails.rb Revison 1.34 from:
http://rubyforge.org/cgi-bin/viewcvs.cgi/gettext/lib/gettext/rails.rb?root=gettext&view=log
-
Replace this file to your rails.rb
(e.g. /usr/lib/ruby/gems/1.8/gems/gettext-1.5.0/lib/gettext/rails.rb)
-
Try validates_length_of at models.
-
Then try validates_length_of at plugins.