GetLocaleInfo returns ZZZ

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

GetLocaleInfo returns ZZZ

Darius Blaszyk-2
On my machine getlocaleinfo returns ZZZ when requesting the abbrev langname. The country code is correctly set to NL. This makes gettext.GetLanguageIDs return zz_NL. What could be causing this?

Also the behavior of GetLocaleInfoIDs does not seem to be according to the gettext manual. On windows the locale is determined by the Win API and on all other platforms the environment variables are checked as they are described in the manual but the first LANGUAGE env var is not probed and followed. This env var gives the preferred order of translations.

I would like to align this functionality over the platforms, but want to ask for advice wether or not a patch would be accepted.

Rgds Darius

Verstuurd vanaf mijn iPhone
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetLocaleInfo returns ZZZ

Bart-48
On Wed, Feb 21, 2018 at 12:11 PM, Darius Blaszyk <[hidden email]> wrote:
> On my machine getlocaleinfo returns ZZZ when requesting the abbrev langname. The country code is correctly set to NL. This makes gettext.GetLanguageIDs return zz_NL. What could be causing this?


Maybe the same as:
http://www.hu.freepascal.org/lists/fpc-devel/2011-January/023648.html

Bart
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetLocaleInfo returns ZZZ

Henry Vermaak
In reply to this post by Darius Blaszyk-2
On Wed, Feb 21, 2018 at 12:11:10PM +0100, Darius Blaszyk wrote:

> On my machine getlocaleinfo returns ZZZ when requesting the abbrev
> langname. The country code is correctly set to NL. This makes
> gettext.GetLanguageIDs return zz_NL. What could be causing this?
>
> Also the behavior of GetLocaleInfoIDs does not seem to be according to
> the gettext manual. On windows the locale is determined by the Win API
> and on all other platforms the environment variables are checked as
> they are described in the manual but the first LANGUAGE env var is not
> probed and followed. This env var gives the preferred order of
> translations.

The Windows implementation of GetLanguageIDs() in gettext.pp is not
right.  It uses GetLocaleInfo() with LOCALE_SABBREVLANGNAME and
LOCALE_SABBREVCTRYNAME where it should probably be using
LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME, respectively.  The
*_SISO* constants work on Windows 98 and later, maybe that was the
reason for using *_SABBREV* originally.

I guess the fix belongs in FPC, but it can also be fixed in lazarus,
which overrides GetLanguageIDs() for darwin already.  Have a look at
LazGetLanguageIDs() in lazutf8.pas.  I override the lot of them and then
call SetDefaultLang() in LCLTranslator.pas.

For reference, the reason I had to fix it was because of the language
codes for Chinese don't agree (CHS/CHT vs zh) and I didn't want to
duplicate the locale directories.  There's a table here:

http://archives.miloush.net/michkap/archive/2005/02/17/375235.html

Henry
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetLocaleInfo returns ZZZ

Bart-48
On Wed, Feb 28, 2018 at 10:58 AM, Henry Vermaak <[hidden email]> wrote:
> On Wed, Feb 21, 2018 at 12:11:10PM +0100, Darius Blaszyk wrote:
>> On my machine getlocaleinfo returns ZZZ when requesting the abbrev
>> langname. The country code is correctly set to NL. This makes

My Win 10 machine returns nl_NL as expected.

> The Windows implementation of GetLanguageIDs() in gettext.pp is not
> right.  It uses GetLocaleInfo() with LOCALE_SABBREVLANGNAME and
> LOCALE_SABBREVCTRYNAME where it should probably be using
> LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME, respectively.  The
> *_SISO* constants work on Windows 98 and later, maybe that was the
> reason for using *_SABBREV* originally.

Results of GetLocaleInfo with different parameters on my Win10 machine:

LOCALE_SABBREVLANGNAME -> NLD
LOCALE_SABBREVCTRYNAME -> NLD
LOCALE_SISO639LANGNAME -> nl
LOCALE_SISO3166CTRYNAME -> NL
LOCALE_SISO639LANGNAME2 -> nld
LOCALE_SISO3166CTRYNAME2 -> NLD

Bart
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GetLocaleInfo returns ZZZ

Henry Vermaak
On Wed, Feb 28, 2018 at 01:36:31PM +0100, Bart wrote:

> On Wed, Feb 28, 2018 at 10:58 AM, Henry Vermaak <[hidden email]> wrote:
> > The Windows implementation of GetLanguageIDs() in gettext.pp is not
> > right.  It uses GetLocaleInfo() with LOCALE_SABBREVLANGNAME and
> > LOCALE_SABBREVCTRYNAME where it should probably be using
> > LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME, respectively.  The
> > *_SISO* constants work on Windows 98 and later, maybe that was the
> > reason for using *_SABBREV* originally.
>
> Results of GetLocaleInfo with different parameters on my Win10 machine:
>
> LOCALE_SABBREVLANGNAME -> NLD
> LOCALE_SABBREVCTRYNAME -> NLD
> LOCALE_SISO639LANGNAME -> nl
> LOCALE_SISO3166CTRYNAME -> NL
> LOCALE_SISO639LANGNAME2 -> nld
> LOCALE_SISO3166CTRYNAME2 -> NLD

Yes, it makes no difference for nl, that's why I posted a link that
contains a table that shows where the differences are.

Note that I don't have an answer for the zzz problem, it works fine for
me.  I was addressing the second paragraph of Darius's mail.

Henry
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal