Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[knx] Improve localization #13293

Merged
merged 5 commits into from
Oct 11, 2022
Merged

Conversation

holgerfriedrich
Copy link
Member

@holgerfriedrich holgerfriedrich commented Aug 19, 2022

- introduce localization of error messages
- add new strings for common exceptions
- provide helper functions for translation
- add test cases

Signed-off-by: Holger Friedrich mail@holger-friedrich.de

@holgerfriedrich holgerfriedrich added enhancement An enhancement or new feature for an existing add-on work in progress A PR that is not yet ready to be merged labels Aug 19, 2022
@holgerfriedrich
Copy link
Member Author

This is still work in progress. It adds German translations to the KNX binding.

I would appreciate any feedback on the general approach how to add the translations.

  1. property files: German translations are based on latest Crowdin export. Is it a valid approach to copy the export to get a start for a new language?
  2. property files: I have added a few lines which are not part of the offical binding yet. If I got it correctly, I should get this into knx.propeties. Once it is merged on master, it will show up on Crowdin and can be translated. When will the automatic PR process start for a language? What is the trigger for the automatic PR process? Who approves the changes on Crowdin?
  3. property files: Will the automatic PR process wipe out all unknown lines?
  4. property files: Any hints regarding namespace for additional strings/error messages?
  5. LocaleProvider.getlocale() -> will it always return the same locale or does this change dynamically?

Thanks!

@holgerfriedrich holgerfriedrich marked this pull request as draft August 19, 2022 20:50
@holgerfriedrich
Copy link
Member Author

@lolodomo could you give some input to the questions above or recommend whom to ask? Thanks!

@jlaur
Copy link
Contributor

jlaur commented Sep 22, 2022

I would appreciate any feedback on the general approach how to add the translations.

This page might also shed some light: https://www.openhab.org/docs/developer/utils/i18n.html#managing-translations

  1. property files: German translations are based on latest Crowdin export. Is it a valid approach to copy the export to get a start for a new language?

I don't understand this question, can you elaborate?

  1. property files: I have added a few lines which are not part of the offical binding yet. If I got it correctly, I should get this into knx.propeties. Once it is merged on master, it will show up on Crowdin and can be translated.

Yes.

When will the automatic PR process start for a language?

At least once per day.

What is the trigger for the automatic PR process?

I believe it's a time trigger, but it can also be triggered manually by admins.

Who approves the changes on Crowdin?

Preferably proof-readers, but I'm not sure we have many yet. So actually, this question I cannot answer - @lolodomo, can you?

  1. property files: Will the automatic PR process wipe out all unknown lines?

Yes.

  1. property files: Any hints regarding namespace for additional strings/error messages?

Each binding has its own namespace, so you don't need to use any prefixes to secure uniqueness. Best advice for custom texts would be to try to avoid potential conflicts with framework-generated strings/prefixes.

  1. LocaleProvider.getlocale() -> will it always return the same locale or does this change dynamically?

It will change dynamically when user changes regional settings.

@holgerfriedrich
Copy link
Member Author

@jlaur thanks for the feedback.
I think I will add a test and then set this PR to ready for review the next days.

I would appreciate any feedback on the general approach how to add the translations.

  1. property files: German translations are based on latest Crowdin export. Is it a valid approach to copy the export to get a start for a new language?

I don't understand this question, can you elaborate?

This was about how to introduce a new language to a binding. Is it intended to download the property file for the new language from Crowdin and add it to the binding - and after this the bot takes over for further updates? Or should I just add empty files like knx_de.properties and the bot will take over as well?

Who approves the changes on Crowdin?

Preferably proof-readers, but I'm not sure we have many yet. So actually, this question I cannot answer - @lolodomo, can you?

That would be interesting. We seem to have unapproved translations for KNX (de). According to the docs the bot will not include them, correct?

@jlaur
Copy link
Contributor

jlaur commented Sep 25, 2022

  1. property files: German translations are based on latest Crowdin export. Is it a valid approach to copy the export to get a start for a new language?

I don't understand this question, can you elaborate?

This was about how to introduce a new language to a binding. Is it intended to download the property file for the new language from Crowdin and add it to the binding - and after this the bot takes over for further updates? Or should I just add empty files like knx_de.properties and the bot will take over as well?

Neither. New languages are automatically provided from Crowdin.

Who approves the changes on Crowdin?

Preferably proof-readers, but I'm not sure we have many yet. So actually, this question I cannot answer - @lolodomo, can you?

That would be interesting. We seem to have unapproved translations for KNX (de). According to the docs the bot will not include them, correct?

Correct.

@holgerfriedrich
Copy link
Member Author

This was about how to introduce a new language to a binding. Is it intended to download the property file for the new language from Crowdin and add it to the binding - and after this the bot takes over for further updates? Or should I just add empty files like knx_de.properties and the bot will take over as well?

Neither. New languages are automatically provided from Crowdin.

@jlaur For me it is still not clear what actually triggers a new language file to be added in the first place. For example, there is a knx.properties, but no file knx_de.properties in resources/OH-INF/i18n yet. Though there are translations available at Crowdin, the bot does not create a PR. I suppose this is because knx_de.properties does not exist.

@jlaur
Copy link
Contributor

jlaur commented Sep 25, 2022

For me it is still not clear what actually triggers a new language file to be added in the first place. For example, there is a knx.properties, but no file knx_de.properties in resources/OH-INF/i18n yet. Though there are translations available at Crowdin, the bot does not create a PR. I suppose this is because knx_de.properties does not exist.

The important sentence from the documentation is this one: "Please note that all texts must be translated and approved in order to be included." So for a language to be included in PR's created from Crowdin, 100% of strings must be translated, and 100% must be approved. So it is not because knx_de.properties does not exist, but because at least one of those criteria are not fulfilled.

In German only 82% are approved. @cweitkamp, would you be able to have a look at the pending knx translations and/or possible shed some more light on the approval process?

@cweitkamp
Copy link
Contributor

In German only 82% are approved. @cweitkamp, would you be able to have a look at the pending knx translations and/or possible shed some more light on the approval process?

Done.

@jlaur
Copy link
Contributor

jlaur commented Sep 26, 2022

@holgerfriedrich - the German translation is now merged: #13448.

@holgerfriedrich holgerfriedrich force-pushed the pr-knx-locale-de branch 3 times, most recently from 0fecab5 to 95b5233 Compare September 28, 2022 06:58
@holgerfriedrich holgerfriedrich changed the title [knx] German locale [WIP] [knx] Improve localization Sep 28, 2022
- introduce localization of error messages
- add new strings for common exceptions
- provide helper functions for translation
- add test cases

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
@holgerfriedrich holgerfriedrich removed the work in progress A PR that is not yet ready to be merged label Sep 28, 2022
@holgerfriedrich
Copy link
Member Author

thanks, @cweitkamp !
@jlaur I added test cases and removed knx_de.properties from the commit as it is now already merged. I will introduce new strings via CrowdIn once this PR is merged. I took over you mock classes from hdpowerview.

@holgerfriedrich holgerfriedrich marked this pull request as ready for review September 28, 2022 18:10
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
@holgerfriedrich
Copy link
Member Author

@kaikreuzer could you please have a look? I'd Like to close this before getting deeper into the data secure topic again... Thanks!

Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've added some feedback. Perhaps @kaikreuzer would like to have a second look.

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
@holgerfriedrich
Copy link
Member Author

@jlaur thanks for the review! I think I addressed all of your comments. I left one conversation open, explaining why I used the enum to implement the singleton.

@kaikreuzer
Copy link
Member

@kaikreuzer could you please have a look?

@jlaur is the much better reviewer for this, so he can merge right away once he is done.

@holgerfriedrich holgerfriedrich requested a review from jlaur October 10, 2022 19:46
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some minor comments. Let's merge after you had a chance to have a look. :-)

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
@holgerfriedrich
Copy link
Member Author

holgerfriedrich commented Oct 10, 2022

I've added some minor comments. Let's merge after you had a chance to have a look. :-)

@jlaur, thanks. Finally, you convinced me to exchange the strings for the unit test :-)

@holgerfriedrich holgerfriedrich requested a review from jlaur October 10, 2022 22:22
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@jlaur jlaur merged commit 4e69e17 into openhab:main Oct 11, 2022
@jlaur jlaur added this to the 3.4 milestone Oct 11, 2022
@holgerfriedrich holgerfriedrich deleted the pr-knx-locale-de branch October 11, 2022 19:18
@holgerfriedrich
Copy link
Member Author

@cweitkamp maybe you could approve the translations for the new strings introduced in this PR once again? I have uploaded German translations to Crowdin. Thanks!

@cweitkamp
Copy link
Contributor

@cweitkamp maybe you could approve the translations for the new strings introduced in this PR once again?

Done.

andan67 pushed a commit to andan67/openhab-addons that referenced this pull request Nov 6, 2022
* [knx] Improve localization

- introduce localization of error messages
- add new strings for common exceptions
- provide helper functions for translation
- add test cases

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Nov 12, 2022
* [knx] Improve localization

- introduce localization of error messages
- add new strings for common exceptions
- provide helper functions for translation
- add test cases

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
borazslo pushed a commit to borazslo/openhab-mideaac-addon that referenced this pull request Jan 8, 2023
* [knx] Improve localization

- introduce localization of error messages
- add new strings for common exceptions
- provide helper functions for translation
- add test cases

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Feb 23, 2023
* [knx] Improve localization

- introduce localization of error messages
- add new strings for common exceptions
- provide helper functions for translation
- add test cases

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Feb 28, 2023
* [knx] Improve localization

- introduce localization of error messages
- add new strings for common exceptions
- provide helper functions for translation
- add test cases

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants