Skip to content

Commit

Permalink
Merge pull request #298 from pulibrary/271-translations
Browse files Browse the repository at this point in the history
Update sort options and add translations
  • Loading branch information
sdellis authored Jan 15, 2025
2 parents ed26f12 + 20a499b commit 6815f73
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 12 deletions.
10 changes: 7 additions & 3 deletions lib/dpul_collections_web/live/search_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ defmodule DpulCollectionsWeb.SearchLive do
{:noreply, socket}
end

defp item_counter(_, 0), do: "No items found"
defp item_counter(_, 0), do: gettext("No items found")

defp item_counter(%{page: page, per_page: per_page}, total_items) do
first_item = max(page - 1, 0) * per_page + 1
Expand All @@ -80,7 +80,7 @@ defmodule DpulCollectionsWeb.SearchLive do
true -> first_item + per_page - 1
end

"#{first_item} - #{last_item} of #{total_items}"
"#{first_item} - #{last_item} #{gettext("of")} #{total_items}"
end

def render(assigns) do
Expand Down Expand Up @@ -130,7 +130,11 @@ defmodule DpulCollectionsWeb.SearchLive do
</label>
<select class="col-span-1" name="sort-by">
<%= Phoenix.HTML.Form.options_for_select(
["relevance", "date desc": "date_desc", "date asc": "date_asc"],
[
{gettext("Relevance"), "relevance"},
{gettext("Year (newest first)"), "date_desc"},
{gettext("Year (oldest first)"), "date_asc"}
],
@search_state.sort_by
) %>
</select>
Expand Down
31 changes: 28 additions & 3 deletions priv/gettext/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ msgstr ""
msgid "Language"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:248
#: lib/dpul_collections_web/live/search_live.ex:252
#, elixir-autogen, elixir-format
msgid "Next"
msgstr ""

#: lib/dpul_collections_web/live/item_live.ex:61
#: lib/dpul_collections_web/live/search_live.ex:170
#: lib/dpul_collections_web/live/search_live.ex:174
#, elixir-autogen, elixir-format
msgid "Pages"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:205
#: lib/dpul_collections_web/live/search_live.ex:209
#, elixir-autogen, elixir-format
msgid "Previous"
msgstr ""
Expand Down Expand Up @@ -147,3 +147,28 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Page not found"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:71
#, elixir-autogen, elixir-format
msgid "No items found"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:83
#, elixir-autogen, elixir-format
msgid "of"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:134
#, elixir-autogen, elixir-format
msgid "Relevance"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:135
#, elixir-autogen, elixir-format
msgid "Year (newest first)"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:136
#, elixir-autogen, elixir-format
msgid "Year (oldest first)"
msgstr ""
31 changes: 28 additions & 3 deletions priv/gettext/en/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ msgstr ""
msgid "Language"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:248
#: lib/dpul_collections_web/live/search_live.ex:252
#, elixir-autogen, elixir-format
msgid "Next"
msgstr ""

#: lib/dpul_collections_web/live/item_live.ex:61
#: lib/dpul_collections_web/live/search_live.ex:170
#: lib/dpul_collections_web/live/search_live.ex:174
#, elixir-autogen, elixir-format
msgid "Pages"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:205
#: lib/dpul_collections_web/live/search_live.ex:209
#, elixir-autogen, elixir-format
msgid "Previous"
msgstr ""
Expand Down Expand Up @@ -147,3 +147,28 @@ msgstr ""
#, elixir-autogen, elixir-format, fuzzy
msgid "Page not found"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:71
#, elixir-autogen, elixir-format
msgid "No items found"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:83
#, elixir-autogen, elixir-format
msgid "of"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:134
#, elixir-autogen, elixir-format, fuzzy
msgid "Relevance"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:135
#, elixir-autogen, elixir-format
msgid "Year (newest first)"
msgstr ""

#: lib/dpul_collections_web/live/search_live.ex:136
#, elixir-autogen, elixir-format
msgid "Year (oldest first)"
msgstr ""
31 changes: 28 additions & 3 deletions priv/gettext/es/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ msgstr "Aplicar"
msgid "Language"
msgstr "Idioma"

#: lib/dpul_collections_web/live/search_live.ex:248
#: lib/dpul_collections_web/live/search_live.ex:252
#, elixir-autogen, elixir-format
msgid "Next"
msgstr "Proxima"

#: lib/dpul_collections_web/live/item_live.ex:61
#: lib/dpul_collections_web/live/search_live.ex:170
#: lib/dpul_collections_web/live/search_live.ex:174
#, elixir-autogen, elixir-format
msgid "Pages"
msgstr "Páginas"

#: lib/dpul_collections_web/live/search_live.ex:205
#: lib/dpul_collections_web/live/search_live.ex:209
#, elixir-autogen, elixir-format
msgid "Previous"
msgstr "Anterior"
Expand Down Expand Up @@ -147,3 +147,28 @@ msgstr "Descargar PDF"
#, elixir-autogen, elixir-format, fuzzy
msgid "Page not found"
msgstr "Página no encontrada"

#: lib/dpul_collections_web/live/search_live.ex:71
#, elixir-autogen, elixir-format
msgid "No items found"
msgstr "No artículos encontrada"

#: lib/dpul_collections_web/live/search_live.ex:83
#, elixir-autogen, elixir-format
msgid "of"
msgstr "de"

#: lib/dpul_collections_web/live/search_live.ex:134
#, elixir-autogen, elixir-format, fuzzy
msgid "Relevance"
msgstr "Relevancia"

#: lib/dpul_collections_web/live/search_live.ex:135
#, elixir-autogen, elixir-format
msgid "Year (newest first)"
msgstr "Año (más reciente primero)"

#: lib/dpul_collections_web/live/search_live.ex:136
#, elixir-autogen, elixir-format
msgid "Year (oldest first)"
msgstr "Año (más antigua primero)"

0 comments on commit 6815f73

Please sign in to comment.