Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

PaperUI: translations of "description" is ignored #2589

Closed
MHerbst opened this issue Dec 3, 2016 · 8 comments
Closed

PaperUI: translations of "description" is ignored #2589

MHerbst opened this issue Dec 3, 2016 · 8 comments

Comments

@MHerbst
Copy link
Contributor

MHerbst commented Dec 3, 2016

I have set the language and locale to "German" resp. "de_DE". The PaperUi shows the translated names of the things but the "...description" entries in the properties file are ignored.

This is an example from the Yahoo Weather binding:
image

@kaikreuzer
Copy link
Contributor

Did you set the locale of your runtime or the locale of the Paper UI (in Preferences menu)?

@MHerbst
Copy link
Contributor Author

MHerbst commented Dec 4, 2016

I set everything in the Paper UI (under Preferences I selected German and under System/Locale I set the locale to de_DE).
I tried it again this morning and have some additional information that may help. For the Homematic things the display texts are correct under Things/Configuration:
image

BTW: as you can see in the screenshot also the name of Yahoo binding and its description is not shown in the correct language.

The Homematic binding does not use the i18n properties files. So it seems that the problem happens only with i18n properties files.

@MHerbst
Copy link
Contributor Author

MHerbst commented Dec 12, 2016

I have some additional information from some tests with the REST API. IF I execute this request with "Accept-Language" set to "de"

curl -X GET --header "Accept: application/json" --header "Accept-Language: de" "http://127.0.0.1:8080/rest/bindings"

I get the correct german description for the binding. If I set "Accept-Language" to "de_DE" or if I leave it empty the english text is returned.

@kaikreuzer
Copy link
Contributor

Thanks for the analysis. So it is clearly not an issue of the Paper UI, but rather a bug on the server side / REST API.

@MHerbst
Copy link
Contributor Author

MHerbst commented Dec 14, 2016

It seems so, but I not absolutely sure yet. Maybe it is combination of Paper/Basic UI and server side. In my test I create an own REST request.
I have planned to perform more tests and log the REST request that were executed by Basic and Paper UI with different combinations of language and locale.

@MHerbst
Copy link
Contributor Author

MHerbst commented Dec 16, 2016

@kaikreuzer I have executed some more tests and to me it looks like there is a either problem with the language string passed to methods implementing the REST API or the method that tries to parse the language is implemented too simple. In my test environment I used a fresh openHAB installation (Build 644), no explicit locale was set and language in preferences was set to "German" (same as the browser language).

I have debugged method org.eclipse.smarthome.io.rest.core.binding.BindingResource#getAll and these are the results:

Test 1: REST request with explicit "Accept-Language: de" ()

curl -X GET --header "Accept: application/json" --header "Accept-Language: de" "http://127.0.0.1:8080/rest/bindings"

The parameter language contains the value "de" and a correct locale is constructed from the language and so the results are OK.

Test 2: REST request without "Accept-Language"

curl -X GET --header "Accept: application/json" "http://127.0.0.1:8080/rest/bindings"

Now parameter language contains this value de,en-US;q=0.8,en;q=0.6 and the method created a locale from this language:
image

To me this does not look like a valid locale.

Test 3: I opened URL http://127.0.0.1:8080/ui/index.html#/configuration/bindings
Parameter language again has this value: "de,en-US;q=0.8,en;q=0.6"

Test 4: Set locale to de_DE and performed "Test 3" again
Same result as Test 3.

Test 5: Similar to Test 2 but with a browser that uses english as language
Now parameter language contains value "en-US,en;q=0.5". This will work correct because "en" is separated from the string and then used as locale:
image
This is a correct definition.

Test 6: English browser with preference language set to "German" and then I openend URL http://127.0.0.1:8080/ui/index.html#/configuration/bindings
Language has the value "en-US,en;q=0.5".

This explains why locales other then english do not work correct. Either the content of the language string passed to server is wrong or method LocaleUtil#getLocale (that simply splits the language string at the first "-" to get the language) does not fit to the content of the language string.

Another result of my test is that the language setting under "Preferences" seems not to work because always the browser language is used.
BTW: why these different ways to set a language? We have the browser language, the language that can be set under Preferences and also the locale definition under System. The locale definition is important because it defines more then just language. But is the language under Preferences really necessary?

Before performing further tests and fixing the other issues related to locales I think this problem needs to be solved.

@MHerbst
Copy link
Contributor Author

MHerbst commented Dec 23, 2016

I have created a PR (#2699) that solves this problem that is caused by the wrong interpretation of the Accept-Language HTTP header. But the language handling in Paper UI in general seems not to work correct (e.g. the preferences settings seems to be ignored). I will do some further testing and create a new issue for that.

@MHerbst
Copy link
Contributor Author

MHerbst commented Jan 7, 2017

This problem was solved with PR #2699. For the problem with the ignored preference setting I have create a new issue: #2777

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants