mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-23 16:33:28 +00:00
a670a7d7a7
- Refactor plugs to detect and set language - Translate ecto validation errors - Use Gettext directly, not Mobilizon.Web.Gettext - Set the language in the <html> attribute according to the one loaded on front-end Signed-off-by: Thomas Citharel <tcit@tcit.fr>
40 lines
1.1 KiB
Elixir
40 lines
1.1 KiB
Elixir
defmodule Mobilizon.Service.Activity.Renderer.Group do
|
|
@moduledoc """
|
|
Insert a comment activity
|
|
"""
|
|
alias Mobilizon.Activities.Activity
|
|
alias Mobilizon.Actors.Actor
|
|
alias Mobilizon.Service.Activity.Renderer
|
|
alias Mobilizon.Web.Endpoint
|
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
|
import Mobilizon.Web.Gettext, only: [dgettext: 3]
|
|
|
|
@behaviour Renderer
|
|
|
|
@impl Renderer
|
|
def render(%Activity{} = activity, options) do
|
|
locale = Keyword.get(options, :locale, "en")
|
|
Gettext.put_locale(locale)
|
|
|
|
case activity.subject do
|
|
:group_updated ->
|
|
%{
|
|
body:
|
|
dgettext("activity", "The group %{group} was updated by %{profile}.", %{
|
|
profile: profile(activity),
|
|
group: group(activity)
|
|
}),
|
|
url: group_url(activity)
|
|
}
|
|
end
|
|
end
|
|
|
|
defp group_url(activity) do
|
|
Endpoint
|
|
|> Routes.page_url(:actor, Actor.preferred_username_and_domain(activity.group))
|
|
|> URI.decode()
|
|
end
|
|
|
|
defp profile(activity), do: Actor.display_name_and_username(activity.author)
|
|
defp group(activity), do: Actor.display_name_and_username(activity.group)
|
|
end
|