From 066ec8fe955b9ff1e3cf15a76a8f2c4968015213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 30 Oct 2022 22:57:20 +0100 Subject: [PATCH] Update description.exs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- config/description.exs | 34 +++++++++++++++++++++-- lib/pleroma/translation/deepl.ex | 4 +-- lib/pleroma/translation/libretranslate.ex | 2 +- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/config/description.exs b/config/description.exs index 0efea0882..bdf2fc2f3 100644 --- a/config/description.exs +++ b/config/description.exs @@ -3531,9 +3531,37 @@ config :pleroma, :config_description, [ description: "Translation providers", children: [ %{ - key: Pleroma.Translation, - type: :service, - suggestions: [Pleroma.Translation.DeepL, Pleroma.Translation.LibreTranslate] + key: :service, + type: :module, + suggestions: [Pleroma.Translation.Deepl, Pleroma.Translation.Libretranslate] + }, + %{ + group: {:subgroup, Pleroma.Translation.Deepl}, + key: :plan, + label: "DeepL plan", + type: {:dropdown, :atom}, + suggestions: [:free, :pro] + }, + %{ + group: {:subgroup, Pleroma.Translation.Deepl}, + key: :api_key, + label: "DeepL API Key", + type: :string, + suggestions: ["YOUR_API_KEY"] + }, + %{ + group: {:subgroup, Pleroma.Translation.Libretranslate}, + key: :base_url, + label: "LibreTranslate plan", + type: :string, + suggestions: ["https://libretranslate.com"] + }, + %{ + group: {:subgroup, Pleroma.Translation.Libretranslate}, + key: :api_key, + label: "LibreTranslate API Key", + type: :string, + suggestions: ["YOUR_API_KEY"] } ] } diff --git a/lib/pleroma/translation/deepl.ex b/lib/pleroma/translation/deepl.ex index 76fff4693..944dab8ec 100644 --- a/lib/pleroma/translation/deepl.ex +++ b/lib/pleroma/translation/deepl.ex @@ -2,7 +2,7 @@ # Copyright © 2017-2022 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only -defmodule Pleroma.Translation.DeepL do +defmodule Pleroma.Translation.Deepl do import Pleroma.Web.Utils.Guards, only: [not_empty_string: 1] alias Pleroma.Translation.Service @@ -60,7 +60,7 @@ defmodule Pleroma.Translation.DeepL do defp endpoint_url do case get_plan() do - "free" -> "https://api-free.deepl.com/v2/translate" + :free -> "https://api-free.deepl.com/v2/translate" _ -> "https://api.deepl.com/v2/translate" end end diff --git a/lib/pleroma/translation/libretranslate.ex b/lib/pleroma/translation/libretranslate.ex index 049053d43..9c9b4b9b5 100644 --- a/lib/pleroma/translation/libretranslate.ex +++ b/lib/pleroma/translation/libretranslate.ex @@ -2,7 +2,7 @@ # Copyright © 2017-2022 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only -defmodule Pleroma.Translation.LibreTranslate do +defmodule Pleroma.Translation.Libretranslate do import Pleroma.Web.Utils.Guards, only: [not_empty_string: 1] alias Pleroma.Translation.Service