]> git.basschouten.com Git - openhab-addons.git/blob
5b501ebecd4090025bc73233f3b8fdc987289803
[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.mielecloud.internal.webservice.language;
14
15 import java.util.Optional;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.core.i18n.LocaleProvider;
19
20 /**
21  * Language provider relying on the openHAB runtime to provide a locale which is converted to a language.
22  *
23  * @author Björn Lange - Initial Contribution
24  */
25 @NonNullByDefault
26 public class OpenHabLanguageProvider implements LanguageProvider {
27     private final LocaleProvider localeProvider;
28
29     public OpenHabLanguageProvider(LocaleProvider localeProvider) {
30         this.localeProvider = localeProvider;
31     }
32
33     @Override
34     public Optional<String> getLanguage() {
35         return Optional.of(localeProvider.getLocale().getLanguage());
36     }
37 }