Fix translation of label for system:addons service (#4306)

The i18n file containing this label is in org.openhab.core bundle.

Fix openhab/openhab-webui#1669

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo
2024-09-08 06:13:58 +02:00
committed by GitHub
parent edf5b62213
commit 3e912eca4b
@@ -54,6 +54,7 @@ import org.openhab.core.io.rest.core.config.ConfigurationService;
import org.openhab.core.io.rest.core.service.ConfigurableServiceDTO;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -307,7 +308,11 @@ public class ConfigurableServiceResource implements RESTResource {
String key = I18nUtil.stripConstantOr(defaultLabel,
() -> inferKey(configurableService.description_uri(), "label"));
String label = i18nProvider.getText(serviceReference.getBundle(), key, defaultLabel, locale);
// i18n file containing label for system:addons service is exceptionally located in bundle
// org.openhab.core (and not in bundle org.openhab.core.addon.eclipse)
String label = i18nProvider.getText("system:addons".equals(configurableService.description_uri())
? FrameworkUtil.getBundle(OpenHAB.class)
: serviceReference.getBundle(), key, defaultLabel, locale);
String category = configurableService.category();