jvang2003 / substruct

Automatically exported from code.google.com/p/substruct
0 stars 0 forks source link

PATCH Easier translation and maintenance of error messages and titles #123

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by edmundo...@gmail.com on 22 Aug 2008 at 10:10

Attachments:

GoogleCodeExporter commented 9 years ago
We might want to hold off for Rails 2.2 & this?

http://i18n-demo.phusion.nl/

Original comment by subim...@gmail.com on 30 Aug 2008 at 5:03

GoogleCodeExporter commented 9 years ago
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.

Original comment by edmundo...@gmail.com on 30 Aug 2008 at 3:17

GoogleCodeExporter commented 9 years ago
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.

Original comment by camla...@gmail.com on 30 Aug 2008 at 8:04

GoogleCodeExporter commented 9 years ago
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.

Original comment by edmundo...@gmail.com on 30 Aug 2008 at 9:57

GoogleCodeExporter commented 9 years ago
@carter - fine with me. show me the patch.

Original comment by subim...@gmail.com on 31 Aug 2008 at 7:51

GoogleCodeExporter commented 9 years ago
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.

Original comment by edmundo...@gmail.com on 31 Aug 2008 at 2:47

GoogleCodeExporter commented 9 years ago
@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

Original comment by arcasysm...@googlemail.com on 14 Sep 2009 at 9:10