| Issue 123: | PATCH Easier translation and maintenance of error messages and titles | |
| 4 people starred this issue and may be notified of changes. | Back to list |
This is an effort to make the translation of error messages and titles
easier to be done and maintained. It consists of changing all the
references of such messages to a hash inside a class method (just like
Active Record already does).
Its not supposed to be a complete solution but part of it.
Current state:
Users of languages other than english needs to customize currency, Active
Record error messages, Substruct custom error messages and titles and views.
The currency can already be customized, the Active Record messages are easy
to be customized, the views are already supposed to be changed to include
new layouts (so it wasn't touched here) but the way it was it still needed
to redefine models and controllers to change such messages (almost all).
So now it follows the same default as AR, and can be customized inside
environment.rb (for example), and models and controllers don't need to be
touched:
ActiveRecord::Errors.default_error_messages = {
:inclusion => "não está incluído na lista",
...
}
Substruct::Errors.default_error_messages = {
:empty => "Por favor, preencha este campo.",
...
}
Substruct::Messages.default_messages = {
:blog => "Blog",
:blog_entries_for => "Registros de Blog para ",
...
}
Seth, take a look at name scopes and/or hash names to see if something
needs to be changed. All tests passed with and without translation, so they
aren't supposed to break.
I got rid of regexps and now I only had some problems with tests when the
messages includes escaped html tags like that (<br\/>), the assert_select,
:html => insists in substitute the bar with an space and then it doesn't
match, so I changed 2 or 3 messages that included them with /n.
Follows the patch.
Aug 29, 2008
Project Member
#1
subim...@gmail.com
Aug 30, 2008
Seems interesting and its only one month old, I think this can be looked at and wait a little to see if worth to wait Rails 2.2 or if something (like conventions over those configurations) can be adopted earlyer. Seems that most of the convention comes from his localized_dates plugin that does what the majority of people are doing, defining a hash and a place to load these configs and apply to rails. I agree that is not pleasant the possibility of the need to change all those references again, just to point to another place because the convention to make this is different of what was implemented.
Aug 30, 2008
I have a working multilanguage substruct site at http://www.aurum.is via the simple_localization plugin (http://simple-localization.arkanis.de/). Not only are error messages, navigations, and forms internationalized but so are product titles/descriptions, tags, and content nodes. I'm using Icelandic and English as the two languages. Rails 2.2 won't support all of these internationalization features.. more specificially the localized ActiveRecord translations that simple_localization allows. Seth, if you're ok with adding simple_localization as a plugin, I'll move my changes to the plugin and add a patch.
Aug 30, 2008
I think in that case should be decided first what is the pretended default behavior, if it should accept two languages at the same time or just make easy to translate the system interface, the needs are different in both cases. Being the multilanguage approach I cannot even have sure if the changes in Rails will do any help.
Aug 31, 2008
@carter - fine with me. show me the patch.
Status:
Accepted
Aug 31, 2008
Carter, it should not break the tests or if some break they need to be patched too. I needed to change almost all assertions that used references that should be translated in my patch to not use regular expressions, probably you will need to do something similar.
Sep 14, 2009
@camlapse: I'd be very interested in your localized implementation. The shop looks very nice and well designed. I've already localized a Rails Goldberg application using Rails 2.2.2 I18n and the translatable_columns plugin so I know about the effort behind. I guess the localized Substruct modules could save me a lot of time if you'd like to share them. Which Substrucz version is your solution based on? Hans |