From c4c9c25621e9e7311e09ed5769d00d0634c5bb23 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Thu, 11 Jul 2019 19:12:15 +0200 Subject: [PATCH] add Polish language --- .../java/org/jabref/logic/l10n/Language.java | 39 ++++++++++--------- .../org/jabref/logic/l10n/Localization.java | 8 ++-- .../jabref/preferences/JabRefPreferences.java | 2 +- src/main/resources/l10n/JabRef_pl.properties | 0 .../org/jabref/logic/l10n/LanguageTest.java | 4 +- .../jabref/logic/l10n/LocalizationTest.java | 14 +++---- 6 files changed, 34 insertions(+), 33 deletions(-) create mode 100644 src/main/resources/l10n/JabRef_pl.properties diff --git a/src/main/java/org/jabref/logic/l10n/Language.java b/src/main/java/org/jabref/logic/l10n/Language.java index 1bde6443678..986766506c5 100644 --- a/src/main/java/org/jabref/logic/l10n/Language.java +++ b/src/main/java/org/jabref/logic/l10n/Language.java @@ -9,25 +9,26 @@ */ public enum Language { - BahasaIndonesia("Bahasa Indonesia", "in"), - BrazilianPortuguese("Brazilian Portuguese", "pt_BR"), - Danish("Dansk", "da"), - German("Deutsch", "de"), - English("English", "en"), - Spanish("Español", "es"), - French("Français", "fr"), - Italian("Italiano", "it"), - Japanese("Japanese", "ja"), - Dutch("Nederlands", "nl"), - Norwegian("Norsk", "no"), - Persian("Persian (فارسی)", "fa"), - Russian("Russian", "ru"), - SimplifiedChinese("Simplified Chinese", "zh"), - Svenska("Svenska", "sv"), - Turkish("Turkish", "tr"), - Vietnamese("Vietnamese", "vi"), - Greek("ελληνικά", "el"), - Tagalog("Tagalog/Filipino", "tl"); + BAHASA_INDONESIA("Bahasa Indonesia", "in"), + BRAZILIAN_PORTUGUESE("Brazilian Portuguese", "pt_BR"), + DANISH("Dansk", "da"), + GERMAN("Deutsch", "de"), + ENGLISH("English", "en"), + SPANISH("Español", "es"), + FRENCH("Français", "fr"), + ITALIAN("Italiano", "it"), + JAPANESE("Japanese", "ja"), + DUTCH("Nederlands", "nl"), + NORWEGIAN("Norsk", "no"), + PERSIAN("Persian (فارسی)", "fa"), + RUSSIAN("Russian", "ru"), + SIMPLIFIED_CHINESE("Simplified Chinese", "zh"), + SVENSKA("Svenska", "sv"), + TURKISH("Turkish", "tr"), + VIETNAMESE("Vietnamese", "vi"), + GREEK("ελληνικά", "el"), + TAGALOG("Tagalog/Filipino", "tl"), + POLISH("Polish", "pl"); private final String displayName; private final String id; diff --git a/src/main/java/org/jabref/logic/l10n/Localization.java b/src/main/java/org/jabref/logic/l10n/Localization.java index 57b48226452..cd260d8cf57 100644 --- a/src/main/java/org/jabref/logic/l10n/Localization.java +++ b/src/main/java/org/jabref/logic/l10n/Localization.java @@ -53,7 +53,7 @@ public static String lang(String key, String... params) { if (localizedMessages == null) { // I'm logging this because it should never happen LOGGER.error("Messages are not initialized before accessing key: " + key); - setLanguage(Language.English); + setLanguage(Language.ENGLISH); } return lookup(localizedMessages, key, params); } @@ -69,7 +69,7 @@ public static void setLanguage(Language language) { final Locale defaultLocale = Locale.getDefault(); if (!knownLanguage.isPresent()) { LOGGER.warn("Language " + language + " is not supported by JabRef (Default:" + defaultLocale + ")"); - setLanguage(Language.English); + setLanguage(Language.ENGLISH); return; } // avoid reinitialization of the language bundles @@ -86,7 +86,7 @@ public static void setLanguage(Language language) { } catch (MissingResourceException ex) { // should not happen as we have scripts to enforce this LOGGER.warn("Could not find bundles for language " + locale + ", switching to full english language", ex); - setLanguage(Language.English); + setLanguage(Language.ENGLISH); } } @@ -98,7 +98,7 @@ public static void setLanguage(Language language) { public static LocalizationBundle getMessages() { // avoid situations where this function is called before any language was set if (locale == null) { - setLanguage(Language.English); + setLanguage(Language.ENGLISH); } return localizedMessages; } diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index cd906dece37..0c1ea92ec4e 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -1983,7 +1983,7 @@ public Language getLanguage() { return Stream.of(Language.values()) .filter(language -> language.getId().equalsIgnoreCase(languageId)) .findFirst() - .orElse(Language.English); + .orElse(Language.ENGLISH); } public void setLanguage(Language language) { diff --git a/src/main/resources/l10n/JabRef_pl.properties b/src/main/resources/l10n/JabRef_pl.properties new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/test/java/org/jabref/logic/l10n/LanguageTest.java b/src/test/java/org/jabref/logic/l10n/LanguageTest.java index 92f7329f8b7..8b583357db9 100644 --- a/src/test/java/org/jabref/logic/l10n/LanguageTest.java +++ b/src/test/java/org/jabref/logic/l10n/LanguageTest.java @@ -12,13 +12,13 @@ class LanguageTest { @Test void convertKnownLanguageOnly() { - assertEquals(Optional.of(new Locale("en")), Language.convertToSupportedLocale(Language.English)); + assertEquals(Optional.of(new Locale("en")), Language.convertToSupportedLocale(Language.ENGLISH)); } @Test void convertKnownLanguageAndCountryCorrect() { //Language and country code have to be separated see: https://stackoverflow.com/a/3318598 - assertEquals(Optional.of(new Locale("pt", "BR")), Language.convertToSupportedLocale(Language.BrazilianPortuguese)); + assertEquals(Optional.of(new Locale("pt", "BR")), Language.convertToSupportedLocale(Language.BRAZILIAN_PORTUGUESE)); } @Test diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationTest.java b/src/test/java/org/jabref/logic/l10n/LocalizationTest.java index 37d22dacead..377ef0b0911 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationTest.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationTest.java @@ -21,43 +21,43 @@ void storeDefaultLocale() { void restoreDefaultLocale() { Locale.setDefault(locale); javax.swing.JComponent.setDefaultLocale(locale); - Localization.setLanguage(Language.English); + Localization.setLanguage(Language.ENGLISH); } @Test void testSetKnownLanguage() { Locale.setDefault(Locale.CHINA); - Localization.setLanguage(Language.English); + Localization.setLanguage(Language.ENGLISH); assertEquals("en", Locale.getDefault().toString()); } @Test void testKnownTranslationWithGroups() { - Localization.setLanguage(Language.English); + Localization.setLanguage(Language.ENGLISH); assertEquals("Groups", Localization.lang("Groups")); } @Test void testKnownEnglishTranslationOfUndo() { - Localization.setLanguage(Language.English); + Localization.setLanguage(Language.ENGLISH); assertEquals("Undo", Localization.lang("Undo")); } @Test void testKnownGermanTranslation() { - Localization.setLanguage(Language.German); + Localization.setLanguage(Language.GERMAN); assertEquals("Zeige Einstellungen", Localization.lang("Show preferences")); } @Test void testKnownTranslationWithCountryModifier() { - Localization.setLanguage(Language.BrazilianPortuguese); + Localization.setLanguage(Language.BRAZILIAN_PORTUGUESE); assertEquals("Grupos", Localization.lang("Groups")); } @Test void testUnknownTranslation() { - Localization.setLanguage(Language.English); + Localization.setLanguage(Language.ENGLISH); assertEquals("WHATEVER", Localization.lang("WHATEVER")); }