From: Martin DeMello Date: 2012-05-16T08:52:57+09:00 Subject: Re: Locale number formatting Thanks for following up! I just checked, and your post comes up as the third google hit for "ruby number locale", so as you say, hopefully the next person down the line will have an easier time. martin On Tue, May 15, 2012 at 4:45 PM, Llelan D. wrote: > No answers? For such an incredibly common and required function? > Really?? > > After a far-too-long search through web pages, blogs, and gem packages, > I can now definitively say that this is one of the worst documented > languages in history. > > It seems, no guarantee here, that localization has centered around the > R18n package found at "http://r18n.rubyforge.org/". Again, the > documentation sucks. > > Apparently they refer to a standard Ruby interpreter (No Rails, Sinatra, > etc.) as a "desktop" installation. You can install the package via gem > with "gem install r18n-desktop". It will install two packages and will > gack on the documentation with conversion errors (It seems a Ruby 1.9.x > thing. I still have no idea why.). > > The attached ruby script demonstrates locale data formatting (Not > documented on the site). This will automatically create an 'i18n' helper > object, configured to the current locale, with an 'l()' method that > performs the locale formatting of a given object. > > -------------------------------------- > Output for a en-US locale > > Locale: American English > 12,345,678.9 > 05/15/2012 04:06 PM > -------------------------------------- > Output for a de-DE locale > > Locale: de_de > 12.345.678,9 > 15.05.2012 16:30 > -------------------------------------- > I do not know why there is no localized title for the de-DE locale. Seem > kind of insulting. > > I have no idea if there are any difference between the 'i18n' and 'r18n' > objects. The 'r18n' object can be used in place of the 'i18n' object in > the attached script with the same results. > > So, at least this works and does the desired job. Hopefully this will > save someone else from unnecessarily burning man-hours like I had to. > > Enjoy! > > Attachments: > http://www.ruby-forum.com/attachment/7393/R18n_Example.rb > > > -- > Posted via http://www.ruby-forum.com/. >