GnuCash
Contact   Instructions
Bug 797569 - Swedish account templates not accessible
Summary: Swedish account templates not accessible
Status: RESOLVED FIXED
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Windows (show other bugs)
Version: 3.8
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: windows
QA Contact: windows
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-11 10:48 EST by Johan von Boisman
Modified: 2020-01-21 04:30 EST (History)
4 users (show)

See Also:


Attachments
Code which may cause the problem (55.58 KB, image/png)
2020-01-11 10:48 EST, Johan von Boisman
no flags Details

Description Johan von Boisman 2020-01-11 10:48:47 EST
Created attachment 373525 [details]
Code which may cause the problem

Microsoft Windows 10 Pro
Version	10.0.18363 build 18363

Use a standard Windows computer in Sweden (i.e with Swedish UI)

Start GnuCash and select command "New File".

Go through the steps of the Wizard until "Choose accounts to be created"

The categories displayed are the ones of C:\Program Files (x86)\gnucash\share\gnucash\accounts\C

Expected: the categories (Swedish) of C:\Program Files (x86)\gnucash\share\gnucash\accounts\sv to be displayed

Double check:

Go to Control Panel and set Display Language to Danish
Go through the steps above and note how the contents of C:\Program Files (x86)\gnucash\share\gnucash\accounts\da is displayed. (as expected)

Poke around in the source code and discover this: (also see attached screencap)

https://github.com/Gnucash/gnucash/blob/master/gnucash/gnome/assistant-hierarchy.c#L238

I don't understand the logic, but it tests for Windows and Swedish specifically, which doesn't make sense as there are some 40 locales in C:\Program Files (x86)\gnucash\share\gnucash\accounts

Why test just for Swedish (which seems to be the one which _doesn't_ work)?
Comment 1 John Ralls 2020-01-13 00:55:58 EST
It's a little convoluted. Dunno if it's still the case, but when I wrote that hack gettext (the translation library) didn't handle 'sv' in the languages list correctly on Windows, so in order to get the GnuCash UI in Swedish when the computer was set to something else one had to put LANG=Swedish_Sweden or LANG=Swedish_Finland in the environment file. That borked the account hierarchy selection, which needed sv_SE or sv_FI and this bit of code provided that.

I do notice a mistake there, the Swedish_Sweden branch returns sv_SV instead of sv_SE, but unless you have LANG set in the environment file that's not what's going wrong with the Swedish account hierarchy.
Comment 2 Johan von Boisman 2020-01-13 14:22:46 EST
Note that I'm not trying to get GnuCash UI in Swedish with the computer set to anything else. My computer is all in Swedish and so is GnuCash (although the translation is not complete).

Here are some observations

I have created the file "environment.local" and added the section

[Variables]
LANG=Swedish_Sweden
LANGUAGE={LANG}

When starting GnuCash, its UI is now displayed in English
I have also made it so that these directories exist in the accounts directory

sv
sv_SE
sv_SV

All containing the Swedish account plans. These plans are not displayed by the New File wizard however.

I currently don't have the resources to set up a Windows build environment for GnuCash.
Comment 3 Johan von Boisman 2020-01-13 14:54:30 EST
I just found the discussion in https://bugs.gnucash.org/show_bug.cgi?id=725296
and changed environment.local to read

[Variables]
LANG=Swedish_Sweden
LANGUAGE=sv

Now GnuCash's UI is displayed in Swedish (as without any environment.local file present at all), but still no Swedish account plans in the wizard
Comment 4 Geert Janssens 2020-01-13 16:21:30 EST
Well, yes, if I read John's comment 1 correctly there's still a bug in the current code that will prevent gnucash from inferring the right language code for the account hierarchies if you set LANG in the environment.local file.

Unfortunately not setting it will prevent the ui from being translated (which is the main topic of bug 725296). As you indicate the UI is properly translated it looks like the LANG variable is being set to Swedish_Sweden somewhere after all.

If not in environment.local, is this done perhaps in the environment file itself ?

Until the typo in the code snippet you refer to is fixed, you may be able to get to the Swedish account templates by making sure the environment variable "LANG" is *not* set and keep your default PC locale settings to Swedish/Sweden. This should turn the interface into English but present the Swedish account templates.

After your account templates have been set up, you can set the LANG environment variable again to get a tranlsated UI.
Comment 5 Geert Janssens 2020-01-13 16:27:28 EST
Note I have just pushed a fix for the typo in the above code ("sv_SV" should really be "sv_SE").

Can you try with tomorrow's nightly build if you can now properly select the Swedish account templates even if the LANG environment variable is set to
"Swedish_Sweden" ?
Comment 6 Geert Janssens 2020-01-13 16:28:07 EST
Installers for nightly builds can be found here:
https://code.gnucash.org/builds/win32/maint/
Comment 7 Geert Janssens 2020-01-15 09:20:28 EST
Tested it myself and it's not working yet. I'm working on a followup patch.
Comment 8 Geert Janssens 2020-01-15 10:26:23 EST
Ok, this time I got it working. The fix will first appear in tomorrow's nightly build.
Comment 9 Johan von Boisman 2020-01-18 16:02:39 EST
I just tried with gnucash-3.8-2020-01-16-git-3.8b-52-ge91e84e7e+.setup.exe and it works fine!

A word on this LANG variable thing. I had never come across it in my ten+ years as a GnuCash (for Windows) user. Not until I began investigating this bug, so personally I don't see how it relates to this issue.

To test it, I first uninstalled GnuCash and deleted all related directories (Program (x86)), Users\NN\AppData  so no environment file existed. Then I installed the nightly build. When starting the program, it displayed in Swedish and the New book wizard correctly displays the account plans in the sv_SE folder.

It appears to work as I expect. Thanks!
Comment 10 Geert Janssens 2020-01-21 04:30:55 EST
That's good to hear.

And regarding LANG, it does seem like this is no longer an issue on our Windows builds. I did a similar test (setting Windows country and region settings to Swedish Sweden without setting any LANG variable) and that works as expected indeed. Apparently my suggestion in comment 4 was wrong.

Note You need to log in before you can comment on or make changes to this bug.