[fpc-pascal] GetLocaleInfo returns ZZZ

Henry Vermaak henry.vermaak at gmail.com
Wed Feb 28 10:58:55 CET 2018

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
*_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:



More information about the fpc-pascal mailing list