← Back to team overview

openjdk team mailing list archive

Bug#608723: [DebianGIS-dev] Bug#608723: josm: LC_CTYPE decides language used for user interface

 

Hi Torsten.

On 03/01/2011 10:23, Torsten Werner wrote:
> On Mon, Jan 3, 2011 at 9:53 AM, David Paleino <d.paleino@xxxxxxxxx> wrote:
>> I found that this really is a Java bug.
> 
> no, not really. The page at
> <http://java.sun.com/developer/technicalArticles/J2SE/locale/>
> explains:
> 
> "Depending on the default locale is not wise. In multiuser
> applications, a single default locale is usually not appropriate for
> everyone using the system. Instead your application should explicitly
> provide a preference to all locale-sensitive objects."

While this may be true or not (the mechanism of having proper
environment variables set is just made to have different users running
the same programs with different locales), I don't think the problem is
here.

The real issue is that the Locale class seems to be unable to correctly
detect the default locale. Of course, given that the Java locale
infrastructure isn't able to discriminate between different scopes of a
locale (that is, there is nothing like the different LC_* variables),
I'm not expecting it to actually display messages in a language and
sorting strings or showing numbers according to a different locale. But
the algorithm to detect the current default locale seems to be a little
strange (I'm using the small program written by David):

> [12:12] giovanni@edelstein:/tmp$ export | grep LC
> [12:12] giovanni@edelstein:/tmp$ export | grep LANG
> declare -x GDM_LANG="it_IT.utf8"
> declare -x LANG="it_IT.utf8"
> [12:12] giovanni@edelstein:/tmp$ java LocaleTest
>    Language, Country, Variant, Name
> 
> Default locale: 
>    it, IT, , , italiano (Italia)
> [12:13] giovanni@edelstein:/tmp$ LC_CTYPE=de_DE.UTF-8 java LocaleTest
>    Language, Country, Variant, Name
> 
> Default locale: 
>    de, DE, , , Deutsch (Deutschland)
> [12:13] giovanni@edelstein:/tmp$ LC_MESSAGES=de_DE.UTF-8 java LocaleTest
>    Language, Country, Variant, Name
> 
> Default locale: 
>    it, IT, , , italiano (Italia)

Why does LC_TYPE have influence over the the default locale and
LC_MESSAGES (or any other LC_* variable) not?

Anyway, this seems to be a really minor issue to me. Nonetheless it's
something strange!

> It is the applications responsibility to provide a preference for
> choosing the locale.

Maybe, but anyway the JVM should be able to correctly detect the default
locale when this isn't done.

BTW, I think that the workaround for josm can be just clearing LC_CTYPE
then firing the JVM.

Thanks, Giovanni.
-- 
Giovanni Mascellani <mascellani@xxxxxxxxxxxxxxxxxxxx>
Pisa, Italy

Web: http://poisson.phc.unipi.it/~mascellani
Jabber: g.mascellani@xxxxxxxxxx / giovanni@xxxxxxxxxxxxxxxxxxxx

Attachment: signature.asc
Description: OpenPGP digital signature


References