-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[mielecloud] Fix i18n in addon.xml #14310
Conversation
Signed-off-by: Mark Hilbush <[email protected]>
BTW, this problem may exist in other bindings. If this is the correct fix, I can submit a another PR for the others.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is correct, nice catch. It would be much appreciated if you want to fix the other bindings as well.
Certainly. I'll submit a PR for the rest of them. |
Signed-off-by: Mark Hilbush <[email protected]>
Signed-off-by: Mark Hilbush <[email protected]>
Signed-off-by: Mark Hilbush <[email protected]>
@mhilbush @jlaur could you please help me understand / point me to what addon.xml is used for / by, specifically the actual string that we entered inside addon.xml
I understand that there's My current understanding is that as long as The only time it matters what is entered inside addon.xml is the fact that the content of addon.xml is collected for all the addons, and combined into /runtime/etc/addons.xml which is used by AddonInfoAddonsXmlProvider Oh, and also when you run the i18n tools, it would read what's in the addon.xml to generate the .properties file. @merwege I understand you encountered problems with this in openhab/openhab-core#3908 So:
All this is so we can have addons description even for uninstalled addons in the UI -> So that we can search in their description, see openhab/openhab-webui#3028 Once again, I still don't understand all this, so I'd appreciate any pointers and corrections. |
@jlaur @mhilbush I don't think you can make this assumption by just looking at the addon.xml file. The key there just needs to match the key in the properties file. You have the |
@jimtng openhab/openhab-core#3908 fixes an issue that was discovered after openhab/openhab-core#3865. The fundamental problem is that i8n info for binding is only available after loading the binding jar or kar, as it is part of the jar. Just reading the addon.xml file will never give that information. But there is another source for binding name and description from the bundle list. So instead of trying to read it from the addon.xml, it just uses it from the bundle list. This will of course never be translated. That mechanism then also copes with any string reference you use in the addon.xml file. So I don't think there is much to do here, except making sure the string keys are the same in the addon.xml and properties files. But the impact is only when the binding is already installed, not in the addon discovery phase. |
@mherwege, thanks for the extra info.
What is this? I'm guessing this is the Karaf addons info which gets its data from the feature list. If this is the case, it does not have description, only label/name (which is called "description" but it's the same as "name" in addon.xml) - I know you already knew this... I'm just restating it here for my own clarity.
Could you elaborate this for me please
Yes, I figured this out too, and I am contemplating this, or some (limited) variations of it. With all this, could you please confirm whether this is correct (inside addon.xml), and who would actually perform the translation for it:
From my tests, it really doesn't matter if I entered any rubbish in it, e.g.
Once the binding is built into a jar, everything I know of would report the name/description from what's inside the |
Yes, indeed, the feature list. And you are right. That does not include the addon descriptions.
I am not an expert on i8n, but my understanding is this uses a standard Java mechanism. In OH we have the
Even after installing the binding? I am surprised by that. I would expect the code to use the TranslationProvider to pick up the translation from the key in addon.xml to the properties file. |
Thanks for the pointers!
Yes, I believe so. I checked this by writing code (in jruby) that queries
I don't think that's necessary? My code requests specific locales in the call to getAddons(locale) and getAddonInfo(id, locale), and I can confirm I am seeing the different languages being returned in the description.
Thank you! That really says that if you entered anything but So given this fact, why don't we just populate all addon.xml with the actual text, which we can then use in Of course, in the conversion process of addon.xml, we'll need to ensure any replacements will still result in the same text for translation purposes. WDYT? |
IMHO that would be great. For completeness, I'll just add that in theory you have no redundancy when having: openhab-addons/bundles/org.openhab.binding.mielecloud/src/main/resources/OH-INF/addon/addon.xml Lines 7 to 8 in d0b918e
pointing towards: Lines 2 to 3 in d0b918e
With: <name>Miele@home Cloud Binding</name>
<description>This is the cloud-based Miele@home binding.</description> you have the same strings in two places. OTOH, with the i18n:generate-default-translations approach we can consider the properties file as (partially) auto-generated rather than manually created, so the redundancy shouldn't matter as long as we remember to run the tool after changing texts. This also dramatically reduces the risk of human mistakes of providing invalid |
So this would mean:
From reading through the code, I believe the name and description should then be available in English when the addon is not installed, and in local language when it gets installed. We might want a script to run to make these changes to all addons in the repository in one go. |
There aren't that many. I can do it manually. It's just a one-off operation. |
Indeed. This is why I was confused when I discovered this A case when this |
And it is also handy when you need string replacements inside the string to be translated. But again, this does not apply for the binding name and description.
When you do that, can you also try to check if there are already translations to keep these? Or would they have to be redone in Crowdin anyway to stay in sync? |
Already started doing this. Found only 11 bindings. I was told not to touch the other languages, so I'll only change the main .properties (if needed) |
The addon info merge treats what is coming from addon.xml as non-master and something coming from a bundle as master. This is to make sure the translations are applied. If it comes from addon.xml, it cannot be applied. If it comes from a jar, translations could be there. So as this is the same addon id, I think this is acceptable here. |
What are these issues? Maybe create an issue for them. |
I noticed that the JarFileAddonService doesn't utilise localization. I haven't fully delved into it though as I didn't want to go on a tangent every time I found something odd (at least to me). |
I guess the issue here is that the karaf / official addons should not be mixed up with jar addons. But it's not a big issue, so I'm happy to let it be for now. Theoretically someone can build a bunch of bogus jar addons that would override official bindings' name / descriptions. |
Fix i18n tags in addon.xml so binding name and description displays correctly in binding list.
Signed-off-by: Mark Hilbush [email protected]