gettext ammo types

This commit is contained in:
shibao 2022-02-09 00:39:27 -05:00
parent ac62afb313
commit c4217e8f45
8 changed files with 293 additions and 75 deletions

View File

@ -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} ->

View File

@ -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

View File

@ -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>

View File

@ -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

View File

@ -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} />

View File

@ -92,6 +92,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
msgid "Save"
msgstr ""
@ -99,3 +100,13 @@ msgstr ""
#: lib/cannery_web/live/ammo_group_live/index.html.heex:56
msgid "View"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/index.html.heex:11
msgid "Add your first type!"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/index.html.heex:16
msgid "New Ammo type"
msgstr ""

View File

@ -111,6 +111,7 @@ msgid "Settings"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:63
#: lib/cannery_web/live/ammo_group_live/index.html.heex:26
msgid "Count"
msgstr ""
@ -143,6 +144,7 @@ msgid "No Ammo"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:77
#: lib/cannery_web/live/ammo_group_live/index.html.heex:32
msgid "Notes"
msgstr ""
@ -154,6 +156,7 @@ msgid "Notes:"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:70
#: lib/cannery_web/live/ammo_group_live/index.html.heex:29
msgid "Price paid"
msgstr ""
@ -178,3 +181,187 @@ msgstr ""
#: lib/cannery_web/live/ammo_group_live/show.html.heex:50
msgid "This ammo group is not in a container"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:57
msgid "Ammo type"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/show.html.heex:86
msgid "Average Price paid"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:139
#: lib/cannery_web/live/ammo_type_live/index.html.heex:38
msgid "Blank"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:101
msgid "Brass"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:77
#: lib/cannery_web/live/ammo_type_live/index.html.heex:28
#: lib/cannery_web/live/ammo_type_live/show.html.heex:37
msgid "Bullet core"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:70
#: lib/cannery_web/live/ammo_type_live/index.html.heex:27
#: lib/cannery_web/live/ammo_type_live/show.html.heex:36
msgid "Bullet type"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:91
#: lib/cannery_web/live/ammo_type_live/index.html.heex:30
#: lib/cannery_web/live/ammo_type_live/show.html.heex:39
msgid "Caliber"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:84
#: lib/cannery_web/live/ammo_type_live/index.html.heex:29
#: lib/cannery_web/live/ammo_type_live/show.html.heex:38
msgid "Cartridge"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:98
#: lib/cannery_web/live/ammo_type_live/index.html.heex:31
#: lib/cannery_web/live/ammo_type_live/show.html.heex:40
msgid "Case material"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:84
msgid "Container"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:143
#: lib/cannery_web/live/ammo_type_live/index.html.heex:39
msgid "Corrosive"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:57
msgid "Description"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/index.ex:23
#: lib/cannery_web/live/ammo_type_live/show.ex:39
msgid "Edit Ammo type"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:68
msgid "Example bullet type abbreviations"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:73
msgid "FMJ"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:105
#: lib/cannery_web/live/ammo_type_live/index.html.heex:32
#: lib/cannery_web/live/ammo_type_live/show.html.heex:41
msgid "Grains"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:135
#: lib/cannery_web/live/ammo_type_live/index.html.heex:37
msgid "Incendiary"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/index.html.heex:3
msgid "Listing Ammo Types"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/index.ex:35
msgid "Listing Ammo types"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:147
#: lib/cannery_web/live/ammo_type_live/index.html.heex:40
msgid "Manufacturer"
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
msgid "Name"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/index.ex:29
msgid "New Ammo type"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/index.html.heex:8
msgid "No Ammo Types"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/show.html.heex:99
msgid "No ammo for this type"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:113
#: lib/cannery_web/live/ammo_type_live/index.html.heex:33
#: lib/cannery_web/live/ammo_type_live/show.html.heex:42
msgid "Pressure"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:120
#: lib/cannery_web/live/ammo_type_live/index.html.heex:34
#: lib/cannery_web/live/ammo_type_live/show.html.heex:43
msgid "Primer type"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:127
#: lib/cannery_web/live/ammo_type_live/index.html.heex:35
msgid "Rimfire"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:151
msgid "SKU"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/show.ex:38
msgid "Show Ammo type"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/index.html.heex:41
msgid "Sku"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:80
msgid "Steel"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:131
#: lib/cannery_web/live/ammo_type_live/index.html.heex:36
msgid "Tracer"
msgstr ""

View File

@ -89,10 +89,27 @@ 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
#: lib/cannery_web/live/ammo_type_live/index.html.heex:104
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
#: lib/cannery_web/live/ammo_type_live/form_component.ex:156
msgid "Saving..."
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:182
msgid "Ammo type created successfully"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:169
msgid "Ammo type updated successfully"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/show.html.heex:26
msgid "Are you sure you want to delete %{name}?"
msgstr ""