1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-15 22:05:00 -05:00

* make usage of ISO language codes more clear

This commit is contained in:
Reinhard Pointner 2014-09-04 16:41:20 +00:00
parent 859436e727
commit caa7c6bb09
3 changed files with 22 additions and 18 deletions

View File

@ -14,34 +14,38 @@ import java.util.Set;
public class Language implements Serializable { public class Language implements Serializable {
// ISO 639-1 code // ISO 639-1 code
private final String iso2; private final String iso_639_1;
// ISO 639-2/T code // ISO 639-3 code (mostly identical to ISO 639-2/T)
private final String iso3; private final String iso_639_3;
// ISO 639-2/B code // ISO 639-2/B code
private final String iso3b; private final String iso_639_2B;
// Language name // Language name
private final String name; private final String name;
public Language(String iso2, String iso3, String iso3b, String name) { public Language(String iso_639_1, String iso_639_3, String iso_639_2B, String name) {
this.iso2 = iso2; this.iso_639_1 = iso_639_1;
this.iso3 = iso3; this.iso_639_3 = iso_639_3;
this.iso3b = iso3b; this.iso_639_2B = iso_639_2B;
this.name = name; this.name = name;
} }
public String getCode() { public String getCode() {
return iso2; return iso_639_1;
} }
public String getISO2() { public String getISO2() {
return iso2; return iso_639_1; // 2-letter code
} }
public String getISO3() { public String getISO3() {
return iso3; return iso_639_3; // 3-letter code
}
public String getISO3B() {
return iso_639_2B; // alternative 3-letter code
} }
public String getName() { public String getName() {
@ -50,7 +54,7 @@ public class Language implements Serializable {
@Override @Override
public String toString() { public String toString() {
return iso3; return iso_639_3;
} }
public Locale getLocale() { public Locale getLocale() {
@ -58,12 +62,12 @@ public class Language implements Serializable {
} }
public boolean matches(String code) { public boolean matches(String code) {
return iso2.equalsIgnoreCase(code) || iso3.equalsIgnoreCase(code) || iso3b.equalsIgnoreCase(code) || name.equalsIgnoreCase(code); return iso_639_1.equalsIgnoreCase(code) || iso_639_3.equalsIgnoreCase(code) || iso_639_2B.equalsIgnoreCase(code) || name.equalsIgnoreCase(code);
} }
@Override @Override
public Language clone() { public Language clone() {
return new Language(iso2, iso3, iso3b, name); return new Language(iso_639_1, iso_639_3, iso_639_2B, name);
} }
public static final Comparator<Language> ALPHABETIC_ORDER = new Comparator<Language>() { public static final Comparator<Language> ALPHABETIC_ORDER = new Comparator<Language>() {
@ -116,9 +120,9 @@ public class Language implements Serializable {
return null; return null;
} }
public static String getISO3LanguageCodeByName(String languageName) { public static String getStandardLanguageCode(String lang) {
try { try {
return Language.findLanguage(languageName).getISO3(); return Language.findLanguage(lang).getISO3();
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }

View File

@ -775,7 +775,7 @@ public class CmdlineOperations implements CmdlineInterface {
private final SubtitleNaming naming = getSubtitleNaming(format); private final SubtitleNaming naming = getSubtitleNaming(format);
// get language code suffix for given language (.eng) // get language code suffix for given language (.eng)
private final String languageCode = Language.getISO3LanguageCodeByName(getLanguage(languageName).getName()); private final String languageCode = Language.getStandardLanguageCode(getLanguage(languageName).getName());
public boolean matchesLanguageCode(File f) { public boolean matchesLanguageCode(File f) {
Locale languageSuffix = MediaDetection.releaseInfo.getLanguageSuffix(FileUtilities.getName(f)); Locale languageSuffix = MediaDetection.releaseInfo.getLanguageSuffix(FileUtilities.getName(f));

View File

@ -314,7 +314,7 @@ public final class SubtitleUtilities {
StringBuilder sb = new StringBuilder(name); StringBuilder sb = new StringBuilder(name);
if (languageName != null) { if (languageName != null) {
String lang = Language.getISO3LanguageCodeByName(languageName); String lang = Language.getStandardLanguageCode(languageName);
if (lang == null) { if (lang == null) {
// we probably won't get here, but just in case // we probably won't get here, but just in case