From 038c6aa24f03c58b6bc7574cf52d090f91c53fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 31 Jul 2024 22:00:22 +0200 Subject: [PATCH] Add `languauge_detection` to instance features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- lib/pleroma/language/language_detector.ex | 6 ++++++ lib/pleroma/web/mastodon_api/views/instance_view.ex | 3 +++ 2 files changed, 9 insertions(+) diff --git a/lib/pleroma/language/language_detector.ex b/lib/pleroma/language/language_detector.ex index 42d200a287..cba2698926 100644 --- a/lib/pleroma/language/language_detector.ex +++ b/lib/pleroma/language/language_detector.ex @@ -5,6 +5,12 @@ defmodule Pleroma.Language.LanguageDetector do @words_threshold 4 + def configured? do + provider = get_provider() + + !!provider and provider.configured? + end + def missing_dependencies do provider = get_provider() diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 829688bfa9..69c4c0c376 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -177,6 +177,9 @@ def features do if Pleroma.Language.Translation.configured?() do "translation" end, + if Pleroma.Language.LanguageDetector.configured?() do + "language_detection" + end, "events", "multitenancy" ]