Fix spaces in options not properly handled in i18n-maven-plugin (#2964)

Signed-off-by: Jan N. Klug <github@klug.nrw>
pull/2960/head^2
J-N-K 2022-05-16 22:26:51 +02:00 committed by GitHub
parent d523275004
commit b11086ef45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 8 deletions

View File

@ -21,6 +21,7 @@ import org.openhab.core.thing.type.DynamicStateDescriptionProvider;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.LoggerFactory;
/**
* Dynamic provider of state options while leaving other state description fields as original.
@ -30,7 +31,6 @@ import org.osgi.service.component.annotations.Reference;
@Component(service = { DynamicStateDescriptionProvider.class, MagicDynamicStateDescriptionProvider.class })
@NonNullByDefault
public class MagicDynamicStateDescriptionProvider extends BaseDynamicStateDescriptionProvider {
@Activate
public MagicDynamicStateDescriptionProvider(final @Reference EventPublisher eventPublisher, //
final @Reference ChannelTypeI18nLocalizationService channelTypeI18nLocalizationService, //
@ -38,5 +38,11 @@ public class MagicDynamicStateDescriptionProvider extends BaseDynamicStateDescri
this.eventPublisher = eventPublisher;
this.channelTypeI18nLocalizationService = channelTypeI18nLocalizationService;
this.itemChannelLinkRegistry = itemChannelLinkRegistry;
LoggerFactory.getLogger(getClass()).error("called activate constructor");
}
public void activate() {
LoggerFactory.getLogger(getClass()).error("called activate method");
}
}

View File

@ -20,6 +20,7 @@ import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.stream.Stream;
import java.util.stream.Stream.Builder;
@ -351,7 +352,9 @@ public class XmlToTranslationsConverter {
entriesBuilder.add(entry(String.format("%s.description", parameterKeyPrefix), parameter.getDescription()));
parameter.getOptions().stream()
.map(option -> entry(String.format("%s.option.%s", parameterKeyPrefix, option.getValue()),
.map(option -> entry(
String.format("%s.option.%s", parameterKeyPrefix,
option.getValue().replaceAll(" ", Matcher.quoteReplacement("\\ "))),
option.getLabel()))
.forEach(entriesBuilder::add);

View File

@ -39,7 +39,7 @@ public class PropertiesToTranslationsConverterTest {
assertThat(translations.hasTranslations(), is(true));
assertThat(translations.sections.size(), is(6));
assertThat(translations.keysStream().count(), is(31L));
assertThat(translations.keysStream().count(), is(32L));
String lines = translations.linesStream().collect(Collectors.joining(System.lineSeparator()));
assertThat(lines, containsString("# binding"));

View File

@ -42,7 +42,7 @@ public class XmlToTranslationsConverterTest {
assertThat(translations.hasTranslations(), is(true));
assertThat(translations.sections.size(), is(7));
assertThat(translations.keysStream().count(), is(30L));
assertThat(translations.keysStream().count(), is(31L));
String lines = translations.linesStream().collect(Collectors.joining(System.lineSeparator()));
assertThat(lines, containsString("# binding"));
@ -53,6 +53,8 @@ public class XmlToTranslationsConverterTest {
"channel-group-type.acmeweather.forecast.channel.minTemperature.description = Minimum forecasted temperature in degrees Celsius (metric) or Fahrenheit (imperial)."));
assertThat(lines, containsString(
"channel-type.acmeweather.time-stamp.state.pattern = %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS"));
assertThat(lines,
containsString("thing-type.config.acmeweather.weather.language.option.de\\ DE = German (Germany)"));
}
@Test

View File

@ -15,7 +15,8 @@
<description>Language to be used by the ACME API.</description>
<options>
<option value="nl">Dutch</option>
<option value="de">German</option>
<option value="de DE">German (Germany)</option>
<option value="de CH">German (Switzerland)</option>
<option value="en">English</option>
<option value="fr">French</option>
</options>

View File

@ -19,7 +19,8 @@ thing-type.acmeweather.weather.channel.minTemperature.description = Minimum temp
thing-type.config.acmeweather.weather.language.label = Language
thing-type.config.acmeweather.weather.language.description = Language to be used by the ACME API.
thing-type.config.acmeweather.weather.language.option.nl = Dutch
thing-type.config.acmeweather.weather.language.option.de = German
thing-type.config.acmeweather.weather.language.option.de\ DE = German (Germany)
thing-type.config.acmeweather.weather.language.option.de\ CH = German (Switzerland)
thing-type.config.acmeweather.weather.language.option.en = English
thing-type.config.acmeweather.weather.language.option.fr = French
thing-type.config.acmeweather.weather.refreshInterval.label = Refresh Interval

View File

@ -19,7 +19,8 @@ thing-type.acmeweather.weather.channel.minTemperature.description = Minimum temp
thing-type.config.acmeweather.weather.language.label = Language
thing-type.config.acmeweather.weather.language.description = Language to be used by the ACME API.
thing-type.config.acmeweather.weather.language.option.nl = Dutch
thing-type.config.acmeweather.weather.language.option.de = German
thing-type.config.acmeweather.weather.language.option.de\ DE = German (Germany)
thing-type.config.acmeweather.weather.language.option.de\ CH = German (Switzerland)
thing-type.config.acmeweather.weather.language.option.en = English
thing-type.config.acmeweather.weather.language.option.fr = French
thing-type.config.acmeweather.weather.refreshInterval.label = Refresh Interval

View File

@ -19,7 +19,8 @@ thing-type.acmeweather.weather.channel.minTemperature.description = Minimale Tem
thing-type.config.acmeweather.weather.language.label = Sprache
thing-type.config.acmeweather.weather.language.description = Sprache zur Anzeige der Daten.
thing-type.config.acmeweather.weather.language.option.nl = Holländisch
thing-type.config.acmeweather.weather.language.option.de = Deutsch
thing-type.config.acmeweather.weather.language.option.de\ DE = Deutsch (Deutschland)
thing-type.config.acmeweather.weather.language.option.de\ CH = Deutsch (Schweitz)
thing-type.config.acmeweather.weather.language.option.en = Englisch
thing-type.config.acmeweather.weather.language.option.fr = Französisch
thing-type.config.acmeweather.weather.refreshInterval.label = Abfrageintervall