diff --git a/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/BundleInfo.java b/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/BundleInfo.java index ef7a6d95db..b4ddf14186 100644 --- a/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/BundleInfo.java +++ b/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/BundleInfo.java @@ -33,12 +33,21 @@ import org.openhab.core.thing.xml.internal.ThingTypeXmlResult; @NonNullByDefault public class BundleInfo { + private String bindingId = ""; private @Nullable BindingInfoXmlResult bindingInfoXml; private List configDescriptions = new ArrayList<>(5); private List channelGroupTypesXml = new ArrayList<>(5); private List channelTypesXml = new ArrayList<>(5); private List thingTypesXml = new ArrayList<>(5); + public String getBindingId() { + return bindingId; + } + + public void setBindingId(String bindingId) { + this.bindingId = bindingId; + } + public @Nullable BindingInfoXmlResult getBindingInfoXml() { return bindingInfoXml; } @@ -79,11 +88,6 @@ public class BundleInfo { this.thingTypesXml = thingTypesXml; } - public String getBindingId() { - BindingInfoXmlResult localBindingInfoXml = bindingInfoXml; - return localBindingInfoXml == null ? "" : localBindingInfoXml.getBindingInfo().getUID(); - } - public Optional getConfigDescription(@Nullable URI uri) { if (uri == null) { return Optional.empty(); diff --git a/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/BundleInfoReader.java b/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/BundleInfoReader.java index 719a519445..d675ecc092 100644 --- a/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/BundleInfoReader.java +++ b/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/BundleInfoReader.java @@ -68,6 +68,7 @@ public class BundleInfoReader { try { BindingInfoXmlResult bindingInfoXml = reader.readFromXML(path.toUri().toURL()); if (bindingInfoXml != null) { + bundleInfo.setBindingId(bindingInfoXml.getBindingInfo().getUID()); bundleInfo.setBindingInfoXml(bindingInfoXml); } } catch (ConversionException | MalformedURLException e) { @@ -102,11 +103,23 @@ public class BundleInfoReader { } for (Object type : types) { if (type instanceof ThingTypeXmlResult) { - bundleInfo.getThingTypesXml().add((ThingTypeXmlResult) type); + ThingTypeXmlResult result = (ThingTypeXmlResult) type; + bundleInfo.getThingTypesXml().add(result); + if (bundleInfo.getBindingId().isBlank()) { + bundleInfo.setBindingId(result.getUID().getBindingId()); + } } else if (type instanceof ChannelGroupTypeXmlResult) { - bundleInfo.getChannelGroupTypesXml().add((ChannelGroupTypeXmlResult) type); + ChannelGroupTypeXmlResult result = (ChannelGroupTypeXmlResult) type; + bundleInfo.getChannelGroupTypesXml().add(result); + if (bundleInfo.getBindingId().isBlank()) { + bundleInfo.setBindingId(result.getUID().getBindingId()); + } } else if (type instanceof ChannelTypeXmlResult) { - bundleInfo.getChannelTypesXml().add((ChannelTypeXmlResult) type); + ChannelTypeXmlResult result = (ChannelTypeXmlResult) type; + bundleInfo.getChannelTypesXml().add(result); + if (bundleInfo.getBindingId().isBlank()) { + bundleInfo.setBindingId(result.toChannelType().getUID().getBindingId()); + } } } } catch (ConversionException | MalformedURLException e) { diff --git a/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/XmlToTranslationsConverter.java b/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/XmlToTranslationsConverter.java index b56f4e29d3..394a6869d1 100644 --- a/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/XmlToTranslationsConverter.java +++ b/tools/i18n-plugin/src/main/java/org/openhab/core/tools/i18n/plugin/XmlToTranslationsConverter.java @@ -51,8 +51,8 @@ import org.openhab.core.types.StateDescription; public class XmlToTranslationsConverter { public Translations convert(BundleInfo bundleInfo) { - BindingInfoXmlResult bindingInfoXml = bundleInfo.getBindingInfoXml(); - return bindingInfoXml == null ? configTranslations(bundleInfo) : bindingTranslations(bundleInfo); + String bindingId = bundleInfo.getBindingId(); + return bindingId.isBlank() ? configTranslations(bundleInfo) : bindingTranslations(bundleInfo); } private Translations bindingTranslations(BundleInfo bundleInfo) {