welcome to the list!
On 21.07.2008, at 10:12, Johannes Fahrenkrug wrote:
> I have just skimmed through some of the posts and api drafts and I
> apologize in advance if I missed the answer to my question in one of
> those posts.
> How will number formatting be supported?
>
> In en-US you'd say 1,000.99 but in de-DE you'd say 1.000,99
> Will that be supported? Will there be support for users to enter
> values like that? At the moment I use the simple localization plugin
> for that and I have to use "price_localized" in my forms in order to
> enable my users to enter numbers with the German separators which
> works pretty nicely, but setting the number format somewhere and then
> not having to worry about it anymore (read: to use "price" instead of
> "price_localized" in my forms) would be even nicer of course.
If you look at the number_helper #number_to_currency there's quite
some stuff about currency formatting. Can you use that for your forms?
I agree that transparent formatting for form in/output would be nice.
That might be a goal for a plugin to experiment with first though.
WDYT?
--
sven fuchs sven...@artweb-design.de
artweb design http://www.artweb-design.de
grünberger 65 + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile)
Ah, I had feeling that could be the case, but its interesting to see
that you tried various alternatives there.
It would still be nice to have some kind of solution for modifying
attributes without having to do some kind of conversion before and
after so that handling the params hash is easier. Perhaps something
can be added to ActiveRecord alone just to recognise and convert
attributes being set? I'm not talking full support, but at least some
hooks for a future plugin to handle it more easily perhaps? I've not
studied this part of ActiveRecord enough to know if this is practical.
Cheers, sam
However I wouldn't include it into Rails right now. Before that more
plugins should experiment with something like this. Maybe there's a more
transparent way of localizing attributes.
ps.: Because of an absolute and unfortunate lack of time I had to stop
development on the Simple Localization project. So don't expect movement
from there any longer. Sorry for that but maybe some other plugin
authors find some ideas useful.
Happy programming
Stephan Soller
Johannes Fahrenkrug schrieb:
This might sound weird at first, but isn't it a better idea to use
formatter and request middleware for this? (as opposed to doing
conversions on the model level)
The point is (as I see it) for the conversion to be done transparently
at least on incoming numbers set using the attributes methods (eg.
update_attributes) so that an incoming parameters don't need to be
handled separetly. The norm in my experience is to pass the params
hash direct to the model where things like time and dates are already
handled and converted automatically, so why not numbers too?
Output is not something I would be so worried about as formatter
methods can be used there, Time#to_s( format ) again is a good example
of this.
Cheers, sam