Merge branch 'localization' into 'develop'
[akkoma] / lib / pleroma / web / translation_helpers.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.TranslationHelpers do
6 defmacro render_error(conn, status, msgid, bindings \\ Macro.escape(%{})) do
7 quote do
8 require Pleroma.Web.Gettext
9
10 unquote(conn)
11 |> Plug.Conn.put_status(unquote(status))
12 |> Phoenix.Controller.json(%{
13 error: Pleroma.Web.Gettext.dgettext("errors", unquote(msgid), unquote(bindings))
14 })
15 end
16 end
17 end