Fix TheMovieDB language codes for Hebrew and Indonesian

@see https://www.filebot.net/forums/viewtopic.php?f=6&t=4898#p30996
This commit is contained in:
Reinhard Pointner 2017-11-08 11:02:55 +01:00
parent 0098840976
commit 9709ef3a42
2 changed files with 26 additions and 9 deletions

View File

@ -383,16 +383,27 @@ public class TMDbClient implements MovieIdentificationService, ArtworkProvider {
}
protected String getLanguageCode(Locale locale) {
// require 2-letter language code
String language = locale.getLanguage();
if (language.length() == 2) {
if (locale.getCountry().length() == 2) {
return locale.getLanguage() + '-' + locale.getCountry(); // e.g. es-MX
}
return locale.getLanguage(); // e.g. en
// Note: ISO 639 is not a stable standard some languages' codes have changed.
// Locale's constructor recognizes both the new and the old codes for the languages whose codes have changed,
// but this function always returns the old code.
switch (language) {
case "iw":
return "he"; // Hebrew
case "in":
return "id"; // Indonesian
case "":
return null; // empty language code
}
return null;
// require 2-letter language code
String country = locale.getCountry();
if (country.length() > 0) {
return language + '-' + country; // e.g. es-MX
}
return language;
}
}

View File

@ -92,11 +92,17 @@ public class TMDbClientTest {
assertEquals("Transformers", movie.getName());
assertEquals("2007-06-27", movie.getReleased().toString());
assertEquals("PG-13", movie.getCertification());
assertEquals("{NL=12, FR=U, BG=C, TH=PG-13, DK=11, SE=15 År, GB=12A, KR=12세 관람가, HU=12, BR=10, AU=M, DE=12, GR=13, US=PG-13}", movie.getCertifications().toString());
assertEquals("{NL=12, AU=M, BG=C, GR=13, KR=12세 관람가, DK=11, GB=12A, TH=PG-13, SE=15, BR=10, HU=12, DE=12, FR=U, US=PG-13}", movie.getCertifications().toString());
assertEquals("[es, en]", movie.getSpokenLanguages().toString());
assertEquals("Shia LaBeouf", movie.getActors().get(0));
assertEquals("Michael Bay", movie.getDirector());
assertEquals("Trailer 2 [Trailer] [720] [en_US]", movie.getTrailers().get(0).toString());
assertEquals("Trailer 2 [Trailer] [720] [en_US] [YouTube::ejxQOv53lXs]", movie.getTrailers().get(0).toString());
}
@Test
public void getMovieInfoHebrew() throws Exception {
MovieInfo movie = db.getMovieInfo(new Movie(1260396), Locale.forLanguageTag("he-IL"), false);
assertEquals("שבעה", movie.getName());
}
@Test