[Solved] OpenOffice jodconverter Conversion: Wrong Locale

Discuss setup / installation issues - Add a spell checker, Language pack?
Post Reply
pavelpipovic
Posts: 3
Joined: Mon May 07, 2018 8:34 am

[Solved] OpenOffice jodconverter Conversion: Wrong Locale

Post by pavelpipovic »

Hello,

at work I am dealing with a strange issue.

I am trying to convert a spreadsheet using the good old jodconverter into a PDF.
This works, except for one minute detail.

Unfortunately, the locale settings for number conversion are not taken into consideration.
E.g.: I have a number 10.90. The spreadsheet file (LibreOffice 5, OpenOffice 3 and Microsoft Excel) displays this as "10,90" (this is what I expect, since this corresponds with the locale setting within the file and even the Operating System). After converting it with the jodconverter the displayed value in the PDF is 10.90.

TL;DR: Number value in spreadsheet: 10.90, Displayed as (in spreadsheet): 10,90 (this is expected), JodConverter PDF export: 10.90 (this not expected)

On another installation [1] this works as expected.
I installed a different language for OpenOffice3, this did not help.
I have set the locale as explained here, this did not help. https://wiki.openoffice.org/wiki/Docume ... e_settings
I suspect that somewhere the locale settings are not loaded as expected.

TL;DR: Looked through wiki / web to find the common places to change Locale/Language settings to no avail.

During debug I can see that this process is running:

Code: Select all

/opt/openoffice.org3/program/soffice.bin -accept=socket,host=127.0.0.1,port=2002;urp; -env:UserInstallation=file:///tmp/.jodconverter_socket_host-127.0.0.1_port-2002 -headless -nocrashreport -nodefault -nofirststartwizard -nolockcheck -nologo -norestore
My question is: Where is this process loading its locale settings from?

* I suspect that these have to come either from the program settings itself, but changing the language/locale settings did not fix my issue.
* Thus I suspect it loads those from somewhere else (I suspected the OS, but I was not able to prove this).
* Is there something like a config file/registry where this is stored?

TL;DR: Where is OpenOffice loading its Locale Settings from?

[1] (Microsoft Windows, OpenOffice 3, JodConverter, Windows Locales + language are/is set to German)
Last edited by pavelpipovic on Wed May 09, 2018 8:43 am, edited 1 time in total.
OpenOffice 3 on Ubuntu 18.04
LibreOffice 6 on Ubuntu 18.04
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OpenOffice jodconverter Conversion: Wrong Locale

Post by Villeroy »

I know nothing about the old jodconverter.

The XML configuration node "/org.openoffice.Setup/L10N" with property "ooSetupSystemLocale" is represented by the locale setting in the options dialog. The language of the user interface is misleadingly named "ooLocale".
Recent versions of Libre/OpenOffice store these nodes in a single file registrymodifications.xcu. Older versions have a hierarchy of xcu files. The API to access these values did not change.

By default, the locale is taken from the OS locale but not the individual settings of that locale. It reads from the OS registry or environment variables that "de-DE" is set and then it applies its own settings for "de-DE" disregarding any customizations on OS level. The locale setting in the GUI reads "Default -- German (Germany)". In this case, the "ooSetupSystemLocale" in the XML configuration is an empty value because it is taken from the OS. If I recall correctly, the locale defaults to "en-US" if the OS locale can not be determined for some reason.

You can choose to ignore the OS locale and select "German (Germany)" explicitly without the "Default -- " prefix. In this case the "ooSetupSystemLocale" is set to "de-DE".
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
pavelpipovic
Posts: 3
Joined: Mon May 07, 2018 8:34 am

Re: OpenOffice jodconverter Conversion: Wrong Locale

Post by pavelpipovic »

Hi Villeroy,

thank you so much for your time and for your reply.

I checked my registrymodifications.xcu. The locale in the property: "ooSetupSystemLocale" is set to "de-DE".
My jodconverter also runs under my user (so I assume that it is also reading the registrymodifications.xcu file from under my user profile located in /home/pavel/.openoffice.org/3/user/registrymodifications.xcu).

I can see that the jodconverter fires up a headless openoffice3 instance and communicates with it through a socket. I suppose that this headless start might be the source of my problems, since I tried to actually open the spreadsheet with my local openoffice3 and simply export it as a PDF and it worked flawlessly.

This might mean that there is a problem between the communication of jodconverter and openoffice3.

Is there any way to check the locale that the headless version is using using the CLI?
OpenOffice 3 on Ubuntu 18.04
LibreOffice 6 on Ubuntu 18.04
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OpenOffice jodconverter Conversion: Wrong Locale

Post by Villeroy »

You can set an environment variable like this:

Code: Select all

LANG=de_DE.UTF-8 /opt/openoffice.org3/program/soffice.bin -accept=socket,host=127.0.0.1,port=2002;urp; -env:UserInstallation=file:///tmp/.jodconverter_socket_host-127.0.0.1_port-2002 -headless -nocrashreport -nodefault -nofirststartwizard -nolockcheck -nologo -norestore
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
pavelpipovic
Posts: 3
Joined: Mon May 07, 2018 8:34 am

Re: OpenOffice jodconverter Conversion: Wrong Locale

Post by pavelpipovic »

Hello Villeroy,

once more thanks for your input.

Yes, indeed - you are right. I passed this into the ProcessBuilder and now it does work.

I had to fix this in jodconverter though, since its the one that fires up the process.

Code: Select all

    // github: https://github.com/mirkonasato/jodconverter/
    // OfficeProcess.java
    command.add("-norestore");
    ProcessBuilder processBuilder = new ProcessBuilder(command);
    if (PlatformUtils.isWindows()) {
         addBasisAndUrePaths(processBuilder);
    }
    // My added Code:
    Map<String, String> env = processBuilder.environment();
    env.put("LANG", "de_DE.UTF-8");
   // Rest untouched...
This solved my issue.

A fork that implements this bugfix can be found here: https://github.com/pavelpipovic/jodconverter
Then you could do:

Code: Select all

// With the above fork, you can do this wherever you instantiate your OfficeManager
DefaultOfficeManagerConfiguration defaultOfficeManagerConfig = new DefaultOfficeManagerConfiguration();
// ...
defaultOfficeManagerConfig.addEnvironmentVariable("LANG", "de_DE.UTF-8");
// ...
OfficeManager officeManager = defaultOfficeManagerConfig.buildOfficeManager();
officeManager.start();
// ...
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
// This converter will now have the correct Locales set.
OpenOffice 3 on Ubuntu 18.04
LibreOffice 6 on Ubuntu 18.04
Post Reply