From 9e1f00c9a82f605865129bd410c0b70d7b08ebdb Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Wed, 29 Jan 2025 11:04:19 +0000 Subject: [PATCH] Refactor type/format labels to enable translations --- lib/music_library/records/record.ex | 22 -- .../components/record_components.ex | 22 +- .../live/artist_live/record_components.ex | 5 +- .../live/collection_live/show.ex | 4 +- .../live/collection_live/show.html.heex | 6 +- .../live/record_live/form_component.ex | 13 +- .../live/record_live/import_component.ex | 10 +- .../live/stats_live/index.ex | 2 +- .../live/stats_live/index.html.heex | 6 +- .../live/wishlist_live/show.ex | 4 +- .../live/wishlist_live/show.html.heex | 4 +- priv/gettext/default.pot | 198 ++++++++++++------ .../live/collection_live/index_test.exs | 13 +- .../live/collection_live/show_test.exs | 5 +- .../live/stats_live/index_test.exs | 6 +- .../live/wishlist_live/show_test.exs | 5 +- 16 files changed, 193 insertions(+), 132 deletions(-) diff --git a/lib/music_library/records/record.ex b/lib/music_library/records/record.ex index 3c7ead8d..5c96edc2 100644 --- a/lib/music_library/records/record.ex +++ b/lib/music_library/records/record.ex @@ -188,28 +188,6 @@ defmodule MusicLibrary.Records.Record do def formats, do: @formats def types, do: @types - def formats_with_labels do - Enum.map(@formats, fn f -> {format_long_label(f), f} end) - end - - def types_with_labels do - Enum.map(@types, fn t -> {type_long_label(t), t} end) - end - - def format_long_label(:cd), do: "CD" - def format_long_label(:backup), do: "Backup" - def format_long_label(:vinyl), do: "Vinyl" - def format_long_label(:blu_ray), do: "Blu-ray" - def format_long_label(:dvd), do: "DVD" - def format_long_label(:multi), do: "Multi" - - def type_long_label(:album), do: "Album" - def type_long_label(:ep), do: "EP" - def type_long_label(:live), do: "Live" - def type_long_label(:compilation), do: "Comp" - def type_long_label(:single), do: "Single" - def type_long_label(:other), do: "Other" - def format_release(nil), do: "N/A" def format_release(release) do diff --git a/lib/music_library_web/components/record_components.ex b/lib/music_library_web/components/record_components.ex index e5584d45..24ca4d44 100644 --- a/lib/music_library_web/components/record_components.ex +++ b/lib/music_library_web/components/record_components.ex @@ -49,9 +49,7 @@ defmodule MusicLibraryWeb.RecordComponents do

- {Records.Record.format_long_label(record.format)} · {Records.Record.type_long_label( - record.type - )} + {format_label(record.format)} · {type_label(record.type)} 0}> · @@ -78,9 +76,7 @@ defmodule MusicLibraryWeb.RecordComponents do

diff --git a/lib/music_library_web/live/record_live/form_component.ex b/lib/music_library_web/live/record_live/form_component.ex index f0e9285a..bd660f1a 100644 --- a/lib/music_library_web/live/record_live/form_component.ex +++ b/lib/music_library_web/live/record_live/form_component.ex @@ -1,6 +1,7 @@ defmodule MusicLibraryWeb.RecordLive.FormComponent do use MusicLibraryWeb, :live_component + import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1] alias MusicLibrary.Records alias MusicLibrary.Records.Cover @@ -37,14 +38,14 @@ defmodule MusicLibraryWeb.RecordLive.FormComponent do type="select" label={gettext("Type")} prompt={gettext("Choose a value")} - options={Records.Record.types_with_labels()} + options={types_with_labels()} /> <.input field={@form[:format]} type="select" label={gettext("Format")} prompt={gettext("Choose a value")} - options={Records.Record.formats_with_labels()} + options={formats_with_labels()} />
<.input field={@form[:musicbrainz_id]} type="text" label={gettext("MusicBrainz ID")} /> @@ -132,5 +133,13 @@ defmodule MusicLibraryWeb.RecordLive.FormComponent do end end + def formats_with_labels do + Enum.map(Records.Record.formats(), fn f -> {format_label(f), f} end) + end + + def types_with_labels do + Enum.map(Records.Record.types(), fn t -> {type_label(t), t} end) + end + defp notify_parent(msg), do: send(self(), {__MODULE__, msg}) end diff --git a/lib/music_library_web/live/record_live/import_component.ex b/lib/music_library_web/live/record_live/import_component.ex index 769877e2..0ac98877 100644 --- a/lib/music_library_web/live/record_live/import_component.ex +++ b/lib/music_library_web/live/record_live/import_component.ex @@ -1,7 +1,9 @@ defmodule MusicLibraryWeb.RecordLive.ImportComponent do use MusicLibraryWeb, :live_component - import MusicLibraryWeb.RecordComponents, only: [toggle_actions_menu: 1, close_actions_menu: 1] + import MusicLibraryWeb.RecordComponents, + only: [toggle_actions_menu: 1, close_actions_menu: 1, format_label: 1, type_label: 1] + alias MusicLibrary.Records @impl true @@ -68,9 +70,7 @@ defmodule MusicLibraryWeb.RecordLive.ImportComponent do {@release_group.title}

- {Records.Record.format_release(@release_group.release)} · {Records.Record.type_long_label( - @release_group.type - )} + {Records.Record.format_release(@release_group.release)} · {type_label(@release_group.type)}

@@ -115,7 +115,7 @@ defmodule MusicLibraryWeb.RecordLive.ImportComponent do JS.push("import", value: %{id: @release_group.id, format: format}, page_loading: true) } > - {Records.Record.format_long_label(format)} + {format_label(format)}
diff --git a/lib/music_library_web/live/stats_live/index.ex b/lib/music_library_web/live/stats_live/index.ex index a37f1a7c..49103e50 100644 --- a/lib/music_library_web/live/stats_live/index.ex +++ b/lib/music_library_web/live/stats_live/index.ex @@ -2,9 +2,9 @@ defmodule MusicLibraryWeb.StatsLive.Index do use MusicLibraryWeb, :live_view import MusicLibraryWeb.StatsLive.DataComponents + import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1] alias MusicLibrary.{Artists, Collection, Records, Wishlist} - alias Records.Record def mount(_params, _session, socket) do latest_record = Collection.get_latest_record!() diff --git a/lib/music_library_web/live/stats_live/index.html.heex b/lib/music_library_web/live/stats_live/index.html.heex index f94ae555..bbb608a2 100644 --- a/lib/music_library_web/live/stats_live/index.html.heex +++ b/lib/music_library_web/live/stats_live/index.html.heex @@ -29,7 +29,7 @@ ]}>
- {Record.format_long_label(format)} + {format_label(format)}
<.link @@ -54,7 +54,7 @@ ]}>
- {Record.type_long_label(type)} + {type_label(type)}
<.link @@ -202,7 +202,7 @@ ) } > - {Records.Record.format_long_label(format)} + {format_label(format)}
diff --git a/lib/music_library_web/live/wishlist_live/show.ex b/lib/music_library_web/live/wishlist_live/show.ex index 8b48c9b5..f83d1768 100644 --- a/lib/music_library_web/live/wishlist_live/show.ex +++ b/lib/music_library_web/live/wishlist_live/show.ex @@ -1,7 +1,9 @@ defmodule MusicLibraryWeb.WishlistLive.Show do use MusicLibraryWeb, :live_view - import MusicLibraryWeb.RecordComponents, only: [toggle_actions_menu: 1, close_actions_menu: 1] + import MusicLibraryWeb.RecordComponents, + only: [toggle_actions_menu: 1, close_actions_menu: 1, format_label: 1, type_label: 1] + alias MusicLibrary.Records @impl true diff --git a/lib/music_library_web/live/wishlist_live/show.html.heex b/lib/music_library_web/live/wishlist_live/show.html.heex index e0148163..7f6b7d86 100644 --- a/lib/music_library_web/live/wishlist_live/show.html.heex +++ b/lib/music_library_web/live/wishlist_live/show.html.heex @@ -26,9 +26,7 @@ ({gettext("Unreleased")}) - · {Records.Record.format_long_label(@record.format)} · {Records.Record.type_long_label( - @record.type - )} + · {format_label(@record.format)} · {type_label(@record.type)}

diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index f40c006e..b6eb261c 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -16,15 +16,15 @@ msgstr "" msgid "Actions" msgstr "" -#: lib/music_library_web/components/record_components.ex:185 +#: lib/music_library_web/components/record_components.ex:181 #: lib/music_library_web/live/collection_live/show.html.heex:127 -#: lib/music_library_web/live/wishlist_live/show.html.heex:148 +#: lib/music_library_web/live/wishlist_live/show.html.heex:146 #, elixir-autogen, elixir-format msgid "Are you sure?" msgstr "" -#: lib/music_library_web/live/record_live/form_component.ex:39 -#: lib/music_library_web/live/record_live/form_component.ex:46 +#: lib/music_library_web/live/record_live/form_component.ex:40 +#: lib/music_library_web/live/record_live/form_component.ex:47 #, elixir-autogen, elixir-format msgid "Choose a value" msgstr "" @@ -32,29 +32,29 @@ msgstr "" #: lib/music_library_web/components/layouts/app.html.heex:14 #: lib/music_library_web/live/artist_live/show.html.heex:67 #: lib/music_library_web/live/collection_live/index.ex:143 -#: lib/music_library_web/live/collection_live/show.ex:115 -#: lib/music_library_web/live/collection_live/show.ex:132 +#: lib/music_library_web/live/collection_live/show.ex:117 +#: lib/music_library_web/live/collection_live/show.ex:134 #, elixir-autogen, elixir-format msgid "Collection" msgstr "" -#: lib/music_library_web/live/record_live/form_component.ex:60 +#: lib/music_library_web/live/record_live/form_component.ex:61 #, elixir-autogen, elixir-format msgid "Cover art" msgstr "" -#: lib/music_library_web/components/record_components.ex:187 +#: lib/music_library_web/components/record_components.ex:183 #: lib/music_library_web/live/collection_live/show.html.heex:135 -#: lib/music_library_web/live/wishlist_live/show.html.heex:156 +#: lib/music_library_web/live/wishlist_live/show.html.heex:154 #, elixir-autogen, elixir-format msgid "Delete" msgstr "" -#: lib/music_library_web/components/record_components.ex:165 -#: lib/music_library_web/live/collection_live/show.ex:139 +#: lib/music_library_web/components/record_components.ex:161 +#: lib/music_library_web/live/collection_live/show.ex:141 #: lib/music_library_web/live/collection_live/show.html.heex:70 -#: lib/music_library_web/live/wishlist_live/show.ex:142 -#: lib/music_library_web/live/wishlist_live/show.html.heex:74 +#: lib/music_library_web/live/wishlist_live/show.ex:144 +#: lib/music_library_web/live/wishlist_live/show.html.heex:72 #, elixir-autogen, elixir-format msgid "Edit" msgstr "" @@ -74,7 +74,7 @@ msgstr "" msgid "Error!" msgstr "" -#: lib/music_library_web/live/record_live/form_component.ex:45 +#: lib/music_library_web/live/record_live/form_component.ex:46 #, elixir-autogen, elixir-format msgid "Format" msgstr "" @@ -85,7 +85,7 @@ msgid "Formats" msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex:165 -#: lib/music_library_web/live/wishlist_live/show.html.heex:187 +#: lib/music_library_web/live/wishlist_live/show.html.heex:185 #, elixir-autogen, elixir-format msgid "Genres" msgstr "" @@ -102,7 +102,7 @@ msgid "Import" msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex:224 -#: lib/music_library_web/live/wishlist_live/show.html.heex:238 +#: lib/music_library_web/live/wishlist_live/show.html.heex:236 #, elixir-autogen, elixir-format msgid "Inserted at" msgstr "" @@ -129,8 +129,8 @@ msgid "Logout" msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex:179 -#: lib/music_library_web/live/record_live/form_component.ex:50 -#: lib/music_library_web/live/wishlist_live/show.html.heex:201 +#: lib/music_library_web/live/record_live/form_component.ex:51 +#: lib/music_library_web/live/wishlist_live/show.html.heex:199 #, elixir-autogen, elixir-format msgid "MusicBrainz ID" msgstr "" @@ -141,19 +141,19 @@ msgstr "" msgid "Next" msgstr "" -#: lib/music_library_web/live/record_live/form_component.ex:67 +#: lib/music_library_web/live/record_live/form_component.ex:68 #, elixir-autogen, elixir-format msgid "No cover selected" msgstr "" -#: lib/music_library_web/live/record_live/import_component.ex:42 +#: lib/music_library_web/live/record_live/import_component.ex:44 #, elixir-autogen, elixir-format msgid "No results" msgstr "" -#: lib/music_library_web/components/record_components.ex:110 +#: lib/music_library_web/components/record_components.ex:106 #: lib/music_library_web/live/collection_live/show.html.heex:38 -#: lib/music_library_web/live/wishlist_live/show.html.heex:42 +#: lib/music_library_web/live/wishlist_live/show.html.heex:40 #, elixir-autogen, elixir-format msgid "Open options" msgstr "" @@ -169,20 +169,20 @@ msgstr "" msgid "Previous" msgstr "" -#: lib/music_library_web/components/record_components.ex:176 +#: lib/music_library_web/components/record_components.ex:172 #: lib/music_library_web/live/collection_live/index.html.heex:42 -#: lib/music_library_web/live/wishlist_live/show.html.heex:139 +#: lib/music_library_web/live/wishlist_live/show.html.heex:137 #, elixir-autogen, elixir-format msgid "Purchase" msgstr "" -#: lib/music_library_web/live/record_live/form_component.ex:56 +#: lib/music_library_web/live/record_live/form_component.ex:57 #, elixir-autogen, elixir-format msgid "Purchased at" msgstr "" -#: lib/music_library_web/components/record_components.ex:65 -#: lib/music_library_web/components/record_components.ex:94 +#: lib/music_library_web/components/record_components.ex:63 +#: lib/music_library_web/components/record_components.ex:90 #: lib/music_library_web/live/collection_live/show.html.heex:201 #, elixir-autogen, elixir-format msgid "Purchased on" @@ -195,46 +195,46 @@ msgstr "" msgid "Record imported successfully" msgstr "" -#: lib/music_library_web/live/record_live/form_component.ex:127 +#: lib/music_library_web/live/record_live/form_component.ex:128 #: lib/music_library_web/live/wishlist_live/index.ex:140 -#: lib/music_library_web/live/wishlist_live/show.ex:111 +#: lib/music_library_web/live/wishlist_live/show.ex:113 #, elixir-autogen, elixir-format msgid "Record updated successfully" msgstr "" -#: lib/music_library_web/live/record_live/form_component.ex:51 +#: lib/music_library_web/live/record_live/form_component.ex:52 #, elixir-autogen, elixir-format msgid "Release" msgstr "" -#: lib/music_library_web/live/record_live/form_component.ex:78 +#: lib/music_library_web/live/record_live/form_component.ex:79 #, elixir-autogen, elixir-format msgid "Save" msgstr "" -#: lib/music_library_web/live/record_live/form_component.ex:78 +#: lib/music_library_web/live/record_live/form_component.ex:79 #, elixir-autogen, elixir-format msgid "Saving..." msgstr "" -#: lib/music_library_web/components/record_components.ex:207 +#: lib/music_library_web/components/record_components.ex:203 #, elixir-autogen, elixir-format msgid "Search" msgstr "" -#: lib/music_library_web/live/record_live/import_component.ex:24 +#: lib/music_library_web/live/record_live/import_component.ex:26 #, elixir-autogen, elixir-format msgid "Search for a record on MusicBrainz" msgstr "" -#: lib/music_library_web/live/record_live/import_component.ex:25 +#: lib/music_library_web/live/record_live/import_component.ex:27 #, elixir-autogen, elixir-format msgid "Search for records" msgstr "" -#: lib/music_library_web/components/record_components.ex:145 -#: lib/music_library_web/live/collection_live/show.ex:138 -#: lib/music_library_web/live/wishlist_live/show.ex:141 +#: lib/music_library_web/components/record_components.ex:141 +#: lib/music_library_web/live/collection_live/show.ex:140 +#: lib/music_library_web/live/wishlist_live/show.ex:143 #, elixir-autogen, elixir-format msgid "Show" msgstr "" @@ -262,9 +262,9 @@ msgid "Success!" msgstr "" #: lib/music_library_web/live/collection_live/index.ex:21 -#: lib/music_library_web/live/collection_live/show.ex:12 +#: lib/music_library_web/live/collection_live/show.ex:14 #: lib/music_library_web/live/wishlist_live/index.ex:21 -#: lib/music_library_web/live/wishlist_live/show.ex:11 +#: lib/music_library_web/live/wishlist_live/show.ex:13 #, elixir-autogen, elixir-format msgid "The application has been updated, please reload." msgstr "" @@ -279,7 +279,7 @@ msgstr "" msgid "Total wishlist" msgstr "" -#: lib/music_library_web/live/record_live/form_component.ex:38 +#: lib/music_library_web/live/record_live/form_component.ex:39 #, elixir-autogen, elixir-format msgid "Type" msgstr "" @@ -290,12 +290,12 @@ msgid "Types" msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex:232 -#: lib/music_library_web/live/wishlist_live/show.html.heex:246 +#: lib/music_library_web/live/wishlist_live/show.html.heex:244 #, elixir-autogen, elixir-format msgid "Updated at" msgstr "" -#: lib/music_library_web/components/record_components.ex:155 +#: lib/music_library_web/components/record_components.ex:151 #, elixir-autogen, elixir-format msgid "View on MusicBrainz" msgstr "" @@ -308,7 +308,7 @@ msgstr "" #: lib/music_library_web/components/layouts/app.html.heex:20 #: lib/music_library_web/live/artist_live/show.html.heex:76 #: lib/music_library_web/live/wishlist_live/index.ex:159 -#: lib/music_library_web/live/wishlist_live/show.ex:135 +#: lib/music_library_web/live/wishlist_live/show.ex:137 #, elixir-autogen, elixir-format msgid "Wishlist" msgstr "" @@ -325,13 +325,13 @@ msgid "close" msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex:189 -#: lib/music_library_web/live/wishlist_live/show.html.heex:211 +#: lib/music_library_web/live/wishlist_live/show.html.heex:209 #, elixir-autogen, elixir-format msgid "Copy MusicBrainz ID to clipboard" msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex:243 -#: lib/music_library_web/live/wishlist_live/show.html.heex:257 +#: lib/music_library_web/live/wishlist_live/show.html.heex:255 #, elixir-autogen, elixir-format msgid "MusicBrainz data" msgstr "" @@ -357,26 +357,26 @@ msgstr "" msgid "Wishlisted" msgstr "" -#: lib/music_library_web/components/record_components.ex:58 -#: lib/music_library_web/components/record_components.ex:87 +#: lib/music_library_web/components/record_components.ex:56 +#: lib/music_library_web/components/record_components.ex:83 #, elixir-autogen, elixir-format msgid "Number of included records" msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex:212 -#: lib/music_library_web/live/wishlist_live/show.html.heex:226 +#: lib/music_library_web/live/wishlist_live/show.html.heex:224 #, elixir-autogen, elixir-format msgid "Includes" msgstr "" -#: lib/music_library_web/live/collection_live/show.ex:54 -#: lib/music_library_web/live/wishlist_live/show.ex:58 +#: lib/music_library_web/live/collection_live/show.ex:56 +#: lib/music_library_web/live/wishlist_live/show.ex:60 #, elixir-autogen, elixir-format msgid "Error refreshing MusicBrainz data" msgstr "" -#: lib/music_library_web/live/collection_live/show.ex:46 -#: lib/music_library_web/live/wishlist_live/show.ex:50 +#: lib/music_library_web/live/collection_live/show.ex:48 +#: lib/music_library_web/live/wishlist_live/show.ex:52 #, elixir-autogen, elixir-format msgid "MusicBrainz data refreshed successfully" msgstr "" @@ -386,18 +386,18 @@ msgstr "" msgid "Refresh LastFm Feed" msgstr "" -#: lib/music_library_web/live/collection_live/show.ex:86 -#: lib/music_library_web/live/wishlist_live/show.ex:70 +#: lib/music_library_web/live/collection_live/show.ex:88 +#: lib/music_library_web/live/wishlist_live/show.ex:72 #, elixir-autogen, elixir-format msgid "Cover refreshed successfully" msgstr "" -#: lib/music_library_web/live/wishlist_live/show.ex:78 +#: lib/music_library_web/live/wishlist_live/show.ex:80 #, elixir-autogen, elixir-format msgid "Error refreshing Cover" msgstr "" -#: lib/music_library_web/live/collection_live/show.ex:94 +#: lib/music_library_web/live/collection_live/show.ex:96 #, elixir-autogen, elixir-format msgid "Error refreshing cover" msgstr "" @@ -408,7 +408,7 @@ msgid "No MB ID" msgstr "" #: lib/music_library_web/live/artist_live/show.ex:42 -#: lib/music_library_web/live/collection_live/show.ex:113 +#: lib/music_library_web/live/collection_live/show.ex:115 #, elixir-autogen, elixir-format msgid "Details" msgstr "" @@ -433,7 +433,7 @@ msgstr "" msgid "Dev dashboard" msgstr "" -#: lib/music_library_web/live/artist_live/record_components.ex:42 +#: lib/music_library_web/live/artist_live/record_components.ex:43 #, elixir-autogen, elixir-format msgid "View details" msgstr "" @@ -453,32 +453,32 @@ msgstr "" msgid "Loading play count" msgstr "" -#: lib/music_library_web/live/collection_live/show.ex:74 -#: lib/music_library_web/live/wishlist_live/show.ex:98 +#: lib/music_library_web/live/collection_live/show.ex:76 +#: lib/music_library_web/live/wishlist_live/show.ex:100 #, elixir-autogen, elixir-format msgid "Error populating genres" msgstr "" -#: lib/music_library_web/live/collection_live/show.ex:66 -#: lib/music_library_web/live/wishlist_live/show.ex:90 +#: lib/music_library_web/live/collection_live/show.ex:68 +#: lib/music_library_web/live/wishlist_live/show.ex:92 #, elixir-autogen, elixir-format msgid "Genres populated successfully" msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex:118 -#: lib/music_library_web/live/wishlist_live/show.html.heex:122 +#: lib/music_library_web/live/wishlist_live/show.html.heex:120 #, elixir-autogen, elixir-format msgid "Populate genres" msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex:102 -#: lib/music_library_web/live/wishlist_live/show.html.heex:106 +#: lib/music_library_web/live/wishlist_live/show.html.heex:104 #, elixir-autogen, elixir-format msgid "Refresh MB data" msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex:86 -#: lib/music_library_web/live/wishlist_live/show.html.heex:90 +#: lib/music_library_web/live/wishlist_live/show.html.heex:88 #, elixir-autogen, elixir-format msgid "Refresh cover" msgstr "" @@ -513,7 +513,7 @@ msgstr "" msgid "On Tour" msgstr "" -#: lib/music_library_web/live/artist_live/record_components.ex:20 +#: lib/music_library_web/live/artist_live/record_components.ex:21 #, elixir-autogen, elixir-format msgid "1 record" msgid_plural "%{count} records" @@ -528,13 +528,13 @@ msgstr[0] "" msgstr[1] "" #: lib/music_library_web/live/collection_live/show.html.heex:153 -#: lib/music_library_web/live/wishlist_live/show.html.heex:175 +#: lib/music_library_web/live/wishlist_live/show.html.heex:173 #, elixir-autogen, elixir-format msgid "Copy record ID to clipboard" msgstr "" #: lib/music_library_web/live/collection_live/show.html.heex:145 -#: lib/music_library_web/live/wishlist_live/show.html.heex:167 +#: lib/music_library_web/live/wishlist_live/show.html.heex:165 #, elixir-autogen, elixir-format msgid "ID" msgstr "" @@ -544,3 +544,63 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Unreleased" msgstr "" + +#: lib/music_library_web/components/record_components.ex:219 +#, elixir-autogen, elixir-format +msgid "Album" +msgstr "" + +#: lib/music_library_web/components/record_components.ex:213 +#, elixir-autogen, elixir-format +msgid "Backup" +msgstr "" + +#: lib/music_library_web/components/record_components.ex:215 +#, elixir-autogen, elixir-format +msgid "Blu-ray" +msgstr "" + +#: lib/music_library_web/components/record_components.ex:212 +#, elixir-autogen, elixir-format +msgid "CD" +msgstr "" + +#: lib/music_library_web/components/record_components.ex:222 +#, elixir-autogen, elixir-format +msgid "Comp" +msgstr "" + +#: lib/music_library_web/components/record_components.ex:216 +#, elixir-autogen, elixir-format +msgid "DVD" +msgstr "" + +#: lib/music_library_web/components/record_components.ex:220 +#, elixir-autogen, elixir-format +msgid "EP" +msgstr "" + +#: lib/music_library_web/components/record_components.ex:221 +#, elixir-autogen, elixir-format +msgid "Live" +msgstr "" + +#: lib/music_library_web/components/record_components.ex:217 +#, elixir-autogen, elixir-format +msgid "Multi" +msgstr "" + +#: lib/music_library_web/components/record_components.ex:224 +#, elixir-autogen, elixir-format +msgid "Other" +msgstr "" + +#: lib/music_library_web/components/record_components.ex:223 +#, elixir-autogen, elixir-format +msgid "Single" +msgstr "" + +#: lib/music_library_web/components/record_components.ex:214 +#, elixir-autogen, elixir-format +msgid "Vinyl" +msgstr "" diff --git a/test/music_library_web/live/collection_live/index_test.exs b/test/music_library_web/live/collection_live/index_test.exs index 150f72e4..84468a72 100644 --- a/test/music_library_web/live/collection_live/index_test.exs +++ b/test/music_library_web/live/collection_live/index_test.exs @@ -3,6 +3,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do import MusicLibrary.RecordsFixtures import MusicLibrary.ReleaseGroupsFixtures + import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1] import Mox alias MusicLibrary.Records.{Cover, Record} alias MusicBrainz.APIBehaviourMock @@ -51,8 +52,8 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do |> assert_has("#records-#{record.id}") |> assert_has("#records-#{record.id} h2", text: escape(record.title)) |> assert_has("#records-#{record.id} p", text: record.release) - |> assert_has("#records-#{record.id} p", text: Record.format_long_label(record.format)) - |> assert_has("#records-#{record.id} p", text: Record.type_long_label(record.type)) + |> assert_has("#records-#{record.id} p", text: format_label(record.format)) + |> assert_has("#records-#{record.id} p", text: type_label(record.type)) |> assert_has("#records-#{record.id} span", text: Record.format_as_date(record.purchased_at) ) @@ -136,8 +137,8 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do |> assert_has("#records-#{record.id}") |> assert_has("#records-#{record.id} h2", text: escape(record.title)) |> assert_has("#records-#{record.id} p", text: record.release) - |> assert_has("#records-#{record.id} p", text: Record.format_long_label(record.format)) - |> assert_has("#records-#{record.id} p", text: Record.type_long_label(record.type)) + |> assert_has("#records-#{record.id} p", text: format_label(record.format)) + |> assert_has("#records-#{record.id} p", text: type_label(record.type)) |> assert_has("#records-#{record.id} span", text: Record.format_as_date(record.purchased_at) ) @@ -178,8 +179,8 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do |> assert_has("#records-#{record.id}") |> assert_has("#records-#{record.id} h2", text: escape(record.title)) |> assert_has("#records-#{record.id} p", text: record.release) - |> assert_has("#records-#{record.id} p", text: Record.format_long_label(record.format)) - |> assert_has("#records-#{record.id} p", text: Record.type_long_label(record.type)) + |> assert_has("#records-#{record.id} p", text: format_label(record.format)) + |> assert_has("#records-#{record.id} p", text: type_label(record.type)) |> assert_has("#records-#{record.id} span", text: Record.format_as_date(record.purchased_at) ) diff --git a/test/music_library_web/live/collection_live/show_test.exs b/test/music_library_web/live/collection_live/show_test.exs index e8739d38..6afa56f1 100644 --- a/test/music_library_web/live/collection_live/show_test.exs +++ b/test/music_library_web/live/collection_live/show_test.exs @@ -2,6 +2,7 @@ defmodule MusicLibraryWeb.CollectionLive.ShowTest do use MusicLibraryWeb.ConnCase import MusicLibrary.RecordsFixtures + import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1] alias MusicLibrary.Records.Record describe "Edit record from show page" do @@ -26,8 +27,8 @@ defmodule MusicLibraryWeb.CollectionLive.ShowTest do |> visit(~p"/collection/#{record.id}") |> assert_has("h2", text: escape(record.title)) |> assert_has("p", text: record.release) - |> assert_has("p", text: Record.format_long_label(record.format)) - |> assert_has("p", text: Record.type_long_label(record.type)) + |> assert_has("p", text: format_label(record.format)) + |> assert_has("p", text: type_label(record.type)) |> assert_has("dd", text: Record.format_as_date(record.purchased_at)) |> assert_has("dd", text: record.id) |> assert_has("a", text: record.musicbrainz_id) diff --git a/test/music_library_web/live/stats_live/index_test.exs b/test/music_library_web/live/stats_live/index_test.exs index b27260fe..5e8613d8 100644 --- a/test/music_library_web/live/stats_live/index_test.exs +++ b/test/music_library_web/live/stats_live/index_test.exs @@ -2,8 +2,8 @@ defmodule MusicLibraryWeb.StatsLive.IndexTest do use MusicLibraryWeb.ConnCase alias MusicLibrary.{Records, Repo, Wishlist} - alias MusicLibrary.Records.Record alias MusicBrainz.APIBehaviourMock + import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1] import MusicLibrary.RecordsFixtures import MusicLibrary.ReleaseGroupsFixtures import Mox @@ -36,14 +36,14 @@ defmodule MusicLibraryWeb.StatsLive.IndexTest do |> Enum.frequencies_by(& &1.format) |> Enum.each(fn {format, count} -> assert_has(session, "a", text: to_string(count)) - assert_has(session, "dt", text: Record.format_long_label(format)) + assert_has(session, "dt", text: format_label(format)) end) collection |> Enum.frequencies_by(& &1.type) |> Enum.each(fn {type, count} -> assert_has(session, "a", text: to_string(count)) - assert_has(session, "dt", text: Record.type_long_label(type)) + assert_has(session, "dt", text: type_label(type)) end) end diff --git a/test/music_library_web/live/wishlist_live/show_test.exs b/test/music_library_web/live/wishlist_live/show_test.exs index 492cdc96..282f477b 100644 --- a/test/music_library_web/live/wishlist_live/show_test.exs +++ b/test/music_library_web/live/wishlist_live/show_test.exs @@ -2,6 +2,7 @@ defmodule MusicLibraryWeb.WishlistLive.ShowTest do use MusicLibraryWeb.ConnCase import MusicLibrary.RecordsFixtures + import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1] alias MusicLibrary.Records.Record describe "Edit record from show page" do @@ -26,8 +27,8 @@ defmodule MusicLibraryWeb.WishlistLive.ShowTest do |> visit(~p"/wishlist/#{record.id}") |> assert_has("h2", text: escape(record.title)) |> assert_has("p", text: record.release) - |> assert_has("p", text: Record.format_long_label(record.format)) - |> assert_has("p", text: Record.type_long_label(record.type)) + |> assert_has("p", text: format_label(record.format)) + |> assert_has("p", text: type_label(record.type)) |> assert_has("dd", text: record.id) |> assert_has("a", text: record.musicbrainz_id) |> assert_has("dd", text: Record.format_as_date(record.inserted_at))