Extract record list translations

This commit is contained in:
Claudio Ortolina
2024-10-21 12:02:26 +01:00
parent e4dfdce635
commit b409f6da6e
3 changed files with 94 additions and 18 deletions
@@ -14,7 +14,7 @@ defmodule MusicLibraryWeb.RecordLive.Index do
def mount(_params, _session, socket) do
socket =
if static_changed?(socket) do
put_flash(socket, :warning, "The application has been updated, please reload.")
put_flash(socket, :warning, gettext("The application has been updated, please reload."))
else
socket
end
@@ -37,7 +37,7 @@ defmodule MusicLibraryWeb.RecordLive.Index do
end
socket
|> assign(:page_title, "Import from MusicBrainz")
|> assign(:page_title, gettext("Import from MusicBrainz"))
|> assign(:record, nil)
end
@@ -51,7 +51,7 @@ defmodule MusicLibraryWeb.RecordLive.Index do
end
socket
|> assign(:page_title, "Edit")
|> assign(:page_title, gettext("Edit"))
|> assign(:record, Records.get_record!(id))
end
@@ -68,7 +68,7 @@ defmodule MusicLibraryWeb.RecordLive.Index do
records = Records.search_records(query, limit: record_list_params.page_size, offset: offset)
socket
|> assign(:page_title, "Collection")
|> assign(:page_title, gettext("Collection"))
|> assign(:record, nil)
|> assign(:record_list_params, record_list_params)
|> stream(:records, records, reset: true)
@@ -102,7 +102,7 @@ defmodule MusicLibraryWeb.RecordLive.Index do
{:ok, record} ->
{:noreply,
socket
|> put_flash(:info, "Record imported successfully")
|> put_flash(:info, gettext("Record imported successfully"))
|> push_navigate(to: ~p"/records/#{record.id}")}
{:error, %Ecto.Changeset{} = changeset} ->
@@ -111,7 +111,7 @@ defmodule MusicLibraryWeb.RecordLive.Index do
{:error, reason} ->
{:noreply,
socket
|> put_flash(:error, "Error importing record, #{inspect(reason)}")
|> put_flash(:error, gettext("Error importing record") <> "," <> inspect(reason))
|> push_patch(to: ~p"/records")}
end
end
@@ -1,6 +1,8 @@
<div>
<header class="gap-6 mb-2">
<h1 class="text-lg font-semibold leading-8 text-zinc-800">All Records</h1>
<h1 class="text-lg font-semibold leading-8 text-zinc-800">
<%= gettext("All Records") %>
</h1>
<div class="flex items-center justify-between gap-6 mb-2 mt-2">
<form class="w-2/3" for={@record_list_params.query} phx-submit="search" phx-change="search">
<input
@@ -9,22 +11,24 @@
id={:query}
name={:query}
value={@record_list_params.query}
placeholder="Search"
placeholder={gettext("Search")}
phx-debounce="500"
autocorrect="off"
autocapitalize="none"
/>
</form>
<.link patch={~p"/records/import"}>
<.button>Import</.button>
<.button><%= gettext("Import") %></.button>
</.link>
</div>
</header>
<p class="text-right text-base max-sm:text-xs mt-8">
Showing <b><%= Enum.count(@streams.records) %></b>
of <b><%= @record_list_params.total_entries %></b>
records
<%= gettext(
"Showing <b>%{visible}</b> of <b>%{total}</b> records",
%{visible: Enum.count(@streams.records), total: @record_list_params.total_entries}
)
|> raw() %>
</p>
</div>
@@ -80,7 +84,7 @@
phx-click={toggle_actions_menu(record.id)}
phx-click-away={close_actions_menu(record.id)}
>
<span class="sr-only">Open options</span>
<span class="sr-only"><%= gettext("Open options") %></span>
<svg
class="h-5 w-5"
viewBox="0 0 20 20"
@@ -118,7 +122,7 @@
id={"actions-#{record.id}-show"}
navigate={~p"/records/#{record}"}
>
Show
<%= gettext("Show") %>
</.link>
<a
href={musicbrainz_url(record)}
@@ -128,7 +132,7 @@
tabindex="-1"
id={"actions-#{record.id}-musicbrainz"}
>
View on MusicBrainz
<%= gettext("View on MusicBrainz") %>
</a>
<.link
@@ -138,7 +142,7 @@
id={"actions-#{record.id}-edit"}
patch={~p"/records/#{record}/edit"}
>
Edit
<%= gettext("Edit") %>
</.link>
<.link
@@ -147,9 +151,9 @@
tabindex="-1"
id={"actions-#{record.id}-delete"}
phx-click={JS.push("delete", value: %{id: record.id}) |> hide("##{id}")}
data-confirm="Are you sure?"
data-confirm={gettext("Are you sure?")}
>
Delete
<%= gettext("Delete") %>
</.link>
</.focus_wrap>
</div>
+72
View File
@@ -78,6 +78,7 @@ msgid "You must be logged in to access this page"
msgstr ""
#: lib/music_library_web/components/layouts/app.html.heex:10
#: lib/music_library_web/live/record_live/index.ex:71
#, elixir-autogen, elixir-format
msgid "Collection"
msgstr ""
@@ -180,3 +181,74 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Search for records"
msgstr ""
#: lib/music_library_web/live/record_live/index.html.heex:4
#, elixir-autogen, elixir-format
msgid "All Records"
msgstr ""
#: lib/music_library_web/live/record_live/index.html.heex:154
#, elixir-autogen, elixir-format
msgid "Are you sure?"
msgstr ""
#: lib/music_library_web/live/record_live/index.html.heex:156
#, elixir-autogen, elixir-format
msgid "Delete"
msgstr ""
#: lib/music_library_web/live/record_live/index.ex:54
#: lib/music_library_web/live/record_live/index.html.heex:145
#, elixir-autogen, elixir-format
msgid "Edit"
msgstr ""
#: lib/music_library_web/live/record_live/index.ex:114
#, elixir-autogen, elixir-format
msgid "Error importing record"
msgstr ""
#: lib/music_library_web/live/record_live/index.html.heex:21
#, elixir-autogen, elixir-format
msgid "Import"
msgstr ""
#: lib/music_library_web/live/record_live/index.ex:40
#, elixir-autogen, elixir-format
msgid "Import from MusicBrainz"
msgstr ""
#: lib/music_library_web/live/record_live/index.html.heex:87
#, elixir-autogen, elixir-format
msgid "Open options"
msgstr ""
#: lib/music_library_web/live/record_live/index.ex:105
#, elixir-autogen, elixir-format
msgid "Record imported successfully"
msgstr ""
#: lib/music_library_web/live/record_live/index.html.heex:14
#, elixir-autogen, elixir-format
msgid "Search"
msgstr ""
#: lib/music_library_web/live/record_live/index.html.heex:125
#, elixir-autogen, elixir-format
msgid "Show"
msgstr ""
#: lib/music_library_web/live/record_live/index.html.heex:27
#, elixir-autogen, elixir-format
msgid "Showing <b>%{visible}</b> of <b>%{total}</b> records"
msgstr ""
#: lib/music_library_web/live/record_live/index.ex:17
#, elixir-autogen, elixir-format
msgid "The application has been updated, please reload."
msgstr ""
#: lib/music_library_web/live/record_live/index.html.heex:135
#, elixir-autogen, elixir-format
msgid "View on MusicBrainz"
msgstr ""