diff --git a/lib/cannery_web/live/container_live/container_card.ex b/lib/cannery_web/live/container_live/container_card.ex index 800b906..d8cacf0 100644 --- a/lib/cannery_web/live/container_live/container_card.ex +++ b/lib/cannery_web/live/container_live/container_card.ex @@ -23,17 +23,20 @@ defmodule CanneryWeb.ContainerLive.ContainerCard do <%= if @container.desc do %> - Description: <%= @container.desc %> + <%= gettext("Description:") %> + <%= @container.desc %> <% end %> - Type: <%= @container.type %> + <%= gettext("Type:") %> + <%= @container.type %> <%= if @container.location do %> - Location: <%= @container.location %> + <%= gettext("Location:") %> + <%= @container.location %> <% end %> diff --git a/lib/cannery_web/live/container_live/form_component.ex b/lib/cannery_web/live/container_live/form_component.ex index d7f4092..eedc56d 100644 --- a/lib/cannery_web/live/container_live/form_component.ex +++ b/lib/cannery_web/live/container_live/form_component.ex @@ -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 <% 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...") ) %> @@ -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} -> diff --git a/lib/cannery_web/live/container_live/index.ex b/lib/cannery_web/live/container_live/index.ex index bb1d6c1..ab6f95a 100644 --- a/lib/cannery_web/live/container_live/index.ex +++ b/lib/cannery_web/live/container_live/index.ex @@ -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()) diff --git a/lib/cannery_web/live/container_live/index.html.heex b/lib/cannery_web/live/container_live/index.html.heex index 8a531dc..a8f99e1 100644 --- a/lib/cannery_web/live/container_live/index.html.heex +++ b/lib/cannery_web/live/container_live/index.html.heex @@ -1,22 +1,22 @@
<%= 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} /> diff --git a/priv/gettext/actions.pot b/priv/gettext/actions.pot index fa6ec52..617e291 100644 --- a/priv/gettext/actions.pot +++ b/priv/gettext/actions.pot @@ -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 "" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index d467e6f..9deae3e 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -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 "" diff --git a/priv/gettext/errors.pot b/priv/gettext/errors.pot index 30b51d8..be18094 100644 --- a/priv/gettext/errors.pot +++ b/priv/gettext/errors.pot @@ -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 "" diff --git a/priv/gettext/prompts.pot b/priv/gettext/prompts.pot index f844d39..470a0b9 100644 --- a/priv/gettext/prompts.pot +++ b/priv/gettext/prompts.pot @@ -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 ""