[GNC-dev] Early locale initialization
jralls at ceridwen.us
Thu Mar 18 21:19:46 EDT 2021
> On Mar 18, 2021, at 6:08 AM, Geert Janssens <geert.gnucash at kobaltwit.be> wrote:
> Op donderdag 18 maart 2021 13:56:35 CET schreef Derek Atkins:
>> On Thu, March 18, 2021 7:58 am, Geert Janssens wrote:
>>> 3. While all three allow to tweak some environment parameters, only linux
>>> allows the user to do so via the environment file. For Windows and Macos
>>> file is only read after locale is set. Whether that's a good thing depends
>>> the answer to question 2.
>> Are you saying that /etc/gnucash/environment (or the equivalent thereof)
>> is not read/used on Windows or Mac?
> No, it is used on all platforms. But it's only read after locale
> initialization on mac/windows has been done. So for locale initialization it
> only will affect linux. The other parameters in there (like LD_LIBRARY_PATH
> tweaks and so on) will still affect all platforms.
No, it's read after the other initializations so that it will override them. As long as setlocale is called after loading the environment then the last computed locale is what GnuCash starts up with. I've tested that pretty extensively on both macOS and Win32, though not since last fall.
The one thing that doesn't work is passing LANG/LANGUAGES in the Win32 CMD shell because that shell doesn't understand that. It should be possible on Powershell with something like $Env:LANG=nl_BE "c:\Program Files (x86)\gnucash\bin\gnucash.exe"; I've never actually tried that.
On macOS the language fallback is used because Apple's localization can result in locales that libc thinks aren't legal, e.g. en_BE so we have to find something close or the user gets "C". That's done only when getting the locale from system preferences (aka "defaults").
More information about the gnucash-devel