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

[nikohomecontrol] Prepare for translation #11319

Merged
merged 8 commits into from
Oct 23, 2021
Merged

Conversation

mherwege
Copy link
Contributor

@mherwege mherwege commented Sep 28, 2021

  • Externalize strings to properties file to allow translation as a next step.
  • Give listener thread a name.
  • Fixed SAT warning

Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
@lolodomo
Copy link
Contributor

lolodomo commented Oct 2, 2021

Please look at other bindings how they defined translations for thing type label/description or config parameter label/description. There is no need to add @text in you thing files. You have predefined properties automatically defined for that.
Take a look at the NTP binding as an example.

@lolodomo
Copy link
Contributor

lolodomo commented Oct 2, 2021

And please note that you did not use strictly the recommended thread name convention. The threads name should start by "OH-binding-" followied by the thing UID and optionally followed by an additional specific part in case you create several threads for the same thing.

@mherwege
Copy link
Contributor Author

mherwege commented Oct 3, 2021

Please look at other bindings how they defined translations for thing type label/description or config parameter label/description. There is no need to add @text in you thing files. You have predefined properties automatically defined for that.
Take a look at the NTP binding as an example.

@lolodomo Thank you for looking into this. I am well aware I do not strictly need the @text in my thing files. But if I understood well from #10635, I would then need to replicate all strings anyway for them to be picked up by Crowdin. I consider that prone to error when one makes a change and forgets to keep them in sync. Therefore I opted for the @text construct.

@mherwege
Copy link
Contributor Author

mherwege commented Oct 3, 2021

And please note that you did not use strictly the recommended thread name convention. The threads name should start by "OH-binding-" followied by the thing UID and optionally followed by an additional specific part in case you create several threads for the same thing.

@lolodomo, thank you for noticing, I didn’t look far enough in my research and will correct. Done

Signed-off-by: Mark Herwege <[email protected]>
@lolodomo
Copy link
Contributor

lolodomo commented Oct 9, 2021

@lolodomo Thank you for looking into this. I am well aware I do not strictly need the @text in my thing files. But if I understood well from #10635, I would then need to replicate all strings anyway for them to be picked up by Crowdin. I consider that prone to error when one makes a change and forgets to keep them in sync. Therefore I opted for the @text construct.

@cweitkamp : can you confirm that is the new way to go for all bindings ?!

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

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

Review comments excluding all stuff with @text

I have now like a doubt that this binding implemented a proper bridge/thing handling.

@lolodomo
Copy link
Contributor

lolodomo commented Oct 9, 2021

https://www.openhab.org/docs/concepts/things.html#thing-status

The statuses UNINITIALIZED, INITIALIZING and REMOVING are set by the framework, whereas the statuses UNKNOWN, ONLINE and OFFLINE are assigned from a binding.

@cweitkamp
Copy link
Contributor

@lolodomo Thank you for looking into this. I am well aware I do not strictly need the @text in my thing files. But if I understood well from #10635, I would then need to replicate all strings anyway for them to be picked up by Crowdin. I consider that prone to error when one makes a change and forgets to keep them in sync. Therefore I opted for the @text construct.

@cweitkamp : can you confirm that is the new way to go for all bindings ?!

According to our documentation this is a valid way to define translatable phrases. There are other bindings which are already designed in this way. There are no strict guidelines for the future way of localization and thus it is up to the developers to choose their favorite path. From my POV @mherwege arguments for his decision are strong and I personally agree on his opinion.

@lolodomo
Copy link
Contributor

lolodomo commented Oct 9, 2021

According to our documentation this is a valid way to define translatable phrases. There are other bindings which are already designed in this way. There are no strict guidelines for the future way of localization and thus it is up to the developers to choose their favorite path. From my POV @mherwege arguments for his decision are strong and I personally agree on his opinion.

I don't really like this choice being dictated by a tool (Crowdin) and the fact that we have 2 different ways of doing it, but if this is compliant with our coding rules, I will review (and approve) this part too. Thank you for the answer.

Signed-off-by: Mark Herwege <[email protected]>
@mherwege
Copy link
Contributor Author

@lolodomo Thank you for your review. I believe I have fixed all thing lifecycle issues. Can you review again?

@mherwege
Copy link
Contributor Author

I believe the build failure is not related to the binding.

@mherwege mherwege added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Oct 12, 2021
Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

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

Please avoid redundant calls to updateStatus.
I see something wrong in your thing handlers initialize(): you are checking the bridge status at the very end, even in the separate thread you are scheduling. In fact, it should be the first thing you should check at the beginning of the method initialize.

@lolodomo lolodomo added the awaiting feedback Awaiting feedback from the pull request author label Oct 22, 2021
Signed-off-by: Mark Herwege <[email protected]>
@mherwege
Copy link
Contributor Author

Sorry, I missed your review earlier. Thank you for the feedback.

Please avoid redundant calls to updateStatus.

I have removed these.

I see something wrong in your thing handlers initialize(): you are checking the bridge status at the very end, even in the separate thread you are scheduling. In fact, it should be the first thing you should check at the beginning of the method initialize.

I am a bit reluctant to touch this. It has been working well for many years for myself and other users. I made a few changes while doing the preparation to allow for translation, but this is becoming much bigger than anticipated. And that comes with added risk. I value your input, and it does make sense. But I don't want to risk destroying a working system.
If I understand well, initialize() in the thing handlers is called after initialize() for the bridge handler. The trigger is not for the bridge being online, just the initialize() method having finished. If I return from the thing handler initialize method at the start when the bridge is not online (and skip the rest of initialize), would initialize get called again when the bridge goes online? Or would I have to implement bridgeStatusChanged and put the initialization logic of the thing handler there?

@mherwege mherwege removed the awaiting feedback Awaiting feedback from the pull request author label Oct 22, 2021
@lolodomo
Copy link
Contributor

I am a bit reluctant to touch this. It has been working well for many years for myself and other users. I made a few changes while doing the preparation to allow for translation, but this is becoming much bigger than anticipated. And that comes with added risk. I value your input, and it does make sense. But I don't want to risk destroying a working system.

I agree that it could be changed in a separate PR, especially if this is currently working well.
I will look again to understand if this is just a not ideal implementation or if there is a serious risk. But yes, my feeling when I commented was more the first option.

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

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

One last thing to be fixed

@lolodomo lolodomo added enhancement An enhancement or new feature for an existing add-on translation labels Oct 22, 2021
Signed-off-by: Mark Herwege <[email protected]>
@mherwege
Copy link
Contributor Author

@lolodomo Many thanks for you torough review effort. I believe I have covered all your remarks.

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

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

LGTM

@lolodomo lolodomo merged commit e54797f into openhab:main Oct 23, 2021
@lolodomo lolodomo added this to the 3.2 milestone Oct 23, 2021
dschoepel pushed a commit to dschoepel/openhab-addons that referenced this pull request Nov 9, 2021
* Externalize strings to support translation

Signed-off-by: Mark Herwege <[email protected]>

* Name events thread.

Signed-off-by: Mark Herwege <[email protected]>

* Fix formatting

Signed-off-by: Mark Herwege <[email protected]>

* Fix SAT warning

Signed-off-by: Mark Herwege <[email protected]>

* Fix threadname

Signed-off-by: Mark Herwege <[email protected]>

* Fix thing lifecycle.

Signed-off-by: Mark Herwege <[email protected]>

* Adjustments from review.

Signed-off-by: Mark Herwege <[email protected]>

* Adjustment from review.

Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Dave J Schoepel <[email protected]>
@mherwege mherwege deleted the translation branch December 11, 2021 14:33
@mherwege mherwege restored the translation branch December 11, 2021 14:48
@mherwege mherwege deleted the translation branch December 11, 2021 14:50
@mherwege mherwege restored the translation branch December 11, 2021 15:18
@mherwege mherwege deleted the translation branch December 11, 2021 15:19
NickWaterton pushed a commit to NickWaterton/openhab-addons that referenced this pull request Dec 30, 2021
* Externalize strings to support translation

Signed-off-by: Mark Herwege <[email protected]>

* Name events thread.

Signed-off-by: Mark Herwege <[email protected]>

* Fix formatting

Signed-off-by: Mark Herwege <[email protected]>

* Fix SAT warning

Signed-off-by: Mark Herwege <[email protected]>

* Fix threadname

Signed-off-by: Mark Herwege <[email protected]>

* Fix thing lifecycle.

Signed-off-by: Mark Herwege <[email protected]>

* Adjustments from review.

Signed-off-by: Mark Herwege <[email protected]>

* Adjustment from review.

Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Nick Waterton <[email protected]>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Jan 28, 2022
* Externalize strings to support translation

Signed-off-by: Mark Herwege <[email protected]>

* Name events thread.

Signed-off-by: Mark Herwege <[email protected]>

* Fix formatting

Signed-off-by: Mark Herwege <[email protected]>

* Fix SAT warning

Signed-off-by: Mark Herwege <[email protected]>

* Fix threadname

Signed-off-by: Mark Herwege <[email protected]>

* Fix thing lifecycle.

Signed-off-by: Mark Herwege <[email protected]>

* Adjustments from review.

Signed-off-by: Mark Herwege <[email protected]>

* Adjustment from review.

Signed-off-by: Mark Herwege <[email protected]>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
* Externalize strings to support translation

Signed-off-by: Mark Herwege <[email protected]>

* Name events thread.

Signed-off-by: Mark Herwege <[email protected]>

* Fix formatting

Signed-off-by: Mark Herwege <[email protected]>

* Fix SAT warning

Signed-off-by: Mark Herwege <[email protected]>

* Fix threadname

Signed-off-by: Mark Herwege <[email protected]>

* Fix thing lifecycle.

Signed-off-by: Mark Herwege <[email protected]>

* Adjustments from review.

Signed-off-by: Mark Herwege <[email protected]>

* Adjustment from review.

Signed-off-by: Mark Herwege <[email protected]>
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 translation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants