-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix exceptions when trying to change settings (#4284)
I also took the opportunity to improve a few things around our localization code (mainly converting Languages to enum).
- Loading branch information
1 parent
835bb47
commit 4dc1008
Showing
11 changed files
with
177 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.jabref.logic.l10n; | ||
|
||
import java.util.Locale; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Contains all supported languages. | ||
*/ | ||
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"); | ||
|
||
private final String displayName; | ||
private final String id; | ||
|
||
Language(String displayName, String id) { | ||
this.displayName = displayName; | ||
this.id = id; | ||
} | ||
|
||
public static Optional<Locale> convertToSupportedLocale(Language language) { | ||
Objects.requireNonNull(language); | ||
|
||
//Very important to split languages like pt_BR into two parts, because otherwise the country would be treated lowercase and create problems in loading | ||
String[] languageParts = language.getId().split("_"); | ||
Locale locale; | ||
if (languageParts.length == 1) { | ||
locale = new Locale(languageParts[0]); | ||
} else if (languageParts.length == 2) { | ||
locale = new Locale(languageParts[0], languageParts[1]); | ||
} else { | ||
locale = Locale.ENGLISH; | ||
} | ||
|
||
return Optional.of(locale); | ||
|
||
} | ||
|
||
public String getDisplayName() { | ||
return displayName; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.