Save user locale and use it to translate things

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-10-01 13:08:09 +02:00
parent d5a15b8a99
commit a84cfb5910
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
31 changed files with 155 additions and 157 deletions

View File

@ -23,6 +23,7 @@ defmodule Mobilizon.Users.User do
confirmation_token: String.t(),
reset_password_sent_at: DateTime.t(),
reset_password_token: String.t(),
locale: String.t(),
default_actor: Actor.t(),
actors: [Actor.t()],
feed_tokens: [FeedToken.t()]
@ -37,7 +38,8 @@ defmodule Mobilizon.Users.User do
:confirmation_sent_at,
:confirmation_token,
:reset_password_sent_at,
:reset_password_token
:reset_password_token,
:locale
]
@attrs @required_attrs ++ @optional_attrs
@ -59,6 +61,7 @@ defmodule Mobilizon.Users.User do
field(:confirmation_token, :string)
field(:reset_password_sent_at, :utc_datetime)
field(:reset_password_token, :string)
field(:locale, :string, default: "en")
belongs_to(:default_actor, Actor)
has_many(:actors, Actor)

View File

@ -24,7 +24,7 @@ defmodule Mobilizon.Users do
Registers an user.
"""
@spec register(map) :: {:ok, User.t()} | {:error, Ecto.Changeset.t()}
def register(%{email: _email, password: _password} = args) do
def register(args) do
with {:ok, %User{} = user} <-
%User{}
|> User.registration_changeset(args)

View File

@ -17,7 +17,7 @@ defmodule MobilizonWeb.Email.Admin do
@spec report(User.t(), Report.t(), String.t()) :: Bamboo.Email.t()
def report(%User{email: email}, %Report{} = report, locale \\ "en") do
Gettext.put_locale(locale)
MobilizonWeb.Gettext.put_locale(locale)
subject =
gettext(

View File

@ -24,7 +24,7 @@ defmodule MobilizonWeb.Email.Event do
changes,
locale \\ "en"
) do
Gettext.put_locale(locale)
MobilizonWeb.Gettext.put_locale(locale)
subject =
gettext(

View File

@ -46,7 +46,7 @@ defmodule MobilizonWeb.Email.Participation do
%Participant{event: event, role: :rejected},
locale
) do
Gettext.put_locale(locale)
MobilizonWeb.Gettext.put_locale(locale)
subject =
gettext(
@ -67,7 +67,7 @@ defmodule MobilizonWeb.Email.Participation do
%Participant{event: event, role: :participant},
locale
) do
Gettext.put_locale(locale)
MobilizonWeb.Gettext.put_locale(locale)
subject =
gettext(

View File

@ -19,7 +19,7 @@ defmodule MobilizonWeb.Email.User do
%User{email: email, confirmation_token: confirmation_token},
locale \\ "en"
) do
Gettext.put_locale(locale)
MobilizonWeb.Gettext.put_locale(locale)
subject =
gettext(
@ -39,7 +39,7 @@ defmodule MobilizonWeb.Email.User do
%User{email: email, reset_password_token: reset_password_token},
locale \\ "en"
) do
Gettext.put_locale(locale)
MobilizonWeb.Gettext.put_locale(locale)
subject =
gettext(

View File

@ -21,4 +21,27 @@ defmodule MobilizonWeb.Gettext do
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
"""
use Gettext, otp_app: :mobilizon
def put_locale(locale) do
locale = determine_best_locale(locale)
Gettext.put_locale(MobilizonWeb.Gettext, locale)
end
@spec determine_best_locale(String.t()) :: String.t()
def determine_best_locale(locale) do
locale = String.trim(locale)
locales = Gettext.known_locales(MobilizonWeb.Gettext)
cond do
# Either it matches directly, eg: "en" => "en", "fr" => "fr", "fr_FR" => "fr_FR"
locale in locales -> locale
# Either the first part matches, "fr_CA" => "fr"
split_locale(locale) in locales -> split_locale(locale)
# Otherwise default to english
true -> "en"
end
end
# Keep only the first part of the locale
defp split_locale(locale), do: locale |> String.split("_", trim: true, parts: 2) |> hd
end

View File

@ -116,7 +116,7 @@ defmodule MobilizonWeb.Resolvers.User do
with {:registrations_open, true} <-
{:registrations_open, Config.instance_registrations_open?()},
{:ok, %User{} = user} <- Users.register(args) do
Activation.send_confirmation_email(user)
Activation.send_confirmation_email(user, Map.get(args, :locale, "en"))
{:ok, user}
else
{:registrations_open, false} ->
@ -154,10 +154,11 @@ defmodule MobilizonWeb.Resolvers.User do
Send the confirmation email again.
We only do this to accounts unconfirmed
"""
def resend_confirmation_email(_parent, %{email: email, locale: locale}, _resolution) do
with {:ok, user} <- Users.get_user_by_email(email, false),
def resend_confirmation_email(_parent, args, _resolution) do
with {:ok, %User{locale: locale} = user} <-
Users.get_user_by_email(Map.get(args, :email), false),
{:ok, email} <-
Activation.resend_confirmation_email(user, locale) do
Activation.resend_confirmation_email(user, Map.get(args, :locale, locale)) do
{:ok, email}
else
{:error, :user_not_found} ->
@ -171,10 +172,11 @@ defmodule MobilizonWeb.Resolvers.User do
@doc """
Send an email to reset the password from an user
"""
def send_reset_password(_parent, %{email: email, locale: locale}, _resolution) do
with {:ok, user} <- Users.get_user_by_email(email, true),
def send_reset_password(_parent, args, _resolution) do
with email <- Map.get(args, :email),
{:ok, %User{locale: locale} = user} <- Users.get_user_by_email(email, true),
{:ok, %Bamboo.Email{} = _email_html} <-
ResetPassword.send_password_reset_email(user, locale) do
ResetPassword.send_password_reset_email(user, Map.get(args, :locale, locale)) do
{:ok, email}
else
{:error, :user_not_found} ->

View File

@ -46,6 +46,8 @@ defmodule MobilizonWeb.Schema.UserType do
field(:role, :user_role, description: "The role for the user")
field(:locale, :string, description: "The user's locale")
field(:participations, list_of(:participant),
description: "The list of events this user goes to"
) do
@ -109,6 +111,7 @@ defmodule MobilizonWeb.Schema.UserType do
field :create_user, type: :user do
arg(:email, non_null(:string))
arg(:password, non_null(:string))
arg(:locale, :string)
resolve(handle_errors(&User.create_user/3))
end
@ -122,14 +125,14 @@ defmodule MobilizonWeb.Schema.UserType do
@desc "Resend registration confirmation token"
field :resend_confirmation_email, type: :string do
arg(:email, non_null(:string))
arg(:locale, :string, default_value: "en")
arg(:locale, :string)
resolve(&User.resend_confirmation_email/3)
end
@desc "Send a link through email to reset user password"
field :send_reset_password, type: :string do
arg(:email, non_null(:string))
arg(:locale, :string, default_value: "en")
arg(:locale, :string)
resolve(&User.send_reset_password/3)
end

View File

@ -58,7 +58,7 @@
<%= gettext "Start of event" %>
</td>
<td bgcolor="#ffffff" align="left">
<%= datetime_to_string(@event.begins_on) %>
<%= datetime_to_string(@event.begins_on, @locale) %>
</td>
</tr>
<% end %>
@ -68,7 +68,7 @@
<%= gettext "Ending of event" %>
</td>
<td bgcolor="#ffffff" align="left">
<%= datetime_to_string(@event.ends_on) %>
<%= datetime_to_string(@event.ends_on, @locale) %>
</td>
</tr>
<% end %>

View File

@ -9,11 +9,11 @@
<% end %>
<%= if MapSet.member?(@changes, :begins_on) do %>
<%= gettext "New date and time for start of event: %{begins_on}", begins_on: datetime_to_string(@event.begins_on) %>
<%= gettext "New date and time for start of event: %{begins_on}", begins_on: datetime_to_string(@event.begins_on, @locale) %>
<% end %>
<%= if MapSet.member?(@changes, :ends_on) do %>
<%= gettext "New date and time for ending of event: %{ends_on}", ends_on: datetime_to_string(@event.ends_on) %>
<%= gettext "New date and time for ending of event: %{ends_on}", ends_on: datetime_to_string(@event.ends_on, @locale) %>
<% end %>
<%= gettext "View the updated event on: %{link}", link: page_url(MobilizonWeb.Endpoint, :event, @event.id) %>

View File

@ -35,7 +35,7 @@
<tr>
<td bgcolor="#ffffff" align="left" style="padding: 20px 30px 0px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
<p style="margin: 0;">
<%= gettext "You requested a new password for your account on %{server}.", server: @instance[:name] %>
<%= gettext "You requested a new password for your account on %{instance}.", instance: @instance[:name] %>
</p>
<p style="margin: 0">
<%= gettext "Resetting your password is easy. Just press the button below and follow the instructions. We'll have you up and running in no time." %>

View File

@ -2,7 +2,7 @@
==
<%= gettext "You requested a new password for your account on %{host}.", host: @instance[:name] %>
<%= gettext "You requested a new password for your account on %{instance}.", instance: @instance[:name] %>
<%= gettext "Resetting your password is easy. Just click the link below and follow the instructions. We'll have you up and running in no time." %>

View File

@ -1,6 +1,8 @@
defmodule MobilizonWeb.EmailView do
use MobilizonWeb, :view
import MobilizonWeb.Gettext
def datetime_to_string(%DateTime{} = datetime, locale \\ "en") do
with {:ok, string} <-
Cldr.DateTime.to_string(datetime, Mobilizon.Cldr, format: :medium, locale: locale) do

View File

@ -38,13 +38,13 @@ defmodule Mobilizon.Service.Events.Tool do
end
defp send_notification_for_event_update_to_participant(
{%Actor{} = actor, %User{} = user},
{%Actor{} = actor, %User{locale: locale} = user},
%Event{} = old_event,
%Event{} = event,
diff
) do
user
|> Email.Event.event_updated(actor, old_event, event, diff)
|> Email.Event.event_updated(actor, old_event, event, diff, locale)
|> Email.Mailer.deliver_later()
end
end

View File

@ -122,11 +122,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -217,11 +212,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -299,3 +289,9 @@ msgstr ""
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr ""
#, elixir-format, fuzzy
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr ""

View File

@ -122,11 +122,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -217,11 +212,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -299,3 +289,9 @@ msgstr ""
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr ""
#, elixir-format, fuzzy
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr ""

View File

@ -108,11 +108,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -203,11 +198,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -285,3 +275,9 @@ msgstr ""
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr ""

View File

@ -134,11 +134,6 @@ msgstr ""
"You created an account on %{host} with this email address. You are one click "
"away from activating it."
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr "You requested a new password for your account on %{server}."
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -239,11 +234,6 @@ msgstr ""
"You created an account on %{host} with this email address. You are one click "
"away from activating it."
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr "You requested a new password for your account on %{server}."
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -321,3 +311,9 @@ msgstr ""
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr "Your participation to event %{title} has been rejected"
#, elixir-format, fuzzy
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr "You requested a new password for your account on %{instance}."

View File

@ -122,11 +122,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -217,11 +212,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -299,3 +289,9 @@ msgstr ""
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr ""
#, elixir-format, fuzzy
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr ""

View File

@ -13,7 +13,7 @@ msgstr ""
"PO-Revision-Date: 2019-09-30 17:10+0000\n"
"Last-Translator: Thomas Citharel <thomas.citharel@framasoft.org>\n"
"Language-Team: French <https://weblate.framasoft.org/projects/mobilizon/backend/fr/>\n"
"Language: fr_FR\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -130,11 +130,6 @@ msgstr "Voir le signalement"
msgid "You created an account on %{host} with this email address. You are one click away from activating it."
msgstr "Vous avez créé un compte sur %{host} avec cette adresse email. Vous êtes à un clic de l'activer."
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr "Vous avez demandé un nouveau mot de passe pour votre compte sur %{server}."
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -234,11 +229,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email."
msgstr "Vous avez créé un compte sur %{host} avec cette adresse email. Vous êtes à un clic de l'activer."
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr "Vous avez demandé un nouveau mot de passe pour votre compte sur %{server}."
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -316,3 +306,9 @@ msgstr "Titre"
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr "Voir l'événement mis à jour sur : %{link}"
#, elixir-format, fuzzy
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr "Vous avez demandé un nouveau mot de passe pour votre compte sur %{instance}."

View File

@ -122,11 +122,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -217,11 +212,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -299,3 +289,9 @@ msgstr ""
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr ""
#, elixir-format, fuzzy
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr ""

View File

@ -122,11 +122,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -217,11 +212,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -299,3 +289,9 @@ msgstr ""
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr ""
#, elixir-format, fuzzy
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr ""

View File

@ -122,11 +122,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -217,11 +212,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -299,3 +289,9 @@ msgstr ""
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr ""
#, elixir-format, fuzzy
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr ""

View File

@ -132,11 +132,6 @@ msgstr ""
"Avètz creat un compte sus %{host} amb aquesta adreça electronica. Sètz a un "
"clic de lactivar."
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr "Avètz demandat un nòu senhal per vòstre compte sus %{server}."
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -231,11 +226,6 @@ msgstr ""
"Avètz creat un compte sus %{host} amb aquesta adreça electronica. Sètz a un "
"clic de lactivar."
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr "Avètz demandat un nòu senhal per vòstre compte sus %{server}."
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -313,3 +303,9 @@ msgstr ""
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr ""
#, elixir-format, fuzzy
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr "Avètz demandat un nòu senhal per vòstre compte sus %{instance}."

View File

@ -122,11 +122,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -217,11 +212,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -299,3 +289,9 @@ msgstr ""
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr ""
#, elixir-format, fuzzy
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr ""

View File

@ -122,11 +122,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -217,11 +212,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -299,3 +289,9 @@ msgstr ""
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr ""
#, elixir-format, fuzzy
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr ""

View File

@ -122,11 +122,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
msgid "You requested a new password for your account on %{server}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/email/user.ex:25
msgid "Instructions to confirm your Mobilizon account on %{instance}"
@ -217,11 +212,6 @@ msgstr ""
msgid "You created an account on %{host} with this email address. You are one click away from activating it. If this wasn't you, please ignore this email."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{host}."
msgstr ""
#, elixir-format
#: lib/mobilizon_web/templates/email/event_participation_approved.html.eex:38
msgid "You requested to participate in event %{title}"
@ -299,3 +289,9 @@ msgstr ""
#: lib/mobilizon_web/templates/email/event_updated.text.eex:19
msgid "View the updated event on: %{link}"
msgstr ""
#, elixir-format, fuzzy
#: lib/mobilizon_web/templates/email/password_reset.html.eex:38
#: lib/mobilizon_web/templates/email/password_reset.text.eex:5
msgid "You requested a new password for your account on %{instance}."
msgstr ""

View File

@ -0,0 +1,9 @@
defmodule Mobilizon.Storage.Repo.Migrations.AddLocaleToUsers do
use Ecto.Migration
def change do
alter table(:users) do
add(:locale, :string, default: "en")
end
end
end

View File

@ -220,6 +220,7 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do
@user_creation %{
email: "test@demo.tld",
password: "long password",
locale: "fr_FR",
username: "toto",
name: "Sir Toto",
summary: "Sir Toto, prince of the functional tests"
@ -236,9 +237,11 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do
createUser(
email: "#{@user_creation.email}",
password: "#{@user_creation.password}",
locale: "#{@user_creation.locale}"
) {
id,
email
email,
locale
}
}
"""
@ -248,6 +251,11 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
assert json_response(res, 200)["data"]["createUser"]["email"] == @user_creation.email
assert json_response(res, 200)["data"]["createUser"]["locale"] == @user_creation.locale
{:ok, user} = Users.get_user_by_email(@user_creation.email)
assert_delivered_email(Email.User.confirmation_email(user, @user_creation.locale))
mutation = """
mutation {