openhab-core icon indicating copy to clipboard operation
openhab-core copied to clipboard

On first-time start values from i18n.config ignored

Open dilyanpalauzov opened this issue 1 year ago • 2 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”.

dilyanpalauzov avatar Feb 21 '24 20:02 dilyanpalauzov

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.

splatch avatar Mar 06 '24 20:03 splatch

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.

dilyanpalauzov avatar Mar 07 '24 20:03 dilyanpalauzov

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

lolodomo avatar May 02 '24 10:05 lolodomo

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

lolodomo avatar May 02 '24 11:05 lolodomo

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.

florian-h05 avatar May 02 '24 11:05 florian-h05

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

florian-h05 avatar May 02 '24 11:05 florian-h05

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

florian-h05 avatar May 02 '24 11:05 florian-h05

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.

lolodomo avatar May 02 '24 11:05 lolodomo

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

florian-h05 avatar May 02 '24 12:05 florian-h05