From ac62afb3134e8b81008399e0f7c653e1e724311e Mon Sep 17 00:00:00 2001 From: shibao Date: Wed, 9 Feb 2022 00:20:04 -0500 Subject: [PATCH] gettext ammo groups --- .../live/ammo_group_live/ammo_group_card.ex | 8 ++- .../live/ammo_group_live/form_component.ex | 18 ++--- lib/cannery_web/live/ammo_group_live/index.ex | 6 +- .../live/ammo_group_live/index.html.heex | 20 +++--- lib/cannery_web/live/ammo_group_live/show.ex | 4 +- .../live/ammo_group_live/show.html.heex | 14 ++-- priv/gettext/actions.pot | 25 +++++++ priv/gettext/default.pot | 69 +++++++++++++++++++ priv/gettext/prompts.pot | 21 ++++++ 9 files changed, 153 insertions(+), 32 deletions(-) diff --git a/lib/cannery_web/live/ammo_group_live/ammo_group_card.ex b/lib/cannery_web/live/ammo_group_live/ammo_group_card.ex index 6e1c4ab..d3aeaee 100644 --- a/lib/cannery_web/live/ammo_group_live/ammo_group_card.ex +++ b/lib/cannery_web/live/ammo_group_live/ammo_group_card.ex @@ -25,18 +25,20 @@ defmodule CanneryWeb.AmmoGroupLive.AmmoGroupCard do
- Count: <%= @ammo_group.count %> + <%= gettext("Count:") %> + <%= @ammo_group.count %> <%= if @ammo_group.notes do %> - Notes: <%= @ammo_group.notes %> + <%= gettext("Notes:") %> + <%= @ammo_group.notes %> <% end %> <%= if @ammo_group.price_paid do %> - Price paid: $ <%= @ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2) %> + <%= gettext("Price paid:") %> $ <%= @ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2) %> <% end %>
diff --git a/lib/cannery_web/live/ammo_group_live/form_component.ex b/lib/cannery_web/live/ammo_group_live/form_component.ex index f0a4d01..77ddbe5 100644 --- a/lib/cannery_web/live/ammo_group_live/form_component.ex +++ b/lib/cannery_web/live/ammo_group_live/form_component.ex @@ -54,41 +54,41 @@ defmodule CanneryWeb.AmmoGroupLive.FormComponent do <% end %> - <%= label(f, :ammo_type_id, class: "mr-4 title text-lg text-primary-500") %> + <%= label(f, :ammo_type_id, gettext("Ammo type"), class: "mr-4 title text-lg text-primary-500") %> <%= select(f, :ammo_type_id, ammo_type_options(@ammo_types), class: "text-center col-span-2 input input-primary" ) %> <%= error_tag(f, :ammo_type_id, "col-span-3 text-center") %> - <%= label(f, :count, class: "mr-4 title text-lg text-primary-500") %> + <%= label(f, :count, gettext("Count"), class: "mr-4 title text-lg text-primary-500") %> <%= number_input(f, :count, class: "text-center col-span-2 input input-primary", min: 1 ) %> <%= error_tag(f, :count, "col-span-3 text-center") %> - <%= label(f, :price_paid, class: "mr-4 title text-lg text-primary-500") %> + <%= label(f, :price_paid, gettext("Price paid"), class: "mr-4 title text-lg text-primary-500") %> <%= number_input(f, :price_paid, step: "0.01", class: "text-center col-span-2 input input-primary" ) %> <%= error_tag(f, :price_paid, "col-span-3 text-center") %> - <%= label(f, :notes, class: "mr-4 title text-lg text-primary-500") %> + <%= label(f, :notes, gettext("Notes"), class: "mr-4 title text-lg text-primary-500") %> <%= textarea(f, :notes, class: "text-center col-span-2 input input-primary", phx_hook: "MaintainAttrs" ) %> <%= error_tag(f, :notes, "col-span-3 text-center") %> - <%= label(f, :container, class: "mr-4 title text-lg text-primary-500") %> + <%= label(f, :container, gettext("Container"), class: "mr-4 title text-lg text-primary-500") %> <%= select(f, :container_id, container_options(@containers), class: "text-center col-span-2 input input-primary" ) %> <%= error_tag(f, :container_id, "col-span-3 text-center") %> - <%= submit("Save", - phx_disable_with: "Saving...", + <%= submit(dgettext("actions", "Save"), + phx_disable_with: dgettext("prompts", "Saving..."), class: "mx-auto col-span-3 btn btn-primary" ) %> @@ -116,7 +116,7 @@ defmodule CanneryWeb.AmmoGroupLive.FormComponent do {:ok, _ammo_group} -> {:noreply, socket - |> put_flash(:info, "Ammo group updated successfully") + |> put_flash(:info, dgettext("prompts", "Ammo group updated successfully")) |> push_redirect(to: socket.assigns.return_to)} {:error, %Changeset{} = changeset} -> @@ -129,7 +129,7 @@ defmodule CanneryWeb.AmmoGroupLive.FormComponent do {:ok, _ammo_group} -> {:noreply, socket - |> put_flash(:info, "Ammo group created successfully") + |> put_flash(:info, dgettext("prompts", "Ammo group created successfully")) |> push_redirect(to: socket.assigns.return_to)} {:error, %Changeset{} = changeset} -> diff --git a/lib/cannery_web/live/ammo_group_live/index.ex b/lib/cannery_web/live/ammo_group_live/index.ex index fed415d..3c49bac 100644 --- a/lib/cannery_web/live/ammo_group_live/index.ex +++ b/lib/cannery_web/live/ammo_group_live/index.ex @@ -20,19 +20,19 @@ defmodule CanneryWeb.AmmoGroupLive.Index do defp apply_action(socket, :edit, %{"id" => id}) do socket - |> assign(:page_title, "Edit Ammo group") + |> assign(:page_title, gettext("Edit Ammo group")) |> assign(:ammo_group, Ammo.get_ammo_group!(id)) end defp apply_action(socket, :new, _params) do socket - |> assign(:page_title, "Add Ammo") + |> assign(:page_title, dgettext("actions", "Add Ammo")) |> assign(:ammo_group, %AmmoGroup{}) end defp apply_action(socket, :index, _params) do socket - |> assign(:page_title, "Listing Ammo groups") + |> assign(:page_title, gettext("Listing Ammo groups")) |> assign(:ammo_group, nil) end diff --git a/lib/cannery_web/live/ammo_group_live/index.html.heex b/lib/cannery_web/live/ammo_group_live/index.html.heex index 6169113..5660f6a 100644 --- a/lib/cannery_web/live/ammo_group_live/index.html.heex +++ b/lib/cannery_web/live/ammo_group_live/index.html.heex @@ -1,19 +1,19 @@

- Listing Ammo + <%= gettext("Listing Ammo") %>

<%= if @ammo_groups |> Enum.empty?() do %>

- No Ammo 😔 + <%= gettext("No Ammo") %> 😔

- <%= live_patch("Add your first box!", + <%= live_patch(dgettext("actions", "Add your first box!"), to: Routes.ammo_group_index_path(@socket, :new), class: "btn btn-primary" ) %> <% else %> - <%= live_patch("New Ammo group", + <%= live_patch(dgettext("actions", "New Ammo group"), to: Routes.ammo_group_index_path(@socket, :new), class: "btn btn-primary" ) %> @@ -23,13 +23,13 @@ - Count + <%= gettext("Count") %> - Price paid + <%= gettext("Price paid") %> - Notes + <%= gettext("Notes") %> @@ -53,7 +53,9 @@ - <%= live_redirect("View", to: Routes.ammo_group_show_path(@socket, :show, ammo_group)) %> + <%= live_redirect(dgettext("actions", "View"), + to: Routes.ammo_group_show_path(@socket, :show, ammo_group) + ) %> <%= live_patch to: Routes.ammo_group_index_path(@socket, :edit, ammo_group), class: "text-primary-500 link" do %> @@ -64,7 +66,7 @@ class: "text-primary-500 link", phx_click: "delete", phx_value_id: ammo_group.id, - data: [confirm: "Are you sure you want to delete this ammo?"] do %> + data: [confirm: dgettext("prompts", "Are you sure you want to delete this ammo?")] do %> <% end %> diff --git a/lib/cannery_web/live/ammo_group_live/show.ex b/lib/cannery_web/live/ammo_group_live/show.ex index 49dbc2a..211f817 100644 --- a/lib/cannery_web/live/ammo_group_live/show.ex +++ b/lib/cannery_web/live/ammo_group_live/show.ex @@ -32,6 +32,6 @@ defmodule CanneryWeb.AmmoGroupLive.Show do {:noreply, socket |> push_redirect(to: Routes.ammo_group_index_path(socket, :index))} end - defp page_title(:show), do: "Show Ammo group" - defp page_title(:edit), do: "Edit Ammo group" + defp page_title(:show), do: gettext("Show Ammo group") + defp page_title(:edit), do: gettext("Edit Ammo group") end diff --git a/lib/cannery_web/live/ammo_group_live/show.html.heex b/lib/cannery_web/live/ammo_group_live/show.html.heex index ac94c56..5d5f665 100644 --- a/lib/cannery_web/live/ammo_group_live/show.html.heex +++ b/lib/cannery_web/live/ammo_group_live/show.html.heex @@ -5,18 +5,20 @@
- Count: <%= @ammo_group.count %> + <%= gettext("Count:") %> + <%= @ammo_group.count %> <%= if @ammo_group.notes do %> - Notes: <%= @ammo_group.notes %> + <%= gettext("Notes:") %> + <%= @ammo_group.notes %> <% end %> <%= if @ammo_group.price_paid do %> - Price paid: $ <%= @ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2) %> + <%= gettext("Price paid:") %> $ <%= @ammo_group.price_paid |> :erlang.float_to_binary(decimals: 2) %> <% end %>
@@ -30,7 +32,7 @@ <%= link to: "#", class: "text-primary-500 link", phx_click: "delete", - data: [confirm: "Are you sure you want to delete this ammo?"] do %> + data: [confirm: dgettext("prompts", "Are you sure you want to delete this ammo?")] do %> <% end %>
@@ -40,12 +42,12 @@
<%= if @ammo_group.container do %>

- Stored in + <%= gettext("Stored in") %>

<.container_card container={@ammo_group.container} /> <% else %> - This ammo group is not in a container + <%= gettext("This ammo group is not in a container") %> <% end %>
diff --git a/priv/gettext/actions.pot b/priv/gettext/actions.pot index fff3050..6174ed3 100644 --- a/priv/gettext/actions.pot +++ b/priv/gettext/actions.pot @@ -74,3 +74,28 @@ msgstr "" #: lib/cannery_web/templates/user_reset_password/new.html.heex:16 msgid "Send instructions to reset password" msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/index.ex:29 +msgid "Add Ammo" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/index.html.heex:11 +msgid "Add your first box!" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/index.html.heex:16 +msgid "New Ammo group" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/form_component.ex:90 +msgid "Save" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/index.html.heex:56 +msgid "View" +msgstr "" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 2574858..332ef1c 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -109,3 +109,72 @@ msgstr "" #: lib/cannery_web/templates/user_settings/edit.html.heex:3 msgid "Settings" msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/index.html.heex:26 +msgid "Count" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/ammo_group_card.ex:28 +#: lib/cannery_web/live/ammo_group_live/show.html.heex:8 +msgid "Count:" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/index.ex:23 +#: lib/cannery_web/live/ammo_group_live/show.ex:36 +msgid "Edit Ammo group" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/index.html.heex:3 +msgid "Listing Ammo" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/index.ex:35 +msgid "Listing Ammo groups" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/index.html.heex:8 +msgid "No Ammo" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/index.html.heex:32 +msgid "Notes" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/ammo_group_card.ex:34 +#: lib/cannery_web/live/ammo_group_live/show.html.heex:14 +msgid "Notes:" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/index.html.heex:29 +msgid "Price paid" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/ammo_group_card.ex:41 +#: lib/cannery_web/live/ammo_group_live/show.html.heex:21 +msgid "Price paid:" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/show.ex:35 +msgid "Show Ammo group" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/show.html.heex:45 +msgid "Stored in" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/show.html.heex:50 +msgid "This ammo group is not in a container" +msgstr "" diff --git a/priv/gettext/prompts.pot b/priv/gettext/prompts.pot index 3e0d3fd..808fe1c 100644 --- a/priv/gettext/prompts.pot +++ b/priv/gettext/prompts.pot @@ -75,3 +75,24 @@ msgstr "" #: lib/cannery_web/controllers/user_settings_controller.ex:78 msgid "Your account has been deleted" msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/form_component.ex:132 +msgid "Ammo group created successfully" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/form_component.ex:119 +msgid "Ammo group updated successfully" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/index.html.heex:69 +#: lib/cannery_web/live/ammo_group_live/show.html.heex:35 +msgid "Are you sure you want to delete this ammo?" +msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/ammo_group_live/form_component.ex:91 +msgid "Saving..." +msgstr ""