Rename
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
066ec8fe95
commit
2b739faa7e
10 changed files with 34 additions and 31 deletions
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Translation do
|
||||
defmodule Pleroma.Language.Translation do
|
||||
@cachex Pleroma.Config.get([:cachex, :provider], Cachex)
|
||||
|
||||
def configured? do
|
||||
|
|
@ -37,7 +37,7 @@ defmodule Pleroma.Translation do
|
|||
end
|
||||
end
|
||||
|
||||
defp get_service, do: Pleroma.Config.get([__MODULE__, :service])
|
||||
defp get_service, do: Pleroma.Config.get([__MODULE__, :provider])
|
||||
|
||||
defp get_cache_key(text, source_language, target_language) do
|
||||
"#{source_language}/#{target_language}/#{content_hash(text)}"
|
||||
|
|
@ -2,19 +2,19 @@
|
|||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Translation.Deepl do
|
||||
defmodule Pleroma.Language.Translation.Deepl do
|
||||
import Pleroma.Web.Utils.Guards, only: [not_empty_string: 1]
|
||||
|
||||
alias Pleroma.Translation.Service
|
||||
alias Pleroma.Language.Translation.Provider
|
||||
|
||||
@behaviour Service
|
||||
@behaviour Provider
|
||||
|
||||
@impl Service
|
||||
@impl Provider
|
||||
def configured? do
|
||||
not_empty_string(get_plan()) and not_empty_string(get_api_key())
|
||||
end
|
||||
|
||||
@impl Service
|
||||
@impl Provider
|
||||
def translate(content, source_language, target_language) do
|
||||
endpoint = endpoint_url()
|
||||
|
||||
|
|
@ -2,17 +2,17 @@
|
|||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Translation.Libretranslate do
|
||||
defmodule Pleroma.Language.Translation.Libretranslate do
|
||||
import Pleroma.Web.Utils.Guards, only: [not_empty_string: 1]
|
||||
|
||||
alias Pleroma.Translation.Service
|
||||
alias Pleroma.Language.Translation.Provider
|
||||
|
||||
@behaviour Service
|
||||
@behaviour Provider
|
||||
|
||||
@impl Service
|
||||
@impl Provider
|
||||
def configured?, do: not_empty_string(get_base_url())
|
||||
|
||||
@impl Service
|
||||
@impl Provider
|
||||
def translate(content, source_language, target_language) do
|
||||
endpoint = endpoint_url()
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Translation.Service do
|
||||
defmodule Pleroma.Language.Translation.Provider do
|
||||
@callback configured?() :: boolean()
|
||||
|
||||
@callback translate(
|
||||
|
|
@ -12,10 +12,10 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Bookmark
|
||||
alias Pleroma.Language.Translation
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.ScheduledActivity
|
||||
alias Pleroma.Translation
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.ActivityPub.Visibility
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
|
|||
end,
|
||||
"pleroma:get:main/ostatus",
|
||||
"pleroma:group_actors",
|
||||
if Pleroma.Translation.configured?() do
|
||||
if Pleroma.Language.Translation.configured?() do
|
||||
"translation"
|
||||
end
|
||||
]
|
||||
|
|
@ -206,7 +206,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
|
|||
vapid: %{
|
||||
public_key: Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key)
|
||||
},
|
||||
translation: %{enabled: Pleroma.Translation.configured?()}
|
||||
translation: %{enabled: Pleroma.Language.Translation.configured?()}
|
||||
})
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue