From 07829a19b8e9aa7bc5b7536193a488c5aa540c2c Mon Sep 17 00:00:00 2001 From: ta264 Date: Thu, 7 Oct 2021 21:01:45 +0100 Subject: [PATCH] Fixed: Account for ISO 639 B vs T --- src/NzbDrone.Core/Books/Calibre/Extensions.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/NzbDrone.Core/Books/Calibre/Extensions.cs b/src/NzbDrone.Core/Books/Calibre/Extensions.cs index 9b3aa10a9..7c6435b4e 100644 --- a/src/NzbDrone.Core/Books/Calibre/Extensions.cs +++ b/src/NzbDrone.Core/Books/Calibre/Extensions.cs @@ -13,6 +13,31 @@ namespace NzbDrone.Core.Books.Calibre private static readonly Dictionary ByThree; private static readonly Dictionary NameMap; + // generated from https://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt + public static readonly Dictionary BtoTmap = new () + { + { "alb", "sqi" }, + { "arm", "hye" }, + { "baq", "eus" }, + { "bur", "mya" }, + { "chi", "zho" }, + { "cze", "ces" }, + { "dut", "nld" }, + { "fre", "fra" }, + { "geo", "kat" }, + { "ger", "deu" }, + { "gre", "ell" }, + { "ice", "isl" }, + { "mac", "mkd" }, + { "mao", "mri" }, + { "may", "msa" }, + { "per", "fas" }, + { "rum", "ron" }, + { "slo", "slk" }, + { "tib", "bod" }, + { "wel", "cym" } + }; + public static HashSet KnownLanguages { get; } static Extensions() @@ -74,6 +99,11 @@ namespace NzbDrone.Core.Books.Calibre { return raw; } + + if (BtoTmap.TryGetValue(raw, out var mapped)) + { + return mapped; + } } return NameMap.TryGetValue(raw, out var langByName) ? langByName : null;