forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[miele] Localization of state, program and phase (openhab#11603)
* Initial changes for state, program and phase localization. * Fix bridge configuration reload. * Extracted DeviceMetaData from MieleBridgeHandler. * Fix fallback to gateway text. * Consolidate getMieleEnum in DeviceMetaData. * Localize thing offline texts and increased accuracy. * Validate language during bridge initialization. * Interpret magic value for temperature. * Add missing i18n channel label/description strings. * Add missing washing machine phase texts in Dutch. * Add missing French dishwasher phase texts. Fixes openhab#11602 Signed-off-by: Jacob Laursen <[email protected]> Signed-off-by: Michael Schmidt <[email protected]>
- Loading branch information
1 parent
d26aaae
commit 2abba37
Showing
36 changed files
with
1,340 additions
and
430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...penhab.binding.miele/src/main/java/org/openhab/binding/miele/internal/DeviceMetaData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.miele.internal; | ||
|
||
import java.util.Map.Entry; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
/** | ||
* The {@link DeviceMetaData} class represents the Metadata node in the response JSON. | ||
* | ||
* @author Jacob Laursen - Initial contribution | ||
*/ | ||
public class DeviceMetaData { | ||
public String Filter; | ||
public String description; | ||
public String LocalizedID; | ||
public String LocalizedValue; | ||
public JsonObject MieleEnum; | ||
public String access; | ||
|
||
public String getMieleEnum(String s) { | ||
if (this.MieleEnum == null) { | ||
return null; | ||
} | ||
|
||
for (Entry<String, JsonElement> enumEntry : this.MieleEnum.entrySet()) { | ||
if (enumEntry.getValue().getAsString().trim().equals(s.trim())) { | ||
return enumEntry.getKey(); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ding.miele/src/main/java/org/openhab/binding/miele/internal/MieleTranslationProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.miele.internal; | ||
|
||
import java.util.Locale; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.openhab.core.i18n.LocaleProvider; | ||
import org.openhab.core.i18n.TranslationProvider; | ||
import org.osgi.framework.Bundle; | ||
import org.osgi.framework.FrameworkUtil; | ||
|
||
/** | ||
* {@link MieleTranslationProvider} provides i18n message lookup | ||
* | ||
* @author Jacob Laursen - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class MieleTranslationProvider { | ||
|
||
private final Bundle bundle; | ||
private final TranslationProvider i18nProvider; | ||
private final LocaleProvider localeProvider; | ||
@Nullable | ||
private final Locale locale; | ||
|
||
public MieleTranslationProvider(TranslationProvider i18nProvider, LocaleProvider localeProvider) { | ||
this.bundle = FrameworkUtil.getBundle(this.getClass()); | ||
this.i18nProvider = i18nProvider; | ||
this.localeProvider = localeProvider; | ||
this.locale = null; | ||
} | ||
|
||
public MieleTranslationProvider(TranslationProvider i18nProvider, LocaleProvider localeProvider, Locale locale) { | ||
this.bundle = FrameworkUtil.getBundle(this.getClass()); | ||
this.i18nProvider = i18nProvider; | ||
this.localeProvider = localeProvider; | ||
this.locale = locale; | ||
} | ||
|
||
public String getText(String key, String defaultText, @Nullable Object... arguments) { | ||
String text = i18nProvider.getText(bundle, key, defaultText, | ||
locale != null ? locale : localeProvider.getLocale(), arguments); | ||
if (text == null) { | ||
return defaultText; | ||
} | ||
return text; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.