Merge branch 'localization' into 'develop'
[akkoma] / lib / pleroma / web / common_api / utils.ex
index 8b9477927c84c3b5ae7f094a764810863358b88b..8e482eef7b88f9e9520e40e70b039598e0ee3d01 100644 (file)
@@ -3,6 +3,8 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.CommonAPI.Utils do
+  import Pleroma.Web.Gettext
+
   alias Calendar.Strftime
   alias Comeonin.Pbkdf2
   alias Pleroma.Activity
@@ -372,7 +374,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
          true <- Pbkdf2.checkpw(password, db_user.password_hash) do
       {:ok, db_user}
     else
-      _ -> {:error, "Invalid password."}
+      _ -> {:error, dgettext("errors", "Invalid password.")}
     end
   end
 
@@ -455,7 +457,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do
     if String.length(comment) <= max_size do
       {:ok, format_input(comment, "text/plain")}
     else
-      {:error, "Comment must be up to #{max_size} characters"}
+      {:error,
+       dgettext("errors", "Comment must be up to %{max_size} characters", max_size: max_size)}
     end
   end
 
@@ -490,7 +493,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
       context
     else
       _e ->
-        {:error, "No such conversation"}
+        {:error, dgettext("errors", "No such conversation")}
     end
   end
 
@@ -512,10 +515,10 @@ defmodule Pleroma.Web.CommonAPI.Utils do
       if length > 0 or Enum.count(attachments) > 0 do
         :ok
       else
-        {:error, "Cannot post an empty status without attachments"}
+        {:error, dgettext("errors", "Cannot post an empty status without attachments")}
       end
     else
-      {:error, "The status is over the character limit"}
+      {:error, dgettext("errors", "The status is over the character limit")}
     end
   end
 end