forked from External/mage
Refactor: improved language support in card images sources;
This commit is contained in:
parent
bd644c273f
commit
70012af6db
6 changed files with 125 additions and 35 deletions
68
Mage.Client/src/main/java/mage/client/util/CardLanguage.java
Normal file
68
Mage.Client/src/main/java/mage/client/util/CardLanguage.java
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
package mage.client.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public enum CardLanguage {
|
||||
|
||||
ENGLISH("en", "English"),
|
||||
SPANISH("es", "Spanish"),
|
||||
FRENCH("fr", "French"),
|
||||
GERMAN("de", "German"),
|
||||
ITALIAN("it", "Italian"),
|
||||
PORTUGUESE("pt", "Portuguese"),
|
||||
JAPANESE("jp", "Japanese"),
|
||||
KOREAN("ko", "Korean"),
|
||||
RUSSIAN("ru", "Russian"),
|
||||
CHINES_SIMPLE("cns", "Chinese Simplified"),
|
||||
CHINES_TRADITION("cnt", "Chinese Traditional");
|
||||
|
||||
private final String code;
|
||||
private final String text;
|
||||
|
||||
CardLanguage(String code, String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String[] toList() {
|
||||
ArrayList<String> res = new ArrayList<>();
|
||||
for (CardLanguage l : values()) {
|
||||
res.add(l.toString());
|
||||
}
|
||||
return res.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static CardLanguage valueByText(String text) {
|
||||
for (CardLanguage type : values()) {
|
||||
if (type.text.equals(text)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return CardLanguage.ENGLISH;
|
||||
}
|
||||
|
||||
public static CardLanguage valueByCode(String code) {
|
||||
for (CardLanguage type : values()) {
|
||||
if (type.code.equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return CardLanguage.ENGLISH;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue