openhab/openhab-core

On first-time start values from i18n.config ignored

dilyanpalauzov opened this issue · 9 comments

Before starting OpenHAB for the first time after the installation, I create this file /var/lib/openhab/config/org/openhab/i18n.config:

:org.apache.felix.configadmin.revision:=L"1"
language="de"
region="DE"
service.pid="org.openhab.i18n"
timezone="Europe/Berlin"

During the start, OpenHAB logs

2024-02-18 09:48:53.435 [INFO ] [org.openhab.core.Activator          ] - Starting openHAB 4.1.1 (build Release Build)
2024-02-18 09:49:20.917 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'Europe/Berlin'.
2024-02-18 09:49:20.945 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'de_DE'.
2024-02-18 09:51:02.893 [INFO ] [.core.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2024-02-18 09:51:18.852 [INFO ] [e.automation.internal.RuleEngineImpl] - Rule engine started.

Over the web interface I initialize the first-time setup by creating a user name. Then OH asks me to select Language, Region and Time Zone suggesting as default English/United States/GMT+1 Europe-Budapest. Once I re-select what I want, the i18n.config file differs from the original one only on its first line: :org.apache.felix.configadmin.revision:=L"2". If I however “Skip the Setup”, then i18n.config is left unmodified.

When I did something, which I do not remember anymore, i18n.config was changed to

:org.apache.felix.configadmin.revision:=L"2"
service.pid="org.openhab.i18n"

and then the OH log contained

2024-02-18 11:27:02.689 [INFO ] [p.auth.internal.AuthorizePageServlet] - First user account created: a
2024-02-18 11:27:13.210 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone is not set, falling back to the default time zone.
2024-02-18 11:27:13.256 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale is not set, falling back to the default locale

I expect that the suggested Language, Region and Timezone are taken from the i18n.config file and the user has the possibility easily to preserve the content of i18n.config. For the latter the current only option is to “Skip the setup”.

Before starting OpenHAB for the first time after the installation, I create this file /var/lib/openhab/config/org/openhab/i18n.config:

Create file named /var/lib/openhab/etc/org.openhab.i18n.cfg. The /var/lib/openhab/config/ is a "state" tracking reference directory, but not a storage directory. All state entries in /var/lib/openhab/config are being overridden by files which are shipped by distribution or defaults pushed through config dispatcher.

With this file /var/lib/openhab/etc/org.openhab.i18n.cfg

language="de"
region="DE"
service.pid="org.openhab.i18n"
timezone="Europe/Berlin"

I start OpenHAB for the very first time. Openhab.log contains then

2024-03-07 21:48:55.558 [INFO ] [org.openhab.core.Activator          ] - Starting openHAB 4.1.1 (build Release Build)
2024-03-07 21:49:21.278 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'Europe/Berlin'.
2024-03-07 21:49:21.321 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'de_DE'.

Then I load the webinterface to utilize the setup wizard. After creating username and password, the system lets me select preferred Language, Region and Time Zone. The suggested values are English, United States and Europe/Budapest. Thus the values from org.openhab.i18n.cfg are honoured on startup for OH internal stuff, but not by the setup wizard.

Maybe the issue could be renamed into "Regional settings provided through .cfg file ignored by the setup wizard on the very first start"

@florian-h05 : does your PR openhab/openhab-webui#2558 would fix the issue explained here in last message ?

It partly fixes the problem. Region and location are now loaded from the API, timezone and locale however are taken from the browser.
So if your browser locale and timezone differ from what's in the i18n file, this will be overriden by the setup-wizard.

It could be changed so that i18n config file takes priority over browser's settings, wich IMO would make sense. Do you agree?

I have created a fix for the setup wizard, now the i18n config file takes priority over everything else: openhab/openhab-webui#2559

It could be changed so that i18n config file takes priority over browser's settings, wich IMO would make sense. Do you agree?

Makes sense to me too.

@openhab/core-maintainers Can you please close this issue? I have merged the fix.