Class ConfigI18nLocalizationService


  • @NonNullByDefault
    public class ConfigI18nLocalizationService
    extends Object
    This OSGi service could be used to localize a config description using the I18N mechanism of the openHAB framework.
    Author:
    Markus Rathgeb - Initial contribution
    • Constructor Detail

      • ConfigI18nLocalizationService

        public ConfigI18nLocalizationService​(TranslationProvider i18nProvider)
    • Method Detail

      • getLocalizedConfigDescription

        public ConfigDescription getLocalizedConfigDescription​(org.osgi.framework.Bundle bundle,
                                                               ConfigDescription configDescription,
                                                               @Nullable Locale locale)
        Localize a config description.
        Parameters:
        bundle - the bundle the i18n resources are located
        configDescription - the config description that should be localized
        locale - the locale it should be localized to
        Returns:
        a localized configuration description on success, a non-localized one on error (e.g. no translation is found).
      • getLocalizedConfigDescriptionParameter

        public ConfigDescriptionParameter getLocalizedConfigDescriptionParameter​(org.osgi.framework.Bundle bundle,
                                                                                 ConfigDescription configDescription,
                                                                                 ConfigDescriptionParameter parameter,
                                                                                 @Nullable Locale locale)
        Localize a config description parameter.
        Parameters:
        bundle - the bundle the i18n resources are located
        configDescription - the config description the parameter is part of
        parameter - the parameter that should be localized
        locale - the locale it should be localized to
        Returns:
        a localized parameter on success, a non-localized one on error (e.g. no translation is found).
      • getLocalizedConfigDescriptionParameter

        public ConfigDescriptionParameter getLocalizedConfigDescriptionParameter​(org.osgi.framework.Bundle bundle,
                                                                                 URI configDescriptionURI,
                                                                                 ConfigDescriptionParameter parameter,
                                                                                 @Nullable Locale locale)
        Localize a config description parameter.
        Parameters:
        bundle - the bundle the i18n resources are located
        configDescriptionURI - the config description URI
        parameter - the parameter that should be localized
        locale - the locale it should be localized to
        Returns:
        a localized parameter on success, a non-localized one on error (e.g. no translation is found).
      • getLocalizedConfigDescriptionGroup

        public ConfigDescriptionParameterGroup getLocalizedConfigDescriptionGroup​(org.osgi.framework.Bundle bundle,
                                                                                  ConfigDescription configDescription,
                                                                                  ConfigDescriptionParameterGroup group,
                                                                                  @Nullable Locale locale)
        Localize a config description parameter group.
        Parameters:
        bundle - the bundle the i18n resources are located
        configDescription - the config description the parameter group is part of
        group - the parameter group that should be localized
        locale - the locale it should be localized to
        Returns:
        a localized parameter group on success, a non-localized one on error (e.g. no translation is found).
      • getLocalizedConfigDescriptionGroup

        public ConfigDescriptionParameterGroup getLocalizedConfigDescriptionGroup​(org.osgi.framework.Bundle bundle,
                                                                                  URI configDescriptionURI,
                                                                                  ConfigDescriptionParameterGroup group,
                                                                                  @Nullable Locale locale)
        Localize a config description parameter group.
        Parameters:
        bundle - the bundle the i18n resources are located
        configDescriptionURI - the config description URI
        group - the parameter group that should be localized
        locale - the locale it should be localized to
        Returns:
        a localized parameter group on success, a non-localized one on error (e.g. no translation is found).
      • getLocalizedOptions

        public List<ParameterOption> getLocalizedOptions​(List<ParameterOption> originalOptions,
                                                         org.osgi.framework.Bundle bundle,
                                                         URI configDescriptionURI,
                                                         String parameterName,
                                                         @Nullable Locale locale)
        Localize parameter options.
        Parameters:
        originalOptions - the parameter options that should be localized
        bundle - the bundle the i18n resources are located
        configDescriptionURI - the config description URI
        parameterName - the name of the parameter
        locale - the locale it should be localized to
        Returns:
        a list with parameter option. If an option could not be localized (e.g. no translation is found), the non-localized one is added to the list.