Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Polish language #5115

Merged
merged 1 commit into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions src/main/java/org/jabref/logic/l10n/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/jabref/logic/l10n/Localization.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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
Expand All @@ -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);
}
}

Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Empty file.
4 changes: 2 additions & 2 deletions src/test/java/org/jabref/logic/l10n/LanguageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/org/jabref/logic/l10n/LocalizationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

Expand Down