diff --git a/bundles/org.openhab.ui.dashboard/build.properties b/bundles/org.openhab.ui.dashboard/build.properties index 20930b404..cea28d9af 100644 --- a/bundles/org.openhab.ui.dashboard/build.properties +++ b/bundles/org.openhab.ui.dashboard/build.properties @@ -4,5 +4,6 @@ bin.includes = META-INF/,\ OSGI-INF/,\ web/,\ templates/,\ - about.html + about.html,\ + ESH-INF/ source.. = src/main/java/ diff --git a/bundles/org.openhab.ui.dashboard/src/main/java/org/openhab/ui/dashboard/internal/DashboardService.java b/bundles/org.openhab.ui.dashboard/src/main/java/org/openhab/ui/dashboard/internal/DashboardService.java index fcfa4ec62..41181756e 100644 --- a/bundles/org.openhab.ui.dashboard/src/main/java/org/openhab/ui/dashboard/internal/DashboardService.java +++ b/bundles/org.openhab.ui.dashboard/src/main/java/org/openhab/ui/dashboard/internal/DashboardService.java @@ -233,19 +233,19 @@ public class DashboardService { * fall-back would be present it returns the key. * * @param key key to get locale from - * @param locale known locale * @return localized text for the key */ - private String getLocalizedText(String key, Locale locale) { - Locale useLocale = locale == null ? localeProvider.getLocale() : locale; + private String getLocalizedText(String key) { + Locale useLocale = localeProvider.getLocale() == null ? Locale.ENGLISH : localeProvider.getLocale(); if ("locale".equals(key)) { // The return value for "locale" key is an ISO 639-1 language code // In case there is no translation for the used locale provided with the dashboard, "en" is returned return bundleContext.getBundle() .getEntry("ESH-INF/i18n/dashboard_" + useLocale.getLanguage() + ".properties") != null - ? useLocale.getLanguage() : "en"; + ? useLocale.getLanguage() + : "en"; } else { return i18nProvider.getText(bundleContext.getBundle(), key, key, useLocale); } diff --git a/bundles/org.openhab.ui.dashboard/src/main/java/org/openhab/ui/dashboard/internal/DashboardServlet.java b/bundles/org.openhab.ui.dashboard/src/main/java/org/openhab/ui/dashboard/internal/DashboardServlet.java index 5e1a5e89d..20bbc7700 100644 --- a/bundles/org.openhab.ui.dashboard/src/main/java/org/openhab/ui/dashboard/internal/DashboardServlet.java +++ b/bundles/org.openhab.ui.dashboard/src/main/java/org/openhab/ui/dashboard/internal/DashboardServlet.java @@ -12,10 +12,8 @@ import java.io.IOException; import java.util.Dictionary; import java.util.HashMap; import java.util.Hashtable; -import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.function.BiFunction; import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -61,11 +59,11 @@ public class DashboardServlet extends HttpServlet { private Set tiles; - private BiFunction localizeFunction; + private Function localizeFunction; public DashboardServlet(ConfigurationAdmin configurationAdmin, String indexTemplate, String entryTemplate, String warnTemplate, String setupTemplate, Set tiles, - BiFunction localizeFunction) { + Function localizeFunction) { this.configurationAdmin = configurationAdmin; this.indexTemplate = indexTemplate; this.entryTemplate = entryTemplate; @@ -113,8 +111,7 @@ public class DashboardServlet extends HttpServlet { replaceMap.put("warn", isExposed(req) ? warnTemplate : ""); // Set the messages in the session resp.setContentType("text/html;charset=UTF-8"); - // We use for UI language the server locale rather than the browser locale that we can get with req.getLocale() - resp.getWriter().append(replaceKeysWithLocaleFunction(replaceKeysFromMap(indexTemplate, replaceMap), null)); + resp.getWriter().append(replaceKeysWithLocaleFunction(replaceKeysFromMap(indexTemplate, replaceMap))); resp.getWriter().close(); } @@ -126,9 +123,7 @@ public class DashboardServlet extends HttpServlet { Map replaceMap = new HashMap<>(); replaceMap.put("version", OpenHAB.getVersion() + " " + OpenHAB.buildString()); resp.setContentType("text/html;charset=UTF-8"); - // We use for UI language the server locale rather than the browser locale that we can get with - // req.getLocale() - resp.getWriter().append(replaceKeysWithLocaleFunction(replaceKeysFromMap(setupTemplate, replaceMap), null)); + resp.getWriter().append(replaceKeysWithLocaleFunction(replaceKeysFromMap(setupTemplate, replaceMap))); resp.getWriter().close(); } } @@ -204,8 +199,8 @@ public class DashboardServlet extends HttpServlet { return null; } - private String replaceKeysWithLocaleFunction(String template, Locale locale) { - return replaceKeysWithFunction(template, (key) -> localizeFunction.apply(key, locale)); + private String replaceKeysWithLocaleFunction(String template) { + return replaceKeysWithFunction(template, (key) -> localizeFunction.apply(key)); } private String replaceKeysFromMap(String template, Map map) {