From caa7c6bb09fe8f4e9710326cb1699f58e73cb559 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 4 Sep 2014 16:41:20 +0000 Subject: [PATCH] * make usage of ISO language codes more clear --- source/net/filebot/Language.java | 36 ++++++++++--------- source/net/filebot/cli/CmdlineOperations.java | 2 +- .../filebot/subtitle/SubtitleUtilities.java | 2 +- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/source/net/filebot/Language.java b/source/net/filebot/Language.java index ffe41313..970f23b7 100644 --- a/source/net/filebot/Language.java +++ b/source/net/filebot/Language.java @@ -14,34 +14,38 @@ import java.util.Set; public class Language implements Serializable { // ISO 639-1 code - private final String iso2; + private final String iso_639_1; - // ISO 639-2/T code - private final String iso3; + // ISO 639-3 code (mostly identical to ISO 639-2/T) + private final String iso_639_3; // ISO 639-2/B code - private final String iso3b; + private final String iso_639_2B; // Language name private final String name; - public Language(String iso2, String iso3, String iso3b, String name) { - this.iso2 = iso2; - this.iso3 = iso3; - this.iso3b = iso3b; + public Language(String iso_639_1, String iso_639_3, String iso_639_2B, String name) { + this.iso_639_1 = iso_639_1; + this.iso_639_3 = iso_639_3; + this.iso_639_2B = iso_639_2B; this.name = name; } public String getCode() { - return iso2; + return iso_639_1; } public String getISO2() { - return iso2; + return iso_639_1; // 2-letter code } 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() { @@ -50,7 +54,7 @@ public class Language implements Serializable { @Override public String toString() { - return iso3; + return iso_639_3; } public Locale getLocale() { @@ -58,12 +62,12 @@ public class Language implements Serializable { } 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 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 ALPHABETIC_ORDER = new Comparator() { @@ -116,9 +120,9 @@ public class Language implements Serializable { return null; } - public static String getISO3LanguageCodeByName(String languageName) { + public static String getStandardLanguageCode(String lang) { try { - return Language.findLanguage(languageName).getISO3(); + return Language.findLanguage(lang).getISO3(); } catch (Exception e) { return null; } diff --git a/source/net/filebot/cli/CmdlineOperations.java b/source/net/filebot/cli/CmdlineOperations.java index 6fd3a39f..12d35ab2 100644 --- a/source/net/filebot/cli/CmdlineOperations.java +++ b/source/net/filebot/cli/CmdlineOperations.java @@ -775,7 +775,7 @@ public class CmdlineOperations implements CmdlineInterface { private final SubtitleNaming naming = getSubtitleNaming(format); // 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) { Locale languageSuffix = MediaDetection.releaseInfo.getLanguageSuffix(FileUtilities.getName(f)); diff --git a/source/net/filebot/subtitle/SubtitleUtilities.java b/source/net/filebot/subtitle/SubtitleUtilities.java index 7e5f1717..f1f61643 100644 --- a/source/net/filebot/subtitle/SubtitleUtilities.java +++ b/source/net/filebot/subtitle/SubtitleUtilities.java @@ -314,7 +314,7 @@ public final class SubtitleUtilities { StringBuilder sb = new StringBuilder(name); if (languageName != null) { - String lang = Language.getISO3LanguageCodeByName(languageName); + String lang = Language.getStandardLanguageCode(languageName); if (lang == null) { // we probably won't get here, but just in case