Package org.openhab.core.thing.i18n
Class ThingStatusInfoI18nLocalizationService
java.lang.Object
org.openhab.core.thing.i18n.ThingStatusInfoI18nLocalizationService
The ThingStatusInfoI18nLocalizationService can be used to localize the ThingStatusInfo of a thing
using the I18N mechanism of the openHAB framework. Currently the description of the ThingStatusInfo
is the single attribute which can be localized.
In order to provide a localized description the corresponding ThingHandler of the thing does not provide a
localized string in the ThingStatus.description attribute, but instead provides the reference of the
localization string, e.g @text/rate_limit. The handler is able to provide placeholder values as a JSON-serialized
array of strings:
@text/rate_limit ["60", "10", "@text/hour"]
rate_limit=Device is blocked by remote service for {0} minutes. Maximum limit of {1} configuration
changes per {2} has been exceeded. For further info please refer to device vendor.
- Author:
- Thomas Höfer - Initial contribution, Henning Sudbrock - Permit translations from thing handler parent bundles
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetLocalizedThingStatusInfo(Thing thing, Locale locale) Localizes theThingStatusInfofor the given thing.voidsetBundleResolver(BundleResolver bundleResolver) protected voidsetTranslationProvider(TranslationProvider i18nProvider) protected voidunsetBundleResolver(BundleResolver bundleResolver) protected voidunsetTranslationProvider(TranslationProvider i18nProvider)
-
Constructor Details
-
ThingStatusInfoI18nLocalizationService
public ThingStatusInfoI18nLocalizationService()
-
-
Method Details
-
getLocalizedThingStatusInfo
Localizes theThingStatusInfofor the given thing.- Parameters:
thing- the thing whose thing status info is to be localized (must not be null)locale- the locale to be used (can be null)- Returns:
- the localized thing status or the original thing status if
- there is nothing to be localized
- the thing does not have a handler
- Throws:
IllegalArgumentException- if given thing is null
-
setTranslationProvider
-
unsetTranslationProvider
-
setBundleResolver
-
unsetBundleResolver
-