Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-02

GetLocaleInfo returns ZZZ

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Darius Blaszyk

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

Darius Blaszyk

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

Michael Van Canneyt
to Darius Blaszyk
Darius Blaszyk wrote 6 lines
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.

If you make a test program that shows the bug, and correct it, a patch will be accepted.

Michael.

Henry Vermaak
to Darius Blaszyk: On my machine getlocaleinfo returns ZZZ when requesting the abbrev langname. The country…
Darius Blaszyk wrote 10 lines
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

Bart
to Henry Vermaak
Henry Vermaak 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.

Show quoted text 6 lines
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

Henry Vermaak
to Bart
Bart wrote 16 lines
On Wed, Feb 28, 2018 at 10:58 AM, Henry Vermaak 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