On 31.07.2009 13:30, Venkat Akkineni wrote:
>> Well, that's what you get with incomplete specifications.  You did not
>> mention that you need the locale awareness of those.  :-)
> 
>     Lesson Learned: Better the specification better the answer. In my 
> defense, I think my mind was wandering around the strippers I have seen 
> last night. cheers.

:-)  No problem at all - it happens all the time.

>  The above code actually replaces the conventional numeric symbols used 
> in English speaking nations with any available local (i.e local to a 
> nation where it is being used) symbols. Thats about it.
> 
> As a solution we are just translating the java.text api into ruby as it 
> saves time in drafting our own api and it would mean adoption of a 
> stable draft developed by fully dedicated team. Comments, criticisms and 
> thoughts are welcome. If things go well we intend to offer the api as a 
> gem.

You could do something like this (untested):

LOCALE_SYMBOLS_US = {
   '%.' => '.',
   '%,' => ',',
}

def lprintf(pattern, *args)
   # emulate locale aware lookup
   syms = LOCALE_SYMBOLS_US
   pat = pattern.gsub(Regexp.new(Regexp.union(syms.keys))) do |m|
     syms[m] || ''
   end
   printf(pat, *args)
end

The symbols then should really come from a resource file selected via 
the current locale.

Kind regards

	robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/