This project is archived and is in readonly mode.
Add I18n shortcuts to AR models
-
Pascal Ehlert
Imho we should keep AR:Base clean from helper methods (actually this feels like a helper method, although the definition is different ;-))..
Actually, translation shouldn't be going on in models at all (where possible) and if someone needs it, it's easy enough to do I18n.t or alias the method on his own.
-1 for this.
-
Yaroslav Markin
Actually, translation shouldn't be going on in models at all (where possible)
Why so? Check the link, I see it as a very common scenario. Validation messages translation is sure built in, but this does not mean you don't need other strings translated.
I think of I18n as some kind of string refactoring -- keep all your string constants in a separate place (YML file or any source supported by I18n backend used).
Judging by link provided, seems it is not really clear that Rails devs should use I18n module -- l/t aliases are built-in for ActionController for a reason.
This style is a bit simular to
loggeraccessor for AC and AR -- sure you can use @RAILS_DEFAULT_LOGGER@, but this stuff is shorter and built-in. -
Yaroslav Markin
- Assigned user changed from Sven Fuchs to DHH
Since Sven is N/A at the moment and it looks like an API design issue anyway (patch is too simple), I pass ticket to DHH.
-
Sven Fuchs
Maybe not n/a for that matter ... but i'm not quite sure about this one tbh. On the one hand I tend to agree with Pascal here that this might be a bit too much in AR::Base. Otoh we ship a helper for controllers and views, too.
The ticket is in best hands with DHH anyway ;)
-
josh
- Assigned user changed from josh to DHH
- Milestone cleared.
Pass back to DHH. I'm kind of a -1 here too.
-
Mike Champion
I wrote a plugin/gem that adds a more DRY "translate" to models, mailers, controllers, views. Might be interesting for those running into this issue:
http://github.com/graysky/translator/
The stock AR models already support i18n for the validation messages, but don't make it simple if you have your own messages you want to have be i18n. If it is valuable for all the validates methods, why not ones developers add?
(A purist could make the case the the models shouldn't be injecting user-visible strings at all and that should be done in a view layer, but I don't think anyone is proposing that.)
-
Dmitry Polushkin
I think this should be in the core (I've used "translator" gem in all the multi-language projects). Models will be more clear (and you will never use additional scopes).
+1 -
José Valim
- State changed from new to wontfix
I'm closing this one guys since I'm kinda of -1 also. Re-raise the discussion in the i18n mailing list or Rails mailing list and see how people react to it.
-
Yehuda Katz (wycats)
- State changed from wontfix to invalid
This has been around the block a few times and has received a lot of -1's from members of the core team. People in general seem ambivalent. I'm closing pending a suggestion that is more widely accepted.
