For the moment error messages are embeded inside the rails code…rails should give an option to specify the language of the app…so error messages have to be took of the code to an xml or txt file…someone for that patch ? :D
—technoweenie
This sounds like a good idea, although I think using yml would be a better fit. Perhaps someone could write up an \ActiveResource class that looks up properties in /config/languages/en-us.yml.
At the bottom of config/environment.rb I have the following code that sneaks in german error messages for validation failures. I doubt that this is a clean way, but apparently it’s the only one possible right now. But I’m still a newbie, thus add a large grain of salt.
module ActiveRecord
class Errors
begin
@@default_error_messages.update( {
:inclusion => "ist nicht in Liste gültiger Optionen enthalten",
:invalid => "ist ungültig",
:confirmation => "entspricht nicht der Bestätigung",
:accepted => "muss akzeptiert werden",
:empty => "darf nicht leer sein",
:too_long => "ist zu lang (höchstens %d Zeichen)",
:too_short => "ist zu kurz (mindestens %d Zeichen)",
:wrong_length => "hat eine falsche Länge (es sollten %d Zeichen sein)",
:taken => "ist schon vergeben",
:not_a_number => "ist keine Zahl",
})
end
end
end
—MichaelSchuerig
see also OverridingRailsMessagesInAnotherLanguage
—Henrik Horneber?
couldnt this be used to internationalize all rails messages ?
http://ri18n.berlios.de/
— [[GiovanniDegani? ]]
“Die Geister, die ich rief”—Please, no. This way of overriding is a stop-gap measure, not a general good practice. Doing things like this ties the new code very tightly to the internal structure of Rails. This is the kind of code I expect to break one time or another with a new version of Rails.
The proper way, IMHO, is to use one of the gettext derivatives and wrap all user visible text occurring in Rails in _(). In cases where no localization exists, the english strings just pass through the _(). Where there are localized messages, they are used.
—MichaelSchuerig
Michael, i guess you didnt understand me..
I was talking about using this: http://ri18n.berlios.de/
to internationalize the framework.
:)
—GiovanniDegani
category: I18n
For the moment error messages are embeded inside the rails code…rails should give an option to specify the language of the app…so error messages have to be took of the code to an xml or txt file…someone for that patch ? :D
—technoweenie
This sounds like a good idea, although I think using yml would be a better fit. Perhaps someone could write up an \ActiveResource class that looks up properties in /config/languages/en-us.yml.
At the bottom of config/environment.rb I have the following code that sneaks in german error messages for validation failures. I doubt that this is a clean way, but apparently it’s the only one possible right now. But I’m still a newbie, thus add a large grain of salt.
module ActiveRecord
class Errors
begin
@@default_error_messages.update( {
:inclusion => "ist nicht in Liste gültiger Optionen enthalten",
:invalid => "ist ungültig",
:confirmation => "entspricht nicht der Bestätigung",
:accepted => "muss akzeptiert werden",
:empty => "darf nicht leer sein",
:too_long => "ist zu lang (höchstens %d Zeichen)",
:too_short => "ist zu kurz (mindestens %d Zeichen)",
:wrong_length => "hat eine falsche Länge (es sollten %d Zeichen sein)",
:taken => "ist schon vergeben",
:not_a_number => "ist keine Zahl",
})
end
end
end
—MichaelSchuerig
see also OverridingRailsMessagesInAnotherLanguage
—Henrik Horneber?
couldnt this be used to internationalize all rails messages ?
http://ri18n.berlios.de/
— [[GiovanniDegani? ]]
“Die Geister, die ich rief”—Please, no. This way of overriding is a stop-gap measure, not a general good practice. Doing things like this ties the new code very tightly to the internal structure of Rails. This is the kind of code I expect to break one time or another with a new version of Rails.
The proper way, IMHO, is to use one of the gettext derivatives and wrap all user visible text occurring in Rails in _(). In cases where no localization exists, the english strings just pass through the _(). Where there are localized messages, they are used.
—MichaelSchuerig
Michael, i guess you didnt understand me..
I was talking about using this: http://ri18n.berlios.de/
to internationalize the framework.
:)
—GiovanniDegani
category: I18n