From 214e8d7172a32bd319c711204ec865726e2a8394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 14 Dec 2022 18:21:43 +0100 Subject: [PATCH] Include unspecified variants in target languages list for DeepL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- lib/pleroma/language/translation/deepl.ex | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/pleroma/language/translation/deepl.ex b/lib/pleroma/language/translation/deepl.ex index 8ce1209cc3..0b56b35d73 100644 --- a/lib/pleroma/language/translation/deepl.ex +++ b/lib/pleroma/language/translation/deepl.ex @@ -80,6 +80,15 @@ def supported_languages(type) when type in [:source, :target] do languages = Jason.decode!(res.body) |> Enum.map(fn %{"language" => language} -> language |> String.downcase() end) + |> Enum.map(fn language -> + if String.contains?(language, "-") do + [language, language |> String.split("-") |> Enum.at(0)] + else + language + end + end) + |> List.flatten() + |> Enum.uniq() {:ok, languages}