Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds localization features #240

Merged
merged 11 commits into from
Nov 22, 2024
Merged

Adds localization features #240

merged 11 commits into from
Nov 22, 2024

Conversation

sdellis
Copy link
Member

@sdellis sdellis commented Nov 13, 2024

still working out how to pass the locale parameter to every liveview page

Ref: #123

Copy link

github-actions bot commented Nov 13, 2024

Container Scanning Status: ✅ Success


ghcr.io/pulibrary/dpul-collections:pr-240 (debian 12.6)
=======================================================
Total: 0 (HIGH: 0, CRITICAL: 0)

@sdellis sdellis changed the title WIP: adds localization features Adds localization features Nov 20, 2024
@sdellis sdellis marked this pull request as ready for review November 20, 2024 22:19
Copy link
Member

@hackartisan hackartisan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!!! I left a few comments.

Also I'd love to look together, I don't understand why we have set_locale_hook as well as locale_plug and how they interact. I'm hoping you can show me.

<lux-menu-bar
type="main-menu"
v-bind:menu-items={"[
{name: '#{gettext("Language")}', component: 'Language', children: [
{name: 'English', component: 'English', href: '?locale=en'},
{name: 'Español', component: 'Español', href: '?locale=es'},
{name: 'Português do Brasil', component: 'Português do Brasil', href: '?locale=pt-BR'}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we take out the Brazilian until we get the translations in place?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to leave it. It would be fairly easy to add the Brasilian translations if we wanted to make sure that option works.

alias DpulCollections.Solr
alias DpulCollectionsWeb.Live.Helpers

# on_mount SetLocaleHook
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old comment?

<p class="text-xl text-center">
We invite you to be inspired by our globally diverse collections of <%= @item_count %> Ephemera items. We can't wait to see how you use these materials to support your unique research.
<%= gettext("We invite you to be inspired by our globally diverse collections of") %> <%= @item_count %>
<%= gettext(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the break between tags render as a newline?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does. The text is very long. I usually have soft wrapping on in my editor, but I try to avoid lines that are that long. I am not tied to having a line break here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a max width style on it so I don't think it will ever get too long on the actual screen.


#: lib/dpul_collections_web/components/core_components.ex:85
#, elixir-autogen, elixir-format
msgid "We can't find the internet"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is my favorite

#: lib/dpul_collections_web/live/search_live.ex:186
#, elixir-autogen, elixir-format
msgid "Previous"
msgstr "anterior"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this one be capitalized?

@@ -6,7 +6,7 @@ defmodule DpulCollectionsWeb.HomeLiveTest do
test "GET /", %{conn: conn} do
count = DpulCollections.Solr.document_count()
conn = get(conn, ~p"/")
assert html_response(conn, 200) =~ "#{count} Ephemera items"
assert html_response(conn, 200) =~ "#{count}\n Ephemera items"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better if we could not have this newline. Relevant to my earlier comment

@@ -0,0 +1,58 @@
defmodule DpulCollectionsWeb.SetLocaleHookTest do
use ExUnit.Case, async: true
# import Phoenix.LiveView
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdellis one more

@@ -0,0 +1,13 @@
defmodule DpulCollectionsWeb.SetLocaleHook do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a module doc that says something like, "set up locale for front-end use"

defmodule DpulCollectionsWeb.LocalePlug do
@moduledoc """
Fetch locale and set it for the specified Gettext backend.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add something like, "sets it in the session so the front end can use it"

#: lib/dpul_collections_web/live/search_live.ex:69
#, elixir-autogen, elixir-format, fuzzy
msgid "Search Results"
msgstr "Search"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this one

#: lib/dpul_collections_web/live/search_live.ex:75
#, elixir-autogen, elixir-format
msgid "Search"
msgstr "Search"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

Copy link
Member

@hackartisan hackartisan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@hackartisan hackartisan merged commit f157ac1 into main Nov 22, 2024
4 checks passed
@hackartisan hackartisan deleted the i123-localization branch November 22, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants