gettext containers
This commit is contained in:
parent
c4217e8f45
commit
91b9e8a730
@ -23,17 +23,20 @@ defmodule CanneryWeb.ContainerLive.ContainerCard do
|
||||
|
||||
<%= if @container.desc do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
Description: <%= @container.desc %>
|
||||
<%= gettext("Description:") %>
|
||||
<%= @container.desc %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<span class="rounded-lg title text-lg">
|
||||
Type: <%= @container.type %>
|
||||
<%= gettext("Type:") %>
|
||||
<%= @container.type %>
|
||||
</span>
|
||||
|
||||
<%= if @container.location do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
Location: <%= @container.location %>
|
||||
<%= gettext("Location:") %>
|
||||
<%= @container.location %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -16,7 +16,6 @@ defmodule CanneryWeb.ContainerLive.FormComponent do
|
||||
|
||||
@impl true
|
||||
def handle_event("validate", %{"container" => container_params}, socket) do
|
||||
container_params = container_params |> Map.put("user_id", socket.assigns.current_user.id)
|
||||
changeset = socket.assigns.container |> Containers.change_container(container_params)
|
||||
{:noreply, socket |> assign(:changeset, changeset)}
|
||||
end
|
||||
@ -47,39 +46,39 @@ defmodule CanneryWeb.ContainerLive.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",
|
||||
placeholder: "My cool ammo can"
|
||||
placeholder: gettext("My cool ammo can")
|
||||
) %>
|
||||
<%= error_tag(f, :name, "col-span-3 text-center") %>
|
||||
|
||||
<%= label(f, :desc, class: "title text-lg text-primary-500") %>
|
||||
<%= label(f, :desc, gettext("Description"), class: "title text-lg text-primary-500") %>
|
||||
<%= textarea(f, :desc,
|
||||
class: "input input-primary col-span-2",
|
||||
phx_hook: "MaintainAttrs",
|
||||
placeholder: "Metal ammo can with the anime girl sticker"
|
||||
placeholder: gettext("Metal ammo can with the anime girl sticker")
|
||||
) %>
|
||||
<%= error_tag(f, :desc, "col-span-3 text-center") %>
|
||||
|
||||
<%= label(f, :type, class: "title text-lg text-primary-500") %>
|
||||
<%= label(f, :type, gettext("Type"), class: "title text-lg text-primary-500") %>
|
||||
<%= text_input(f, :type,
|
||||
class: "input input-primary col-span-2",
|
||||
placeholder: "Magazine, Clip, Ammo Box, etc"
|
||||
placeholder: gettext("Magazine, Clip, Ammo Box, etc")
|
||||
) %>
|
||||
<%= error_tag(f, :type, "col-span-3 text-center") %>
|
||||
|
||||
<%= label(f, :location, class: "title text-lg text-primary-500") %>
|
||||
<%= label(f, :location, gettext("Location"), class: "title text-lg text-primary-500") %>
|
||||
<%= textarea(f, :location,
|
||||
class: "input input-primary col-span-2",
|
||||
phx_hook: "MaintainAttrs",
|
||||
placeholder: "On the bookshelf"
|
||||
placeholder: gettext("On the bookshelf")
|
||||
) %>
|
||||
<%= error_tag(f, :location, "col-span-3 text-center") %>
|
||||
|
||||
<%= 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>
|
||||
@ -96,7 +95,7 @@ defmodule CanneryWeb.ContainerLive.FormComponent do
|
||||
{:ok, _container} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, "Container updated successfully")
|
||||
|> put_flash(:info, dgettext("prompts", "Container updated successfully"))
|
||||
|> push_redirect(to: socket.assigns.return_to)}
|
||||
|
||||
{:error, %Changeset{} = changeset} ->
|
||||
@ -111,7 +110,7 @@ defmodule CanneryWeb.ContainerLive.FormComponent do
|
||||
{:ok, _container} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, "Container created successfully")
|
||||
|> put_flash(:info, dgettext("prompts", "Container created successfully"))
|
||||
|> push_redirect(to: socket.assigns.return_to)}
|
||||
|
||||
{:error, %Changeset{} = changeset} ->
|
||||
|
@ -19,19 +19,19 @@ defmodule CanneryWeb.ContainerLive.Index do
|
||||
|
||||
defp apply_action(socket, :edit, %{"id" => id}) do
|
||||
socket
|
||||
|> assign(:page_title, "Edit Container")
|
||||
|> assign(:page_title, gettext("Edit Container"))
|
||||
|> assign(:container, Containers.get_container!(id))
|
||||
end
|
||||
|
||||
defp apply_action(socket, :new, _params) do
|
||||
socket
|
||||
|> assign(:page_title, "New Container")
|
||||
|> assign(:page_title, gettext("New Container"))
|
||||
|> assign(:container, %Container{})
|
||||
end
|
||||
|
||||
defp apply_action(socket, :index, _params) do
|
||||
socket
|
||||
|> assign(:page_title, "Listing Containers")
|
||||
|> assign(:page_title, gettext("Listing Containers"))
|
||||
|> assign(:container, nil)
|
||||
end
|
||||
|
||||
@ -42,7 +42,7 @@ defmodule CanneryWeb.ContainerLive.Index do
|
||||
|> Enum.find(fn %{id: container_id} -> id == container_id end)
|
||||
|> case do
|
||||
nil ->
|
||||
socket |> put_flash(:error, "Could not find that container")
|
||||
socket |> put_flash(:error, dgettext("errors", "Could not find that container"))
|
||||
|
||||
container ->
|
||||
container
|
||||
@ -50,12 +50,22 @@ defmodule CanneryWeb.ContainerLive.Index do
|
||||
|> case do
|
||||
{:ok, container} ->
|
||||
socket
|
||||
|> put_flash(:info, "#{container.name} has been deleted")
|
||||
|> put_flash(
|
||||
:info,
|
||||
dgettext("prompts", "%{name} has been deleted", name: container.name)
|
||||
)
|
||||
|> display_containers()
|
||||
|
||||
{:error, %{action: :delete, errors: [ammo_groups: _error], valid?: false} = changeset} ->
|
||||
ammo_groups_error = changeset |> changeset_errors(:ammo_groups) |> Enum.join(", ")
|
||||
socket |> put_flash(:error, "Could not delete container: #{ammo_groups_error}")
|
||||
|
||||
socket
|
||||
|> put_flash(
|
||||
:error,
|
||||
dgettext("errors", "Could not delete container: %{error}",
|
||||
error: ammo_groups_error
|
||||
)
|
||||
)
|
||||
|
||||
{:error, changeset} ->
|
||||
socket |> put_flash(:error, changeset |> changeset_errors())
|
||||
|
@ -1,22 +1,22 @@
|
||||
<div class="flex flex-col space-y-8 justify-center items-center">
|
||||
<h1 class="title text-2xl title-primary-500">
|
||||
Listing Containers
|
||||
<%= gettext("Listing Containers") %>
|
||||
</h1>
|
||||
|
||||
<%= if @containers |> Enum.empty?() do %>
|
||||
<h2 class="title text-xl text-primary-500">
|
||||
No containers 😔
|
||||
<%= gettext("No containers") %> 😔
|
||||
</h2>
|
||||
|
||||
<%= live_patch("Add your first container!",
|
||||
<%= live_patch(dgettext("actions", "Add your first container!"),
|
||||
to: Routes.container_index_path(@socket, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<% else %>
|
||||
<%= live_patch to: Routes.container_index_path(@socket, :new),
|
||||
class: "btn btn-primary" do %>
|
||||
New Container
|
||||
<% end %>
|
||||
<%= live_patch(dgettext("actions", "New Container"),
|
||||
to: Routes.container_index_path(@socket, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<% end %>
|
||||
|
||||
<div class="flex flex-row flex-wrap">
|
||||
@ -31,7 +31,10 @@
|
||||
class: "text-primary-500 link",
|
||||
phx_click: "delete",
|
||||
phx_value_id: container.id,
|
||||
data: [confirm: "Are you sure you want to delete #{container.name}?"] do %>
|
||||
data: [
|
||||
confirm:
|
||||
dgettext("prompts", "Are you sure you want to delete %{name}?", name: container.name)
|
||||
] do %>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.container_card>
|
||||
|
@ -32,12 +32,20 @@ defmodule CanneryWeb.ContainerLive.Show do
|
||||
|> case do
|
||||
{:ok, container} ->
|
||||
socket
|
||||
|> put_flash(:info, "#{container.name} has been deleted")
|
||||
|> put_flash(
|
||||
:info,
|
||||
dgettext("prompts", "%{name} has been deleted", name: container.name)
|
||||
)
|
||||
|> push_redirect(to: Routes.container_index_path(socket, :index))
|
||||
|
||||
{:error, %{action: :delete, errors: [ammo_groups: _error], valid?: false} = changeset} ->
|
||||
ammo_groups_error = changeset |> changeset_errors(:ammo_groups) |> Enum.join(", ")
|
||||
socket |> put_flash(:error, "Could not delete container: #{ammo_groups_error}")
|
||||
|
||||
socket
|
||||
|> put_flash(
|
||||
:error,
|
||||
dgettext("errors", "Could not delete container: %{error}", error: ammo_groups_error)
|
||||
)
|
||||
|
||||
{:error, changeset} ->
|
||||
socket |> put_flash(:error, changeset |> changeset_errors())
|
||||
@ -46,6 +54,6 @@ defmodule CanneryWeb.ContainerLive.Show do
|
||||
{:noreply, socket}
|
||||
end
|
||||
|
||||
defp page_title(:show), do: "Show Container"
|
||||
defp page_title(:edit), do: "Edit Container"
|
||||
defp page_title(:show), do: gettext("Show Container")
|
||||
defp page_title(:edit), do: gettext("Edit Container")
|
||||
end
|
||||
|
@ -5,17 +5,20 @@
|
||||
|
||||
<%= if @container.desc do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
Description: <%= @container.desc %>
|
||||
<%= gettext("Description:") %>
|
||||
<%= @container.desc %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<span class="rounded-lg title text-lg">
|
||||
Type: <%= @container.type %>
|
||||
<%= gettext("Type:") %>
|
||||
<%= @container.type %>
|
||||
</span>
|
||||
|
||||
<%= if @container.location do %>
|
||||
<span class="rounded-lg title text-lg">
|
||||
Location: <%= @container.location %>
|
||||
<%= gettext("Location:") %>
|
||||
<%= @container.location %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
@ -28,7 +31,10 @@
|
||||
<%= link to: "#",
|
||||
class: "text-primary-500 link",
|
||||
phx_click: "delete",
|
||||
data: [confirm: "Are you sure you want to delete #{@container.name}?"] do %>
|
||||
data: [
|
||||
confirm:
|
||||
dgettext("prompts", "Are you sure you want to delete %{name}?", name: @container.name)
|
||||
] do %>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</div>
|
||||
@ -37,7 +43,7 @@
|
||||
|
||||
<p>
|
||||
<%= if @container.ammo_groups |> Enum.empty?() do %>
|
||||
No ammo groups in this container
|
||||
<%= gettext("No ammo groups in this container") %>
|
||||
<% else %>
|
||||
<%= for ammo_group <- @container.ammo_groups do %>
|
||||
<.ammo_group_card ammo_group={ammo_group} />
|
||||
|
@ -93,6 +93,7 @@ msgstr ""
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/ammo_group_live/form_component.ex:90
|
||||
#: lib/cannery_web/live/ammo_type_live/form_component.ex:155
|
||||
#: lib/cannery_web/live/container_live/form_component.ex:79
|
||||
msgid "Save"
|
||||
msgstr ""
|
||||
|
||||
@ -110,3 +111,13 @@ msgstr ""
|
||||
#: lib/cannery_web/live/ammo_type_live/index.html.heex:16
|
||||
msgid "New Ammo type"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:11
|
||||
msgid "Add your first container!"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:16
|
||||
msgid "New Container"
|
||||
msgstr ""
|
||||
|
@ -251,6 +251,7 @@ msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/ammo_type_live/form_component.ex:57
|
||||
#: lib/cannery_web/live/container_live/form_component.ex:56
|
||||
msgid "Description"
|
||||
msgstr ""
|
||||
|
||||
@ -302,6 +303,7 @@ msgstr ""
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/ammo_type_live/form_component.ex:53
|
||||
#: lib/cannery_web/live/ammo_type_live/index.html.heex:26
|
||||
#: lib/cannery_web/live/container_live/form_component.ex:49
|
||||
msgid "Name"
|
||||
msgstr ""
|
||||
|
||||
@ -365,3 +367,83 @@ msgstr ""
|
||||
#: lib/cannery_web/live/ammo_type_live/index.html.heex:36
|
||||
msgid "Tracer"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/container_card.ex:26
|
||||
#: lib/cannery_web/live/container_live/show.html.heex:8
|
||||
msgid "Description:"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/index.ex:22
|
||||
#: lib/cannery_web/live/container_live/show.ex:58
|
||||
msgid "Edit Container"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/index.ex:34
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:3
|
||||
msgid "Listing Containers"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/form_component.ex:71
|
||||
msgid "Location"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/container_card.ex:38
|
||||
#: lib/cannery_web/live/container_live/show.html.heex:20
|
||||
msgid "Location:"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/form_component.ex:67
|
||||
msgid "Magazine, Clip, Ammo Box, etc"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/form_component.ex:60
|
||||
msgid "Metal ammo can with the anime girl sticker"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/form_component.ex:52
|
||||
msgid "My cool ammo can"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/index.ex:28
|
||||
msgid "New Container"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/show.html.heex:46
|
||||
msgid "No ammo groups in this container"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:8
|
||||
msgid "No containers"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/form_component.ex:75
|
||||
msgid "On the bookshelf"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/show.ex:57
|
||||
msgid "Show Container"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/form_component.ex:64
|
||||
msgid "Type"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/container_card.ex:32
|
||||
#: lib/cannery_web/live/container_live/show.html.heex:14
|
||||
msgid "Type:"
|
||||
msgstr ""
|
||||
|
@ -199,3 +199,14 @@ msgstr ""
|
||||
#: lib/cannery_web/controllers/user_auth.ex:145
|
||||
msgid "You must log in to access this page."
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/index.ex:65
|
||||
#: lib/cannery_web/live/container_live/show.ex:47
|
||||
msgid "Could not delete container: %{error}"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/index.ex:45
|
||||
msgid "Could not find that container"
|
||||
msgstr ""
|
||||
|
@ -96,6 +96,7 @@ msgstr ""
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/ammo_group_live/form_component.ex:91
|
||||
#: lib/cannery_web/live/ammo_type_live/form_component.ex:156
|
||||
#: lib/cannery_web/live/container_live/form_component.ex:81
|
||||
msgid "Saving..."
|
||||
msgstr ""
|
||||
|
||||
@ -111,5 +112,23 @@ msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/ammo_type_live/show.html.heex:26
|
||||
#: lib/cannery_web/live/container_live/index.html.heex:36
|
||||
#: lib/cannery_web/live/container_live/show.html.heex:36
|
||||
msgid "Are you sure you want to delete %{name}?"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/index.ex:55
|
||||
#: lib/cannery_web/live/container_live/show.ex:37
|
||||
msgid "%{name} has been deleted"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/form_component.ex:113
|
||||
msgid "Container created successfully"
|
||||
msgstr ""
|
||||
|
||||
#, elixir-format, ex-autogen
|
||||
#: lib/cannery_web/live/container_live/form_component.ex:98
|
||||
msgid "Container updated successfully"
|
||||
msgstr ""
|
||||
|
Loading…
Reference in New Issue
Block a user