From b409f6da6e5dc860f8b8861c6a8d163c361a6173 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 21 Oct 2024 12:02:26 +0100 Subject: [PATCH] Extract record list translations --- .../live/record_live/index.ex | 12 ++-- .../live/record_live/index.html.heex | 28 ++++---- priv/gettext/default.pot | 72 +++++++++++++++++++ 3 files changed, 94 insertions(+), 18 deletions(-) diff --git a/lib/music_library_web/live/record_live/index.ex b/lib/music_library_web/live/record_live/index.ex index 6cf0f8d1..98446bda 100644 --- a/lib/music_library_web/live/record_live/index.ex +++ b/lib/music_library_web/live/record_live/index.ex @@ -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 diff --git a/lib/music_library_web/live/record_live/index.html.heex b/lib/music_library_web/live/record_live/index.html.heex index 5ab984e6..c7d65a1a 100644 --- a/lib/music_library_web/live/record_live/index.html.heex +++ b/lib/music_library_web/live/record_live/index.html.heex @@ -1,6 +1,8 @@
-

All Records

+

+ <%= gettext("All Records") %> +

<.link patch={~p"/records/import"}> - <.button>Import + <.button><%= gettext("Import") %>

- Showing <%= Enum.count(@streams.records) %> - of <%= @record_list_params.total_entries %> - records + <%= gettext( + "Showing %{visible} of %{total} records", + %{visible: Enum.count(@streams.records), total: @record_list_params.total_entries} + ) + |> raw() %>

@@ -80,7 +84,7 @@ phx-click={toggle_actions_menu(record.id)} phx-click-away={close_actions_menu(record.id)} > - Open options + <%= gettext("Open options") %> - Show + <%= gettext("Show") %> - View on MusicBrainz + <%= gettext("View on MusicBrainz") %> <.link @@ -138,7 +142,7 @@ id={"actions-#{record.id}-edit"} patch={~p"/records/#{record}/edit"} > - Edit + <%= gettext("Edit") %> <.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") %> diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 6f209744..4bad9798 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -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 %{visible} of %{total} 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 ""