forked from shibao/cannery
		
	gettext User
This commit is contained in:
		| @@ -5,6 +5,7 @@ defmodule Cannery.Accounts.User do | |||||||
|  |  | ||||||
|   use Ecto.Schema |   use Ecto.Schema | ||||||
|   import Ecto.Changeset |   import Ecto.Changeset | ||||||
|  |   import CanneryWeb.Gettext | ||||||
|   alias Ecto.{Changeset, UUID} |   alias Ecto.{Changeset, UUID} | ||||||
|   alias Cannery.{Accounts.User, Invites.Invite} |   alias Cannery.{Accounts.User, Invites.Invite} | ||||||
|  |  | ||||||
| @@ -77,7 +78,9 @@ defmodule Cannery.Accounts.User do | |||||||
|   defp validate_email(changeset) do |   defp validate_email(changeset) do | ||||||
|     changeset |     changeset | ||||||
|     |> validate_required([:email]) |     |> validate_required([:email]) | ||||||
|     |> validate_format(:email, ~r/^[^\s]+@[^\s]+$/, message: "must have the @ sign and no spaces") |     |> validate_format(:email, ~r/^[^\s]+@[^\s]+$/, | ||||||
|  |       message: dgettext("errors", "must have the @ sign and no spaces") | ||||||
|  |     ) | ||||||
|     |> validate_length(:email, max: 160) |     |> validate_length(:email, max: 160) | ||||||
|     |> unsafe_validate_unique(:email, Cannery.Repo) |     |> unsafe_validate_unique(:email, Cannery.Repo) | ||||||
|     |> unique_constraint(:email) |     |> unique_constraint(:email) | ||||||
| @@ -122,7 +125,7 @@ defmodule Cannery.Accounts.User do | |||||||
|     |> validate_email() |     |> validate_email() | ||||||
|     |> case do |     |> case do | ||||||
|       %{changes: %{email: _}} = changeset -> changeset |       %{changes: %{email: _}} = changeset -> changeset | ||||||
|       %{} = changeset -> add_error(changeset, :email, "did not change") |       %{} = changeset -> add_error(changeset, :email, dgettext("errors", "did not change")) | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|  |  | ||||||
| @@ -143,7 +146,7 @@ defmodule Cannery.Accounts.User do | |||||||
|   def password_changeset(user, attrs, opts \\ []) do |   def password_changeset(user, attrs, opts \\ []) do | ||||||
|     user |     user | ||||||
|     |> cast(attrs, [:password]) |     |> cast(attrs, [:password]) | ||||||
|     |> validate_confirmation(:password, message: "does not match password") |     |> validate_confirmation(:password, message: dgettext("errors", "does not match password")) | ||||||
|     |> validate_password(opts) |     |> validate_password(opts) | ||||||
|   end |   end | ||||||
|  |  | ||||||
| @@ -180,6 +183,6 @@ defmodule Cannery.Accounts.User do | |||||||
|   def validate_current_password(changeset, password) do |   def validate_current_password(changeset, password) do | ||||||
|     if valid_password?(changeset.data, password), |     if valid_password?(changeset.data, password), | ||||||
|       do: changeset, |       do: changeset, | ||||||
|       else: changeset |> add_error(:current_password, "is not valid") |       else: changeset |> add_error(:current_password, dgettext("errors", "is not valid")) | ||||||
|   end |   end | ||||||
| end | end | ||||||
|   | |||||||
| @@ -99,3 +99,23 @@ msgid "There is still %{amount} ammo group in this container!" | |||||||
| msgid_plural "There are still %{amount} ammo groups in this container!" | msgid_plural "There are still %{amount} ammo groups in this container!" | ||||||
| msgstr[0] "" | msgstr[0] "" | ||||||
| msgstr[1] "" | msgstr[1] "" | ||||||
|  |  | ||||||
|  | #, elixir-format, ex-autogen | ||||||
|  | #: lib/cannery/accounts/user.ex:128 | ||||||
|  | msgid "did not change" | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
|  | #, elixir-format, ex-autogen | ||||||
|  | #: lib/cannery/accounts/user.ex:149 | ||||||
|  | msgid "does not match password" | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
|  | #, elixir-format, ex-autogen | ||||||
|  | #: lib/cannery/accounts/user.ex:186 | ||||||
|  | msgid "is not valid" | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
|  | #, elixir-format, ex-autogen | ||||||
|  | #: lib/cannery/accounts/user.ex:82 | ||||||
|  | msgid "must have the @ sign and no spaces" | ||||||
|  | msgstr "" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user