Class ThingStatusInfoI18nLocalizationService

java.lang.Object
org.openhab.core.thing.i18n.ThingStatusInfoI18nLocalizationService

public final class ThingStatusInfoI18nLocalizationService extends Object

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 Details

    • ThingStatusInfoI18nLocalizationService

      public ThingStatusInfoI18nLocalizationService()
  • Method Details

    • getLocalizedThingStatusInfo

      public ThingStatusInfo getLocalizedThingStatusInfo(Thing thing, Locale locale)
      Localizes the ThingStatusInfo for 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

      protected void setTranslationProvider(TranslationProvider i18nProvider)
    • unsetTranslationProvider

      protected void unsetTranslationProvider(TranslationProvider i18nProvider)
    • setBundleResolver

      public void setBundleResolver(BundleResolver bundleResolver)
    • unsetBundleResolver

      protected void unsetBundleResolver(BundleResolver bundleResolver)