gettext invites and tags

This commit is contained in:
2022-02-09 00:58:53 -05:00
parent 91b9e8a730
commit 5451728541
10 changed files with 192 additions and 47 deletions

View File

@ -50,17 +50,17 @@ defmodule CanneryWeb.InviteLive.FormComponent do
</div>
<% end %>
<%= label(f, :name, class: "title text-lg text-primary-500") %>
<%= label(f, :name, gettext("Name"), class: "title text-lg text-primary-500") %>
<%= text_input(f, :name, class: "input input-primary col-span-2") %>
<%= error_tag(f, :name, "col-span-3") %>
<%= label(f, :uses_left, class: "title text-lg text-primary-500") %>
<%= label(f, :uses_left, gettext("Uses left"), class: "title text-lg text-primary-500") %>
<%= number_input(f, :uses_left, min: 0, class: "input input-primary col-span-2") %>
<%= error_tag(f, :uses_left, "col-span-3") %>
<%= submit("Save",
<%= submit(dgettext("actions", "Save"),
class: "mx-auto btn btn-primary col-span-3",
phx_disable_with: "Saving..."
phx_disable_with: dgettext("prompts", "Saving...")
) %>
</.form>
</div>
@ -72,7 +72,7 @@ defmodule CanneryWeb.InviteLive.FormComponent do
{:ok, _invite} ->
{:noreply,
socket
|> put_flash(:info, "Invite updated successfully")
|> put_flash(:info, dgettext("prompts", "Invite updated successfully"))
|> push_redirect(to: socket.assigns.return_to)}
{:error, %Changeset{} = changeset} ->
@ -85,7 +85,7 @@ defmodule CanneryWeb.InviteLive.FormComponent do
{:ok, _invite} ->
{:noreply,
socket
|> put_flash(:info, "Invite created successfully")
|> put_flash(:info, dgettext("prompts", "Invite created successfully"))
|> push_redirect(to: socket.assigns.return_to)}
{:error, %Changeset{} = changeset} ->

View File

@ -20,17 +20,17 @@ defmodule CanneryWeb.InviteLive.Index do
defp apply_action(socket, :edit, %{"id" => id}) do
socket
|> assign(page_title: "Edit Invite", invite: Invites.get_invite!(id))
|> assign(page_title: gettext("Edit Invite"), invite: Invites.get_invite!(id))
end
defp apply_action(socket, :new, _params) do
socket
|> assign(page_title: "New Invite", invite: %Invite{})
|> assign(page_title: gettext("New Invite"), invite: %Invite{})
end
defp apply_action(socket, :index, _params) do
socket
|> assign(page_title: "Listing Invites", invite: nil)
|> assign(page_title: gettext("Listing Invites"), invite: nil)
end
@impl true

View File

@ -1,22 +1,20 @@
<div class="flex flex-col space-y-8 justify-center items-center">
<h1 class="title text-2xl title-primary-500">
Listing Invites
<%= gettext("Listing Invites") %>
</h1>
<%= if @invites |> Enum.empty?() do %>
<h1 class="title text-xl text-primary-500">
No invites 😔
<%= gettext("No invites") %> 😔
</h1>
<%= live_patch to: Routes.invite_index_path(@socket, :new),
class: "btn btn-primary" do %>
Invite someone new!
<% end %>
<%= live_patch dgettext("actions", "Invite someone new!"),
to: Routes.invite_index_path(@socket, :new),
class: "btn btn-primary" %>
<% else %>
<%= live_patch to: Routes.invite_index_path(@socket, :new),
class: "btn btn-primary" do %>
Create Invite
<% end %>
<%= live_patch dgettext("actions", "Create Invite"),
to: Routes.invite_index_path(@socket, :new),
class: "btn btn-primary" %>
<% end %>
<div class="flex flex-row flex-wrap space-x-4 space-y-4">
@ -29,11 +27,12 @@
<%= if invite.disabled_at |> is_nil() do %>
<h2 class="title text-md">
Uses Left: <%= invite.uses_left || "Unlimited" %>
<%= gettext("Uses Left:") %>
<%= invite.uses_left || "Unlimited" %>
</h2>
<% else %>
<h2 class="title text-md">
Invite Disabled
<%= gettext("Invite Disabled") %>
</h2>
<% end %>
@ -51,27 +50,27 @@
class: "text-primary-500 link",
phx_click: "delete",
phx_value_id: invite.id,
data: [confirm: "Are you sure you want to delete the invite for #{invite.name}?"] do %>
data: [confirm: dgettext("prompts", "Are you sure you want to delete the invite for %{name}?", name: invite.name)] do %>
<i class="fa-fw fa-lg fas fa-trash"></i>
<% end %>
<%= if invite.disabled_at |> is_nil() do %>
<a href="#" class="btn btn-primary"
phx-click="disable" phx-value-id="<%= invite.id %>">
Disable
<%= gettext("Disable") %>
</a>
<% else %>
<a href="#" class="btn btn-primary"
phx-click="enable" phx-value-id="<%= invite.id %>">
Enable
<%= gettext("Enable") %>
</a>
<% end %>
<%= if invite.disabled_at |> is_nil() and not(invite.uses_left |> is_nil()) do %>
<a href="#" class="btn btn-primary"
phx-click="set_unlimited" phx-value-id="<%= invite.id %>"
data-confirm="Are you sure you want to make this invite unlimited?">
Set Unlimited
data-confirm={dgettext("prompts", "Are you sure you want to make this invite unlimited?")}>
<%= gettext("Set Unlimited") %>
</a>
<% end %>
</div>