2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.boschindego.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.core.i18n.LocaleProvider;
18 import org.openhab.core.i18n.TranslationProvider;
19 import org.osgi.framework.Bundle;
20 import org.osgi.framework.FrameworkUtil;
23 * {@link BoschIndegoTranslationProvider} provides i18n message lookup.
25 * @author Jacob Laursen - Initial contribution
28 public class BoschIndegoTranslationProvider {
30 private final Bundle bundle;
31 private final TranslationProvider i18nProvider;
32 private final LocaleProvider localeProvider;
34 public BoschIndegoTranslationProvider(TranslationProvider i18nProvider, LocaleProvider localeProvider) {
35 this.bundle = FrameworkUtil.getBundle(this.getClass());
36 this.i18nProvider = i18nProvider;
37 this.localeProvider = localeProvider;
40 public @Nullable String getText(String key, @Nullable Object... arguments) {
41 return i18nProvider.getText(bundle, key, null, localeProvider.getLocale(), arguments);
44 public String getText(String key, String defaultText, @Nullable Object... arguments) {
45 String text = i18nProvider.getText(bundle, key, defaultText, localeProvider.getLocale(), arguments);