]> git.basschouten.com Git - openhab-addons.git/blob
740ed277156550ec6771d268b14918aabe1e3a84
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.hdpowerview.internal.providers;
14
15 import static java.util.Map.entry;
16
17 import java.text.MessageFormat;
18 import java.util.Locale;
19 import java.util.Map;
20
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;
25
26 /**
27  * Translation provider for unit tests.
28  *
29  * @author Jacob Laursen - Initial contribution
30  */
31 @NonNullByDefault
32 public class MockedTranslationProvider implements TranslationProvider {
33
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"));
50
51     public MockedTranslationProvider() {
52     }
53
54     @Nullable
55     public String getText(@Nullable Bundle bundle, @Nullable String key, @Nullable String defaultText,
56             @Nullable Locale locale) {
57         return "";
58     }
59
60     @Nullable
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);
65     }
66 }