Merge branch 'target-languages' into 'develop'

Include unspecified variants in target languages list for DeepL

See merge request soapbox-pub/rebased!227
This commit is contained in:
marcin mikołajczak 2022-12-16 15:10:16 +00:00
commit 8a1898591e

View file

@ -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}