Michal Suchanek
1/15/2008 8:41:00 PM
On 15/01/2008, Jochen Hayek <jochen+ruby-forum@hayek.name> wrote:
> Michal Suchanek wrote:
> > On 15/01/2008, Jochen Hayek wrote:
> >>
> >> 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,
>
> That's right, but ...
>
> > and there are real multithreaded ruby applications.
>
> ... will a single instance of a non-web software
> usually serve more than a single user-interface.
> An let us assume for the time being,
> that a single-user interface usually comes with a single language!
There might be pieces of text or other data in different languages.
And POSIX locale handles such situations poorly. And you should
remember that the application is not just the interface. It's the
mistake that the people designing POSIX locale did: they forgot that
the data has to live somewhere before it gets to the user interface.
>
> > I suspect you misunderstand the way locale is currently handled.
> > It is not used by ruby, it is avoided.
>
> Well, as long as MRI is written in C
> and makes use of host libraries esp. like (g)libc,
> "avoiding" is better replaced by "defaulting",
no, it's avoiding it. The locale was set to "C" in 1.8, and now only
LC_CTYPE is set.
> because *there* *are* language strings emitted by C library routines
> and passed through to ruby class resp. object methods,
> and it's probably not too wrong
> to assume these strings are "very similar" to en_US.
> That is a locale de facto, isn't it?!?
no, locale is about having the language specific stuff different at
different times. Before there was locale, everything was in the
implicit "C" locale which was like en_US
>
> > 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.
>
> Extensions built on assumptions *like* "you always work with en_US",
> of course, that simplifies life tremendously,
> but you don't real want to discuss this bad idea with me, right?
No, extensions that use libraries built around the assumption that
LC_CTYPE specifies the correct character classes which the "C" locale
does not for most cases.
>
> > 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
>
> Last released around Dec. 2002,
> and you will agree with me,
> we should regard such software as abandoned, right?
It depends. If it's simple and does what it's supposed to do there is
no need for further development at some point. The C api did not
change almost at all between 1.8.x, and even many simple 1.6
extensions would probably work with 1.8.
>
> Unlikely to be compatible with 1.8.5, 1.8.6, 1.9,
> and certainly for "good reason" not released with MRI itself.
Yes, the reason is that the interpreter is not tested with locale
other than "C". 1.9 had to be fixed up for that.
>
> > that you can use for that.
>
> I am awfully sorry,
> but I mistrust that suggestion.
>
> Again: MRI, rubinius, and jruby should get it right:
> * no locale dependencies between core and middleware
> (HTTP protocol and whatever XML dialect implementation),
HTTP should not depend on locale. It's the same in Europe as it is in
Asia. That's exactly why there should be core functions independent of
locale.
> * passing (g)libc capabilities straight through,
> where not too much speaks against it
The libc is never used directly because it does not operate on the
same data types as ruby does. You could make wrappers but it's always
some *addition*.
> * implement nicer locale capabilities,
> when there are any coding resources left
What capabilities do you need exactly?
>
> You do see, how people struggle for I18N in rails apps in a desperate
> and strange way,
Afaik they struggle with multibyte encodings which 1.9 should make
easier. This has nothing to do with locale.
> just because available locale capabilities
> most easy to get passed through from the interpreter's runtime system
> are twisted suboptimally?
There are none to be twisted.
>
> Again: it's already there, just set it free!
What is there? Could you, please point at the capabilities, in the
code, that are hidden?
Thanks
Michal