use of org.eclipse.smarthome.config.core.i18n.ConfigDescriptionI18nUtil in project smarthome by eclipse.
the class AbstractResourceBundleProvider method getLocalizedConfigurationDescription.
protected List<ConfigDescriptionParameter> getLocalizedConfigurationDescription(TranslationProvider i18nProvider, List<ConfigDescriptionParameter> config, Bundle bundle, String uid, String prefix, Locale locale) {
List<ConfigDescriptionParameter> configDescriptions = new ArrayList<ConfigDescriptionParameter>();
if (config != null) {
ConfigDescriptionI18nUtil util = new ConfigDescriptionI18nUtil(i18nProvider);
for (ConfigDescriptionParameter parameter : config) {
String parameterName = parameter.getName();
URI uri = null;
try {
uri = new URI(prefix + ":" + uid + ".name");
} catch (URISyntaxException e) {
logger.error("Constructed invalid uri '{}:{}.name'", prefix, uid, e);
}
String llabel = parameter.getLabel();
if (llabel != null) {
llabel = util.getParameterLabel(bundle, uri, parameterName, llabel, locale);
}
String ldescription = parameter.getDescription();
if (ldescription != null) {
ldescription = util.getParameterDescription(bundle, uri, parameterName, ldescription, locale);
}
String lpattern = parameter.getPattern();
if (lpattern != null) {
lpattern = util.getParameterPattern(bundle, uri, parameterName, lpattern, locale);
}
List<ParameterOption> loptions = parameter.getOptions();
if (loptions != null && !loptions.isEmpty()) {
for (ParameterOption option : loptions) {
String label = util.getParameterOptionLabel(bundle, uri, parameterName, option.getValue(), option.getLabel(), locale);
option = new ParameterOption(option.getValue(), label);
}
}
String lunitLabel = parameter.getUnitLabel();
if (lunitLabel != null) {
lunitLabel = util.getParameterUnitLabel(bundle, uri, parameterName, parameter.getUnit(), lunitLabel, locale);
}
configDescriptions.add(ConfigDescriptionParameterBuilder.create(parameterName, parameter.getType()).withMinimum(parameter.getMinimum()).withMaximum(parameter.getMaximum()).withStepSize(parameter.getStepSize()).withPattern(lpattern).withRequired(parameter.isRequired()).withMultiple(parameter.isMultiple()).withReadOnly(parameter.isReadOnly()).withContext(parameter.getContext()).withDefault(parameter.getDefault()).withLabel(llabel).withDescription(ldescription).withFilterCriteria(parameter.getFilterCriteria()).withGroupName(parameter.getGroupName()).withAdvanced(parameter.isAdvanced()).withOptions(loptions).withLimitToOptions(parameter.getLimitToOptions()).withMultipleLimit(parameter.getMultipleLimit()).withUnit(parameter.getUnit()).withUnitLabel(lunitLabel).build());
}
}
return configDescriptions;
}
Aggregations