### Question:
LocalizedString extends Base { @Nullable public String getTranslation(final Iterable<Locale> locales) { return StreamSupport.stream(locales.spliterator(), false) .map(localeToFind -> { String match = get(localeToFind); if (match == null) { final Locale pureLanguageLocale = new Locale(localeToFind.getLanguage()); match = get(pureLanguageLocale); } return match; }) .filter(x -> x != null) .findFirst() .orElse(null); } @JsonCreator private  LocalizedString(final Map<Locale, String> translations); @JsonIgnore static LocalizedString of(); static LocalizedString empty(); @JsonIgnore static LocalizedString of(final Locale locale, final String value); @JsonIgnore static LocalizedString of(final Locale locale1, final String value1, final Locale locale2, final String value2); @JsonIgnore static LocalizedString of(final Map<Locale, String> translations); @JsonIgnore static LocalizedString ofStringToStringMap(final Map<String, String> translations); LocalizedString plus(final Locale locale, final String value); @Nonnull Optional<String> find(final Locale locale); @Nullable String get(final Locale locale); @Nullable String get(final String languageTag); @Nonnull Optional<String> find(final Iterable<Locale> locales); @Nullable String get(final Iterable<Locale> locales); @Nullable String getTranslation(final Iterable<Locale> locales); LocalizedString mapValue(final BiFunction<Locale, String, String> function); Stream<LocalizedStringEntry> stream(); static Collector<LocalizedStringEntry, ?, LocalizedString> streamCollector(); LocalizedString slugified(); LocalizedString slugifiedUnique(); @JsonIgnore @Nonnull Set<Locale> getLocales(); @Override String toString(); static TypeReference<LocalizedString> typeReference(); static LocalizedString ofEnglish(final String translationForEnglish);  }### Answer:
@Test public void getTranslation() { final LocalizedString ls = LocalizedString .of(Locale.GERMAN, "de") .plus(Locale.ENGLISH, "en") .plus(Locale.US, "en_US"); assertThat(ls.getTranslation(asList(Locale.US, Locale.ENGLISH))).isEqualTo("en_US"); assertThat(ls.getTranslation(asList(Locale.ENGLISH, Locale.US))).isEqualTo("en"); assertThat(ls.getTranslation(asList(Locale.FRENCH, Locale.ENGLISH))).isEqualTo("en"); assertThat(ls.getTranslation(asList(Locale.UK, Locale.ENGLISH))).isEqualTo("en"); assertThat(ls.getTranslation(asList(Locale.GERMAN, Locale.UK))).isEqualTo("de"); assertThat(ls.getTranslation(asList(Locale.UK, Locale.GERMAN))) .overridingErrorMessage( "the plain language fallback wins also in the case after that comes a concrete match") .isEqualTo("en"); assertThat(ls.getTranslation(asList(Locale.FRENCH, Locale.UK, Locale.GERMAN))) .overridingErrorMessage("automatic fallback to plain English") .isEqualTo("en"); assertThat(LocalizedString.of(Locale.US, "en_US").getTranslation(asList(Locale.ENGLISH))) .overridingErrorMessage("no fallback to locale with country") .isNull(); assertThat(ls.getTranslation(asList(Locale.UK, Locale.US, Locale.GERMAN))) .isEqualTo(ls.get(asList(Locale.UK, Locale.ENGLISH, Locale.US, Locale.ENGLISH, Locale.GERMAN))); assertThat(ls.get("en")) .isEqualTo(ls.get(Locale.ENGLISH)) .isEqualTo(ls.get("en-***")) .isNotEqualTo(ls.get(Locale.US)); assertThat(ls.get("de")) .isEqualTo(ls.get(Locale.GERMAN)) .isNotEqualTo(ls.get("de-AT")); assertThat(ls.get("en-US")) .isEqualTo(ls.get(Locale.US)) .isEqualTo(ls.get("en-US-blub")) .isNotEqualTo(ls.get("en-US-u-islamcal")); assertThat(ls.get("en_US")) .isNull(); assertThat(ls.get("xxx")) .isNull(); }