-
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.
Support for dynamic translation of item labels.
Signed-off-by: Łukasz Dywicki <luke@code-house.org>
- Loading branch information
Showing
4 changed files
with
90 additions
and
2 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
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
55 changes: 55 additions & 0 deletions
55
...smarthouse.core.i18n/src/main/java/org/openhab/core/i18n/ResourceTranslationProvider.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,55 @@ | ||
/** | ||
* Copyright (c) 2010-2020 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.core.i18n; | ||
|
||
import java.util.Locale; | ||
|
||
/** | ||
* Interface for resource/translation provider which can be registered dynamically as a service. | ||
* | ||
* @author Łukasz Dywicki - Initial contribution. | ||
*/ | ||
public interface ResourceTranslationProvider { | ||
|
||
/** | ||
* Returns a translation for the specified key in the specified locale (language) by only | ||
* considering the specified resource section. The resource is equal to a base name and | ||
* therefore it is mapped to one translation package (all files which belong to the base | ||
* name). | ||
* <p> | ||
* If no translation could be found, {@code null} is returned. If the location is not specified, the default | ||
* location is used. | ||
* | ||
* @param resource the resource to be used for look-up (could be null or empty) | ||
* @param key the key to be translated (could be null or empty) | ||
* @param locale the locale (language) to be used (could be null) | ||
* | ||
* @return the translated text, or null if the key could not be translated | ||
*/ | ||
String getText(String resource, String key, Locale locale); | ||
|
||
/** | ||
* Returns a translation for the specified key in the specified locale (language) | ||
* by considering all resources in the according bundle. | ||
* <p> | ||
* If no translation could be found, {@code null} is returned. If the location is not specified, the default | ||
* location is used. | ||
* | ||
* @param key the key to be translated (could be null or empty) | ||
* @param locale the locale (language) to be used (could be null) | ||
* | ||
* @return the translated text, or null if the key could not be translated | ||
*/ | ||
String getText(String key, Locale locale); | ||
|
||
} |
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