-
Notifications
You must be signed in to change notification settings - Fork 780
Duplicate code for i18n in automation.providers and config.core bundles #922
Comments
@danchom @marinmitev Could you have a look at this? Do we have a way to remove the duplicate code? |
@adimova is working on this, it seems to be possible to avoid the duplication |
using the URI objects from org.eclipse.smarthome.config.core.i18n.ConfigDescriptionI18nUtil adds limitation to the characters used in the rules/moduletypes/templates UIDs. Such an example is the '_' symbol which is used in several places: ItemStateEvent_ON_Condition in file /org.eclipse.smarthome.automation.module.core/ESH-INF/automation/moduletypes/ItemEventConditionModuleTypeDefinition.json |
…core bundles eclipse-archived#922 Signed-off-by: Ana Dimova <a.dimova@prosyst.bg>
So far, we defined UIDs to be of this pattern: https://github.com/eclipse/smarthome/blob/d0dde874a4e8024b9b4c075720a986d68587bf06/bundles/core/org.eclipse.smarthome.core.thing/src/main/java/org/eclipse/smarthome/core/thing/UID.java#L24 Where exactly do you come across exceptions when using underscores in the UID? |
I defined keys for localization of the automation objects: I construct the configDescriptionURI as module-type.{moduleTypeUID}:param to receive the keys: module-type.{moduleTypeUID}.config.param.{parameterName}.label; and as rule-template.{RuleTemplateUID}:param to receive the keys: rule-template.{RuleTemplateUID}.config.param.{parameterName}.label; rule-template.{RuleTemplateUID} and module-type.{moduleTypeUID} are treated as scheme in ConfigDescriptionI18nUtil.inferKey(URI configDescriptionURI, String parameterName, String lastSegment) and this leads to runtime exceptions URISyntaxException |
Could you pls provide an example of {RuleTemplateUID} and {moduleTypeUID} which throws an URISyntaxException... I would like to reproduce it... |
if you use the commit c0dc375 and run the configuration "SmartHome Runtime", use the console command "smarthome automation listModuleTypes", you will receive the exception message: which is in the file "ESH_INF/automation/moduletypes/ItemEventConditionModuleTypeDefinition.json" in bundle org.eclipse.smarthome.automation.module.core |
and we still can use this pattern: https://github.com/eclipse/smarthome/blob/d0dde874a4e8024b9b4c075720a986d68587bf06/bundles/core/org.eclipse.smarthome.core.thing/src/main/java/org/eclipse/smarthome/core/thing/UID.java#L24, but without underscore |
@tomhoefer I think the problem is if a module type UID contains an _ and we create a configDescriptionURI from that. |
I have to check.... |
There is no special logic to build the config description URI from thing-types that consist of an underscore. So having an underscore in the thing-type will result in a config description URI with an underscore. |
@tomhoefer As @marinmitev points out in #922 (comment), underscores are not a valid character for URIs, so you are hence doing it wrong, which needs to be fixed. Is your code not using the constructor of URI? If it does, it should also fail with an exception. |
According to chapter 2.3 of RFC 2396 the underscore belongs to the unreserved characters that are allowed in URIs Furthermore there is also no problem to execute the following simple main operation:
Maybe I still don´t get the issue.... |
Ok... I see the problem now.... |
I made changes in the way I construct the keys for localization that fixes the problem for automation module |
The problem is the underscore in the scheme.... So
cannot be parsed. Is it possible to exchange / replace the underscore in the module type ID? |
This was my first proposition but Kai regect it, so I changed the way to construct the keys. They are now: |
your change fixes the URISyntaxException, correct? |
I am very confused now. @adimova, where did you ever have an underscore within the URI scheme? Can you give a concrete example? |
yes, now Module Type UIDs participate only to the Scheme Specific Part and can contain "_" |
in the first way the constructed URI was module-type.ItemStateEvent_ON_Condition:param and the scheme was "module-type.ItemStateEvent_ON_Condition" and Scheme Specific Part - "param", now the URI will be "module-type:ItemStateEvent_ON_Condition.name" where the scheme will be "module-type" and the Scheme Specific Part - "ItemStateEvent_ON_Condition.name" |
Ok, so the "first way" never made sense, as the scheme should only be the entity type as it is given in https://www.eclipse.org/smarthome/documentation/development/bindings/xml-reference.html#xml-structure-for-configuration-descriptions. |
Signed-off-by: Ana Dimova <a.dimova@prosyst.bg>
Before the contribution of the automation bundles the config.core bundle was the single point in ESH to internationalize config descriptions and their parameters. Now the automation.providers bundle contains also an utility to internationalize config description parameters. This utility should be removed and the utility of the config.core bundle should be used instead.
One problem having two i18n utilities for the configuration description parameters is that is not possible to internationalize the unit and the unit label with the i18n utility of the automation.providers bundle. The reason for this is that the unit.properties is only available in the config.core bundle.
The text was updated successfully, but these errors were encountered: