From e3b94477db04f7d19ba6d2aa47f67554302929c1 Mon Sep 17 00:00:00 2001 From: shibao Date: Tue, 8 Feb 2022 23:38:20 -0500 Subject: [PATCH] gettext topbar --- CONTRIBUTING.md | 5 ++-- lib/cannery_web/component/topbar.ex | 26 ++++++----------- .../templates/layout/app.html.heex | 2 ++ .../templates/layout/root.html.heex | 1 + .../{topbar.html.eex => topbar.html.heex} | 28 ++++++++++++------- priv/gettext/actions.pot | 23 +++++++++++++++ priv/gettext/default.pot | 25 +++++++++++++++++ priv/gettext/prompts.pot | 6 ++++ 8 files changed, 86 insertions(+), 30 deletions(-) rename lib/cannery_web/templates/layout/{topbar.html.eex => topbar.html.heex} (63%) create mode 100644 priv/gettext/actions.pot diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9875b2e8..3491e279 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,8 +41,9 @@ If you're multilingual, this project can use your translations! Visit - When adding text, please use `gettext` macros to enable things to be translated in the future. After adding `gettext` macros, run `mix format` in order to add your new text strings to the files in `priv/gettext`. - - Existing domains: `"default"` (for anything general), `"prompts"`, - `"emails"`, and `"errors"` + - Existing domains: `"default"` (for anything general), `"prompts"` (as a + result of the user doing an action), `"actions"` (actions that the user can + take), `"emails"`, and `"errors"` - Before submitting a PR, please make sure all tests are passing using `mix test`. And as always, thank you! diff --git a/lib/cannery_web/component/topbar.ex b/lib/cannery_web/component/topbar.ex index 853c062c..22d1aba2 100644 --- a/lib/cannery_web/component/topbar.ex +++ b/lib/cannery_web/component/topbar.ex @@ -32,32 +32,32 @@ defmodule CanneryWeb.Component.Topbar do space-x-4 text-lg text-white text-ellipsis"> <%= if @current_user do %>
  • - <%= link("Tags", + <%= link(gettext("Tags"), class: "hover:underline", to: Routes.tag_index_path(CanneryWeb.Endpoint, :index) ) %>
  • - <%= link("Containers", + <%= link(gettext("Containers"), class: "hover:underline", to: Routes.container_index_path(CanneryWeb.Endpoint, :index) ) %>
  • - <%= link("Ammo", + <%= link(gettext("Ammo"), class: "hover:underline", to: Routes.ammo_type_index_path(CanneryWeb.Endpoint, :index) ) %>
  • - <%= link("Manage", + <%= link(gettext("Manage"), class: "hover:underline", to: Routes.ammo_group_index_path(CanneryWeb.Endpoint, :index) ) %>
  • <%= if @current_user.role == :admin do %>
  • - <%= link("Invites", + <%= link(gettext("Invites"), class: "hover:underline", to: Routes.invite_index_path(CanneryWeb.Endpoint, :index) ) %> @@ -72,7 +72,7 @@ defmodule CanneryWeb.Component.Topbar do
  • <%= link to: Routes.user_session_path(CanneryWeb.Endpoint, :delete), method: :delete, - data: [confirm: "Are you sure you want to log out?"] do %> + data: [confirm: dgettext("prompts", "Are you sure you want to log out?")] do %> <% end %>
  • @@ -86,14 +86,14 @@ defmodule CanneryWeb.Component.Topbar do <% else %> <%= if Accounts.allow_registration?() do %>
  • - <%= link("Register", + <%= link(dgettext("actions", "Register"), class: "hover:underline", to: Routes.user_registration_path(CanneryWeb.Endpoint, :new) ) %>
  • <% end %>
  • - <%= link("Log in", + <%= link(dgettext("actions", "Log in"), class: "hover:underline", to: Routes.user_session_path(CanneryWeb.Endpoint, :new) ) %> @@ -102,16 +102,6 @@ defmodule CanneryWeb.Component.Topbar do - <%= if @flash && @flash |> Map.has_key?(:info) do %> - - <% end %> - <%= if @flash && @flash |> Map.has_key?(:error) do %> - - <% end %> """ end diff --git a/lib/cannery_web/templates/layout/app.html.heex b/lib/cannery_web/templates/layout/app.html.heex index 5a7d89d9..a352cb9c 100644 --- a/lib/cannery_web/templates/layout/app.html.heex +++ b/lib/cannery_web/templates/layout/app.html.heex @@ -2,6 +2,7 @@
    <%= render("topbar.html", assigns) %>
    +
    <%= if get_flash(@conn, :info) do %> <% end %>
    + <%= @inner_content %> diff --git a/lib/cannery_web/templates/layout/root.html.heex b/lib/cannery_web/templates/layout/root.html.heex index a8ae8ac7..36a3efc2 100644 --- a/lib/cannery_web/templates/layout/root.html.heex +++ b/lib/cannery_web/templates/layout/root.html.heex @@ -15,6 +15,7 @@ > + <%= @inner_content %> diff --git a/lib/cannery_web/templates/layout/topbar.html.eex b/lib/cannery_web/templates/layout/topbar.html.heex similarity index 63% rename from lib/cannery_web/templates/layout/topbar.html.eex rename to lib/cannery_web/templates/layout/topbar.html.heex index 33fd1d57..37af7190 100644 --- a/lib/cannery_web/templates/layout/topbar.html.eex +++ b/lib/cannery_web/templates/layout/topbar.html.heex @@ -1,34 +1,42 @@