diff --git a/src/main/java/org/meeuw/i18n/languages/DisplayNames_en.java b/src/main/java/org/meeuw/i18n/languages/DisplayNames.java similarity index 83% rename from src/main/java/org/meeuw/i18n/languages/DisplayNames_en.java rename to src/main/java/org/meeuw/i18n/languages/DisplayNames.java index 797628a..f617fa4 100644 --- a/src/main/java/org/meeuw/i18n/languages/DisplayNames_en.java +++ b/src/main/java/org/meeuw/i18n/languages/DisplayNames.java @@ -2,7 +2,7 @@ import java.util.stream.Stream; -public class DisplayNames_en extends java.util.ListResourceBundle { +public class DisplayNames extends java.util.ListResourceBundle { @Override protected Object[][] getContents() { return Stream.concat( diff --git a/src/main/java/org/meeuw/i18n/languages/ISO_639_Code.java b/src/main/java/org/meeuw/i18n/languages/ISO_639_Code.java index 0098a7e..854cfd6 100644 --- a/src/main/java/org/meeuw/i18n/languages/ISO_639_Code.java +++ b/src/main/java/org/meeuw/i18n/languages/ISO_639_Code.java @@ -56,15 +56,11 @@ static ISO_639_Code fromCode(String code) { return ISO_639.iso639(code); } - ResourceBundle DEFAULT = ResourceBundle.getBundle("org.meeuw.i18n.languages.DisplayNames", Locale.US); + default String getDisplayName(Locale locale) { ResourceBundle bundle = ResourceBundle.getBundle("org.meeuw.i18n.languages.DisplayNames", locale); - if (bundle.containsKey(code())) { - return bundle.getString(code()); - } else { - return DEFAULT.getString(code()); - } + return bundle.getString(code()); } diff --git a/src/test/java/org/meeuw/i18n/languages/test/LanguageCodeTest.java b/src/test/java/org/meeuw/i18n/languages/test/LanguageCodeTest.java index 8e391b8..382d6ba 100644 --- a/src/test/java/org/meeuw/i18n/languages/test/LanguageCodeTest.java +++ b/src/test/java/org/meeuw/i18n/languages/test/LanguageCodeTest.java @@ -219,7 +219,7 @@ public void deprecated() { @Test public void dutchSignLanguage() { - LanguageCode l = LanguageCode.get("sse").orElseThrow(); + LanguageCode l = LanguageCode.get("dse").orElseThrow(); assertThat(l.refName()).isEqualTo("Dutch Sign Language"); assertThat(l.nameRecord().print()).isEqualTo("dse (Dutch Sign Language)");