From 783c1249dbbdd69af0e48c4fefb2e967d4c7755d Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Fri, 6 Oct 2023 21:31:30 +0200 Subject: [PATCH] Fix locale switching. --- .../logviewer/LogViewer-functions.ftl.js | 15 +++++---- .../logviewer/LogViewer-l10nBundles.ftl.js | 31 +++++++++++++++++++ .../osgi/webconlet/logviewer/l10n.properties | 4 +-- .../webconlet/logviewer/l10n_de.properties | 4 +-- 4 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/LogViewer-l10nBundles.ftl.js diff --git a/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/LogViewer-functions.ftl.js b/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/LogViewer-functions.ftl.js index c403c461..68ad8d38 100644 --- a/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/LogViewer-functions.ftl.js +++ b/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/LogViewer-functions.ftl.js @@ -23,6 +23,7 @@ import JgwcPlugin, { JGWC } from "../../page-resource/jgwc-vue-components/jgwc-components.js"; import { provideApi, getApi } from "../../page-resource/aash-vue-components/lib/aash-vue-components.js"; +import l10nBundles from "./LogViewer-l10nBundles.ftl.js"; window.orgJGrapesOsgiConletLogViewer = {}; @@ -39,13 +40,15 @@ window.orgJGrapesOsgiConletLogViewer.initView = function(content) { setup() { const conletId = content.closest("[data-conlet-id]") .dataset["conletId"]; + const ctrlL18n = (key) => + JGConsole.localize(l10nBundles, JGWC.lang(), key); const controller = reactive(new JGConsole.TableController([ - ["time", '${_("timestamp")}'], - ["logLevel", '${_("level")}'], - ["message", '${_("message")}'], - ["bundle", '${_("bundle")}'], - ["service", '${_("service")}'], - ["exception", '${_("exception")}'], + ["time", ctrlL18n], + ["logLevel", ctrlL18n], + ["message", ctrlL18n], + ["bundle", ctrlL18n], + ["service", ctrlL18n], + ["exception", ctrlL18n], ], { sortKey: "sequence", sortOrder: "down" diff --git a/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/LogViewer-l10nBundles.ftl.js b/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/LogViewer-l10nBundles.ftl.js new file mode 100644 index 00000000..7d58ee9b --- /dev/null +++ b/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/LogViewer-l10nBundles.ftl.js @@ -0,0 +1,31 @@ +/* + * Ad Hoc Polling Application + * Copyright (C) 2018 Michael N. Lipp + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +'use strict'; + +const l10nBundles = new Map(); +let entries = null; +// <#list supportedLanguages() as l> +entries = new Map(); +l10nBundles.set('${l.locale.toLanguageTag()}', entries); +// <#list l.l10nBundle.keys as key> +entries.set('${key}', '${l.l10nBundle.getString(key)}') +// +// + +export default l10nBundles; diff --git a/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/l10n.properties b/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/l10n.properties index b917f0be..e49d6211 100644 --- a/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/l10n.properties +++ b/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/l10n.properties @@ -18,8 +18,8 @@ conletName = Log -timestamp = Timestamp -level = Level +time = Timestamp +logLevel = Level message = Message service = Service bundle = Bundle diff --git a/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/l10n_de.properties b/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/l10n_de.properties index 3da956f2..e6a3cfa0 100644 --- a/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/l10n_de.properties +++ b/org.jgrapes.osgi.webconlet.logviewer/resources/org/jgrapes/osgi/webconlet/logviewer/l10n_de.properties @@ -21,9 +21,9 @@ conletName = Meldungsprotokoll auto = automatisch bundle = Paket exception = Ausnahme -level = Stufe +logLevel = Stufe message = Meldung -timestamp = Zeitstempel +time = Zeitstempel service = Dienst severityAtLeast = Mindeststufe Update = Aktualisierung