From: Michal Suchanek Date: 2008-01-16T01:16:49+09:00 Subject: Re: does ruby's strftime not attempt POSIX-compliance? On 15/01/2008, Jochen Hayek wrote: > Michal Suchanek wrote: > > > I think that locale as defined by posix is not very well thought out. > > For one, I do not see any specification > > of the scope of the setlocale() call. > > The standard dates presumably in the pre-threaded times. > > > Is it thread-local or per process? > > If it is per-process, > > Are we talking about software with a web GUI like rails?!? > Aren't they MVC-based?!? > Are they really talking to more than one user per instance?!? > Don't we have a fresh process for a request each time any way?!? Note that if some ruby methods will start acting differently in different locale it will affect all programs, not just rails. Ruby is more than rails, and there are real multithreaded ruby applications. > > > how can a multithreaded process work with data in multiple languages? > > Pls don't feel insulted, > and the question is interesting but in real life maybe not too relevant, > as I discussed it above. > > > That's why I suggest > > that locale should be supported by an add-on library > > that allows formatting/scanning/sorting/... > > according to current locale > > but ruby core should work the same regardless of locale. > > I actually "humbly request" :-) > that (g)libc's locale capabilities are just passed straight through, > where they are available, > and that they should not just be made use of for internal things > and then kept away from the public, > as it wasn't quite kosher the way is was done and made use of > in some "middleware". > We ("the community") can certainly wait a little while > until all that is cleaned up, > but then we want to have fair competion with what perl and python can do > locale-wise. > > > It does not imply that the ruby core should not implement sorting (or > > ther functionality) that respects language-specific rules. I just > > suggest that this functionality should be done independent of locale > > in a more object-oriented way if it is done in ruby. It should also be > > portable to systems that do not implement POSIX locale. > > Of course something tremendously shining can be done and added to ruby > libraries, so that the ruby way will turn out again to be the far better > way. > > But for short-term: > Pls give us libc's locale capabilities > and don't keep it for yourself! I suspect you misunderstand the way locale is currently handled. It is not used by ruby, it is avoided. The only recent change was adding the setlocale() call in the ruby interpreter that is required for some extensions to work properly in different locales. And small fixes were required to some core ruby classes to work properly after that. If you want to call setlocale() yourself there is a ruby-locale extension for quite some time that you can use for that. Thanks Michal