logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

translation_helpers.ex (814B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.TranslationHelpers do
  5. defmacro render_error(
  6. conn,
  7. status,
  8. msgid,
  9. bindings \\ Macro.escape(%{}),
  10. identifier \\ Macro.escape("")
  11. ) do
  12. quote do
  13. require Pleroma.Web.Gettext
  14. error_map =
  15. %{
  16. error: Pleroma.Web.Gettext.dgettext("errors", unquote(msgid), unquote(bindings)),
  17. identifier: unquote(identifier)
  18. }
  19. |> Enum.reject(fn {_k, v} -> v == "" end)
  20. |> Map.new()
  21. unquote(conn)
  22. |> Plug.Conn.put_status(unquote(status))
  23. |> Phoenix.Controller.json(error_map)
  24. end
  25. end
  26. end