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.hdpowerview.internal.providers;
15 import static java.util.Map.entry;
17 import java.text.MessageFormat;
18 import java.util.Locale;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.openhab.core.i18n.TranslationProvider;
24 import org.osgi.framework.Bundle;
27 * Translation provider for unit tests.
29 * @author Jacob Laursen - Initial contribution
32 public class MockedTranslationProvider implements TranslationProvider {
34 private static final Map<String, String> TEXTS = Map.ofEntries(
35 entry("dynamic-channel.scene-activate.description", "Activates the scene ''{0}''"),
36 entry("dynamic-channel.scene-group-activate.description", "Activates the scene group ''{0}''"),
37 entry("dynamic-channel.automation-enabled.description", "Enables/disables the automation ''{0}''"),
38 entry("dynamic-channel.automation-enabled.label", "{0}, {1}, {2}"),
39 entry("dynamic-channel.automation.hour", "{0}hr"), entry("dynamic-channel.automation.minute", "{0}m"),
40 entry("dynamic-channel.automation.hour-minute", "{0}hr {1}m"),
41 entry("dynamic-channel.automation.at-sunrise", "At sunrise"),
42 entry("dynamic-channel.automation.before-sunrise", "{0} before sunrise"),
43 entry("dynamic-channel.automation.after-sunrise", "{0} after sunrise"),
44 entry("dynamic-channel.automation.at-sunset", "At sunset"),
45 entry("dynamic-channel.automation.before-sunset", "{0} before sunset"),
46 entry("dynamic-channel.automation.after-sunset", "{0} after sunset"),
47 entry("dynamic-channel.automation.weekdays", "Weekdays"),
48 entry("dynamic-channel.automation.weekends", "Weekends"),
49 entry("dynamic-channel.automation.all-days", "All days"));
51 public MockedTranslationProvider() {
55 public String getText(@Nullable Bundle bundle, @Nullable String key, @Nullable String defaultText,
56 @Nullable Locale locale) {
61 public String getText(@Nullable Bundle bundle, @Nullable String key, @Nullable String defaultText,
62 @Nullable Locale locale, @Nullable Object @Nullable... arguments) {
63 String text = TEXTS.get(key);
64 return MessageFormat.format(text != null ? text : key, arguments);