* add alias Portuguese (BR) for Brazilian language

This commit is contained in:
Reinhard Pointner 2015-08-18 23:36:15 +00:00
parent 6484e4b3f7
commit ed1bad0478
3 changed files with 22 additions and 10 deletions

View File

@ -23,13 +23,13 @@ public class Language implements Serializable {
private final String iso_639_2B;
// Language name
private final String name;
private final String[] names;
public Language(String iso_639_1, String iso_639_3, String iso_639_2B, String name) {
public Language(String iso_639_1, String iso_639_3, String iso_639_2B, String[] names) {
this.iso_639_1 = iso_639_1;
this.iso_639_3 = iso_639_3;
this.iso_639_2B = iso_639_2B;
this.name = name;
this.names = names.clone();
}
public String getCode() {
@ -49,7 +49,11 @@ public class Language implements Serializable {
}
public String getName() {
return name;
return names[0];
}
public List<String> getNames() {
return unmodifiableList(asList(names));
}
@Override
@ -62,19 +66,27 @@ public class Language implements Serializable {
}
public boolean matches(String code) {
return iso_639_1.equalsIgnoreCase(code) || iso_639_3.equalsIgnoreCase(code) || iso_639_2B.equalsIgnoreCase(code) || name.equalsIgnoreCase(code) || code.toLowerCase().contains(name.toLowerCase());
if (iso_639_1.equalsIgnoreCase(code) || iso_639_3.equalsIgnoreCase(code) || iso_639_2B.equalsIgnoreCase(code)) {
return true;
}
for (String it : names) {
if (it.equalsIgnoreCase(code) || code.toLowerCase().contains(it.toLowerCase())) {
return true;
}
}
return false;
}
@Override
public Language clone() {
return new Language(iso_639_1, iso_639_3, iso_639_2B, name);
return new Language(iso_639_1, iso_639_3, iso_639_2B, names);
}
public static final Comparator<Language> ALPHABETIC_ORDER = new Comparator<Language>() {
@Override
public int compare(Language o1, Language o2) {
return o1.name.compareToIgnoreCase(o2.name);
return o1.getName().compareToIgnoreCase(o2.getName());
}
};
@ -83,7 +95,7 @@ public class Language implements Serializable {
try {
String[] values = bundle.getString(code).split("\\t", 3);
return new Language(code, values[0], values[1], values[2]);
return new Language(code, values[0], values[1], values[2].split("\\t"));
} catch (Exception e) {
return null;
}

View File

@ -4,7 +4,7 @@ languages.common = en,de,fr,es,pt,ru,ja,zh
sq: sqi alb Albanian
ar: ara ara Arabic
hy: hye arm Armenian
pb: pob pob Brazilian
pb: pob pob Brazilian Portuguese (BR)
bg: bul bul Bulgarian
ca: cat cat Catalan
zh: zho chi Chinese

View File

@ -13,7 +13,7 @@ import net.filebot.Language;
public class LanguageComboBoxModel extends AbstractListModel implements ComboBoxModel {
public static final Language ALL_LANGUAGES = new Language("undefined", "undefined", "undefined", "All Languages");
public static final Language ALL_LANGUAGES = new Language("undefined", "undefined", "undefined", new String[] { "All Languages" });
private Language defaultLanguage;
private Language selection;