gettext ammo types
This commit is contained in:
		| @@ -50,11 +50,11 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do | ||||
|           </div> | ||||
|         <% end %> | ||||
|  | ||||
|         <%= label(f, :name, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :name, gettext("Name"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :name, class: "text-center col-span-2 input input-primary") %> | ||||
|         <%= error_tag(f, :name, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :desc, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :desc, gettext("Description"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= textarea(f, :desc, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           phx_hook: "MaintainAttrs" | ||||
| @@ -65,44 +65,44 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do | ||||
|           href="https://en.wikipedia.org/wiki/Bullet#Abbreviations" | ||||
|           class="col-span-3 text-center link title text-md text-primary-600" | ||||
|         > | ||||
|           Example bullet type abbreviations | ||||
|           <%= gettext("Example bullet type abbreviations") %> | ||||
|         </a> | ||||
|         <%= label(f, :bullet_type, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :bullet_type, gettext("Bullet type"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :bullet_type, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           placeholder: "FMJ" | ||||
|           placeholder: gettext("FMJ") | ||||
|         ) %> | ||||
|         <%= error_tag(f, :bullet_type, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :bullet_core, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :bullet_core, gettext("Bullet core"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :bullet_core, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           placeholder: "Steel" | ||||
|           placeholder: gettext("Steel") | ||||
|         ) %> | ||||
|         <%= error_tag(f, :bullet_core, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :cartridge, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :cartridge, gettext("Cartridge"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :cartridge, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           placeholder: "5.56x46mm NATO" | ||||
|         ) %> | ||||
|         <%= error_tag(f, :cartridge, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :caliber, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :caliber, gettext("Caliber"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :caliber, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           placeholder: ".223" | ||||
|         ) %> | ||||
|         <%= error_tag(f, :caliber, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :case_material, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :case_material, gettext("Case material"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :case_material, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           placeholder: "Brass" | ||||
|           placeholder: gettext("Brass") | ||||
|         ) %> | ||||
|         <%= error_tag(f, :case_material, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :grains, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :grains, gettext("Grains"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= number_input(f, :grains, | ||||
|           step: "1", | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
| @@ -110,50 +110,50 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do | ||||
|         ) %> | ||||
|         <%= error_tag(f, :grains, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :pressure, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :pressure, gettext("Pressure"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :pressure, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           placeholder: "+P" | ||||
|         ) %> | ||||
|         <%= error_tag(f, :pressure, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :primer_type, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :primer_type, gettext("Primer type"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :primer_type, | ||||
|           class: "text-center col-span-2 input input-primary", | ||||
|           placeholder: "Boxer" | ||||
|         ) %> | ||||
|         <%= error_tag(f, :primer_type, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :rimfire, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :rimfire, gettext("Rimfire"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= checkbox(f, :rimfire, class: "text-center col-span-2 checkbox") %> | ||||
|         <%= error_tag(f, :rimfire, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :tracer, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :tracer, gettext("Tracer"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= checkbox(f, :tracer, class: "text-center col-span-2 checkbox") %> | ||||
|         <%= error_tag(f, :tracer, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :incendiary, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :incendiary, gettext("Incendiary"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= checkbox(f, :incendiary, class: "text-center col-span-2 checkbox") %> | ||||
|         <%= error_tag(f, :incendiary, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :blank, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :blank, gettext("Blank"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= checkbox(f, :blank, class: "text-center col-span-2 checkbox") %> | ||||
|         <%= error_tag(f, :blank, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :corrosive, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :corrosive, gettext("Corrosive"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= checkbox(f, :corrosive, class: "text-center col-span-2 checkbox") %> | ||||
|         <%= error_tag(f, :corrosive, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :manufacturer, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :manufacturer, gettext("Manufacturer"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :manufacturer, class: "text-center col-span-2 input input-primary") %> | ||||
|         <%= error_tag(f, :manufacturer, "col-span-3 text-center") %> | ||||
|  | ||||
|         <%= label(f, :sku, class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= label(f, :sku, gettext("SKU"), class: "mr-4 title text-lg text-primary-500") %> | ||||
|         <%= text_input(f, :sku, class: "text-center col-span-2 input input-primary") %> | ||||
|         <%= error_tag(f, :sku, "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" | ||||
|         ) %> | ||||
|       </.form> | ||||
| @@ -166,7 +166,7 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do | ||||
|       {:ok, _ammo_type} -> | ||||
|         {:noreply, | ||||
|          socket | ||||
|          |> put_flash(:info, "Ammo type updated successfully") | ||||
|          |> put_flash(:info, dgettext("prompts", "Ammo type updated successfully")) | ||||
|          |> push_redirect(to: socket.assigns.return_to)} | ||||
|  | ||||
|       {:error, %Changeset{} = changeset} -> | ||||
| @@ -179,7 +179,7 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do | ||||
|       {:ok, _ammo_type} -> | ||||
|         {:noreply, | ||||
|          socket | ||||
|          |> put_flash(:info, "Ammo type created successfully") | ||||
|          |> put_flash(:info, dgettext("prompts", "Ammo type created successfully")) | ||||
|          |> push_redirect(to: socket.assigns.return_to)} | ||||
|  | ||||
|       {:error, %Changeset{} = changeset} -> | ||||
|   | ||||
| @@ -20,19 +20,19 @@ defmodule CanneryWeb.AmmoTypeLive.Index do | ||||
|  | ||||
|   defp apply_action(socket, :edit, %{"id" => id}) do | ||||
|     socket | ||||
|     |> assign(:page_title, "Edit Ammo type") | ||||
|     |> assign(:page_title, gettext("Edit Ammo type")) | ||||
|     |> assign(:ammo_type, Ammo.get_ammo_type!(id)) | ||||
|   end | ||||
|  | ||||
|   defp apply_action(socket, :new, _params) do | ||||
|     socket | ||||
|     |> assign(:page_title, "New Ammo type") | ||||
|     |> assign(:page_title, gettext("New Ammo type")) | ||||
|     |> assign(:ammo_type, %AmmoType{}) | ||||
|   end | ||||
|  | ||||
|   defp apply_action(socket, :index, _params) do | ||||
|     socket | ||||
|     |> assign(:page_title, "Listing Ammo types") | ||||
|     |> assign(:page_title, gettext("Listing Ammo types")) | ||||
|     |> assign(:ammo_type, nil) | ||||
|   end | ||||
|  | ||||
|   | ||||
| @@ -1,19 +1,19 @@ | ||||
| <div class="mx-8 flex flex-col space-y-8 justify-center items-center"> | ||||
|   <h1 class="title text-2xl title-primary-500"> | ||||
|     Listing Ammo Types | ||||
|     <%= gettext("Listing Ammo Types") %> | ||||
|   </h1> | ||||
|  | ||||
|   <%= if @ammo_types |> Enum.empty?() do %> | ||||
|     <h2 class="title text-xl text-primary-500"> | ||||
|       No Ammo Types 😔 | ||||
|       <%= gettext("No Ammo Types") %> 😔 | ||||
|     </h2> | ||||
|  | ||||
|     <%= live_patch("Add your first type!", | ||||
|     <%= live_patch(dgettext("actions", "Add your first type!"), | ||||
|       to: Routes.ammo_type_index_path(@socket, :new), | ||||
|       class: "btn btn-primary" | ||||
|     ) %> | ||||
|   <% else %> | ||||
|     <%= live_patch("New Ammo type", | ||||
|     <%= live_patch(dgettext("actions", "New Ammo type"), | ||||
|       to: Routes.ammo_type_index_path(@socket, :new), | ||||
|       class: "btn btn-primary" | ||||
|     ) %> | ||||
| @@ -22,26 +22,26 @@ | ||||
|       <table class="min-w-full table-auto text-center bg-white"> | ||||
|         <thead class="border-b border-primary-600"> | ||||
|           <tr> | ||||
|             <%= for field <- [ | ||||
|                   :name, | ||||
|                   :bullet_type, | ||||
|                   :bullet_core, | ||||
|                   :cartridge, | ||||
|                   :caliber, | ||||
|                   :case_material, | ||||
|                   :grains, | ||||
|                   :pressure, | ||||
|                   :primer_type, | ||||
|                   :rimfire, | ||||
|                   :tracer, | ||||
|                   :incendiary, | ||||
|                   :blank, | ||||
|                   :corrosive, | ||||
|                   :manufacturer, | ||||
|                   :sku | ||||
|             <%= for field_name <- [ | ||||
|                   gettext("Name"), | ||||
|                   gettext("Bullet type"), | ||||
|                   gettext("Bullet core"), | ||||
|                   gettext("Cartridge"), | ||||
|                   gettext("Caliber"), | ||||
|                   gettext("Case material"), | ||||
|                   gettext("Grains"), | ||||
|                   gettext("Pressure"), | ||||
|                   gettext("Primer type"), | ||||
|                   gettext("Rimfire"), | ||||
|                   gettext("Tracer"), | ||||
|                   gettext("Incendiary"), | ||||
|                   gettext("Blank"), | ||||
|                   gettext("Corrosive"), | ||||
|                   gettext("Manufacturer"), | ||||
|                   gettext("Sku") | ||||
|                 ] do %> | ||||
|               <th class="p-2"> | ||||
|                 <%= field |> humanize() %> | ||||
|                 <%= field_name %> | ||||
|               </th> | ||||
|             <% end %> | ||||
|  | ||||
| @@ -101,7 +101,7 @@ | ||||
|                        class: "text-primary-500 link", | ||||
|                        phx_click: "delete", | ||||
|                        phx_value_id: ammo_type.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 %> | ||||
|                     <i class="fa-lg fas fa-trash"></i> | ||||
|                   <% end %> | ||||
|                 </div> | ||||
|   | ||||
| @@ -35,6 +35,6 @@ defmodule CanneryWeb.AmmoTypeLive.Show do | ||||
|     {:noreply, socket |> push_redirect(to: Routes.ammo_type_index_path(socket, :index))} | ||||
|   end | ||||
|  | ||||
|   defp page_title(:show), do: "Show Ammo type" | ||||
|   defp page_title(:edit), do: "Edit Ammo type" | ||||
|   defp page_title(:show), do: gettext("Show Ammo type") | ||||
|   defp page_title(:edit), do: gettext("Edit Ammo type") | ||||
| end | ||||
|   | ||||
| @@ -21,7 +21,10 @@ | ||||
|     <%= link to: "#", | ||||
|          class: "text-primary-500 link", | ||||
|          phx_click: "delete", | ||||
|          data: [confirm: "Are you sure you want to delete #{@ammo_type.name}?"] do %> | ||||
|          data: [ | ||||
|            confirm: | ||||
|              dgettext("prompts", "Are you sure you want to delete %{name}?", name: @ammo_type.name) | ||||
|          ] do %> | ||||
|       <i class="fa-fw fa-lg fas fa-trash"></i> | ||||
|     <% end %> | ||||
|   </div> | ||||
| @@ -29,19 +32,19 @@ | ||||
|   <hr class="hr"> | ||||
|  | ||||
|   <div class="grid sm:grid-cols-2 text-center justify-center items-center"> | ||||
|     <%= for field <- [ | ||||
|           :bullet_type, | ||||
|           :bullet_core, | ||||
|           :cartridge, | ||||
|           :caliber, | ||||
|           :case_material, | ||||
|           :grains, | ||||
|           :pressure, | ||||
|           :primer_type | ||||
|     <%= for {field_name, field} <- [ | ||||
|           {gettext("Bullet type"), :bullet_type}, | ||||
|           {gettext("Bullet core"), :bullet_core}, | ||||
|           {gettext("Cartridge"), :cartridge}, | ||||
|           {gettext("Caliber"), :caliber}, | ||||
|           {gettext("Case material"), :case_material}, | ||||
|           {gettext("Grains"), :grains}, | ||||
|           {gettext("Pressure"), :pressure}, | ||||
|           {gettext("Primer type"), :primer_type} | ||||
|         ] do %> | ||||
|       <%= if @ammo_type |> Map.get(field) do %> | ||||
|         <h3 class="mb-2 sm:mr-4 title text-lg"> | ||||
|           <%= field |> humanize() %> : | ||||
|           <%= field_name %> : | ||||
|         </h3> | ||||
|  | ||||
|         <span class="mb-4 sm:mb-2 text-primary-600"> | ||||
| @@ -50,15 +53,15 @@ | ||||
|       <% end %> | ||||
|     <% end %> | ||||
|  | ||||
|     <%= for field <- [ | ||||
|           :rimfire, | ||||
|           :tracer, | ||||
|           :incendiary, | ||||
|           :blank, | ||||
|           :corrosive | ||||
|     <%= for {field_name, field} <- [ | ||||
|           {"Rimfire", :rimfire}, | ||||
|           {"Tracer", :tracer}, | ||||
|           {"Incendiary", :incendiary}, | ||||
|           {"Blank", :blank}, | ||||
|           {"Corrosive", :corrosive} | ||||
|         ] do %> | ||||
|       <h3 class="mb-2 sm:mr-4 title text-lg"> | ||||
|         <%= field |> humanize() %> : | ||||
|         <%= field_name %> : | ||||
|       </h3> | ||||
|  | ||||
|       <span class="mb-4 sm:mb-2 text-primary-600"> | ||||
| @@ -66,10 +69,10 @@ | ||||
|       </span> | ||||
|     <% end %> | ||||
|  | ||||
|     <%= for field <- [:manufacturer, :sku] do %> | ||||
|     <%= for {field_name, field} <- [{"Manufacturer", :manufacturer}, {"Sku", :sku}] do %> | ||||
|       <%= if @ammo_type |> Map.get(field) do %> | ||||
|         <h3 class="mb-2 sm:mr-4 title text-lg"> | ||||
|           <%= field |> humanize() %> : | ||||
|           <%= field_name %> : | ||||
|         </h3> | ||||
|  | ||||
|         <span class="mb-4 sm:mb-2 text-primary-600"> | ||||
| @@ -80,7 +83,7 @@ | ||||
|  | ||||
|     <%= if @avg_cost_per_round do %> | ||||
|       <h3 class="mb-2 sm:mr-4 title text-lg"> | ||||
|         Average Price paid: | ||||
|         <%= gettext("Average Price paid") %> : | ||||
|       </h3> | ||||
|  | ||||
|       <span class="mb-4 sm:mb-2 text-primary-600"> | ||||
| @@ -93,7 +96,7 @@ | ||||
|  | ||||
|   <div> | ||||
|     <%= if @ammo_groups |> Enum.empty?() do %> | ||||
|       No ammo for this type | ||||
|       <%= gettext("No ammo for this type") %> | ||||
|     <% else %> | ||||
|       <%= for ammo_group <- @ammo_groups do %> | ||||
|         <.ammo_group_card ammo_group={ammo_group} /> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user