From 8f8d2abb12395a2b3565868d6e52608b832fcbd5 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Mon, 28 Feb 2022 02:11:57 -0500 Subject: [PATCH] Make oauth pages translatable --- lib/pleroma/web/o_auth/o_auth_view.ex | 2 + .../templates/o_auth/o_auth/_scopes.html.eex | 2 +- .../templates/o_auth/o_auth/consumer.html.eex | 4 +- .../o_auth/oob_authorization_created.html.eex | 4 +- .../o_auth/o_auth/oob_token_exists.html.eex | 4 +- .../templates/o_auth/o_auth/register.html.eex | 26 ++-- .../web/templates/o_auth/o_auth/show.html.eex | 22 +-- priv/gettext/static_pages.pot | 145 ++++++++++++++++++ 8 files changed, 179 insertions(+), 30 deletions(-) diff --git a/lib/pleroma/web/o_auth/o_auth_view.ex b/lib/pleroma/web/o_auth/o_auth_view.ex index 1419c96a2..57a315705 100644 --- a/lib/pleroma/web/o_auth/o_auth_view.ex +++ b/lib/pleroma/web/o_auth/o_auth_view.ex @@ -5,6 +5,8 @@ defmodule Pleroma.Web.OAuth.OAuthView do use Pleroma.Web, :view import Phoenix.HTML.Form + import Phoenix.HTML + alias Pleroma.Web.Gettext alias Pleroma.Web.OAuth.Token.Utils diff --git a/lib/pleroma/web/templates/o_auth/o_auth/_scopes.html.eex b/lib/pleroma/web/templates/o_auth/o_auth/_scopes.html.eex index c9ec1ecbf..73115e92a 100644 --- a/lib/pleroma/web/templates/o_auth/o_auth/_scopes.html.eex +++ b/lib/pleroma/web/templates/o_auth/o_auth/_scopes.html.eex @@ -1,5 +1,5 @@
- <%= label @form, :scope, "The following permissions will be granted" %> + <%= label @form, :scope, Gettext.dpgettext("static_pages", "oauth scopes message", "The following permissions will be granted") %>
<%= for scope <- @available_scopes do %> <%# Note: using hidden input with `unchecked_value` in order to distinguish user's empty selection from `scope` param being omitted %> diff --git a/lib/pleroma/web/templates/o_auth/o_auth/consumer.html.eex b/lib/pleroma/web/templates/o_auth/o_auth/consumer.html.eex index dc4521a62..8b894cd58 100644 --- a/lib/pleroma/web/templates/o_auth/o_auth/consumer.html.eex +++ b/lib/pleroma/web/templates/o_auth/o_auth/consumer.html.eex @@ -1,4 +1,4 @@ -

Sign in with external provider

+

<%= Gettext.dpgettext("static_pages", "oauth external provider page title", "Sign in with external provider") %>

<%= form_for @conn, Routes.o_auth_path(@conn, :prepare_request), [as: "authorization", method: "get"], fn f -> %>
@@ -10,6 +10,6 @@ <%= hidden_input f, :state, value: @state %> <%= for strategy <- Pleroma.Config.oauth_consumer_strategies() do %> - <%= submit "Sign in with #{String.capitalize(strategy)}", name: "provider", value: strategy %> + <%= submit Gettext.dpgettext("static_pages", "oauth external provider sign in button", "Sign in with %{strategy}", strategy: String.capitalize(strategy)), name: "provider", value: strategy %> <% end %> <% end %> diff --git a/lib/pleroma/web/templates/o_auth/o_auth/oob_authorization_created.html.eex b/lib/pleroma/web/templates/o_auth/o_auth/oob_authorization_created.html.eex index ffabe29a6..aaa38513a 100644 --- a/lib/pleroma/web/templates/o_auth/o_auth/oob_authorization_created.html.eex +++ b/lib/pleroma/web/templates/o_auth/o_auth/oob_authorization_created.html.eex @@ -1,2 +1,2 @@ -

Successfully authorized

-

Token code is
<%= @auth.token %>

+

<%= Gettext.dpgettext("static_pages", "oauth authorized page title", "Successfully authorized") %>

+

<%= raw Gettext.dpgettext("static_pages", "oauth token code message", "Token code is
%{token}", token: html_escape(@auth.token)) %>

diff --git a/lib/pleroma/web/templates/o_auth/o_auth/oob_token_exists.html.eex b/lib/pleroma/web/templates/o_auth/o_auth/oob_token_exists.html.eex index 82785c4b9..de4cd0f34 100644 --- a/lib/pleroma/web/templates/o_auth/o_auth/oob_token_exists.html.eex +++ b/lib/pleroma/web/templates/o_auth/o_auth/oob_token_exists.html.eex @@ -1,2 +1,2 @@ -

Authorization exists

-

Access token is
<%= @token.token %>

+

<%= Gettext.dpgettext("static_pages", "oauth authorization exists page title", "Authorization exists") %>

+

<%= raw Gettext.dpgettext("static_pages", "oauth token code message", "Token code is
%{token}", token: html_escape(@auth.token)) %>

diff --git a/lib/pleroma/web/templates/o_auth/o_auth/register.html.eex b/lib/pleroma/web/templates/o_auth/o_auth/register.html.eex index 99f900fb7..1f661efb2 100644 --- a/lib/pleroma/web/templates/o_auth/o_auth/register.html.eex +++ b/lib/pleroma/web/templates/o_auth/o_auth/register.html.eex @@ -5,34 +5,34 @@ <% end %> -

Registration Details

+

<%= Gettext.dpgettext("static_pages", "oauth register page title", "Registration Details") %>

-

If you'd like to register a new account, please provide the details below.

+

<%= Gettext.dpgettext("static_pages", "oauth register page fill form prompt", "If you'd like to register a new account, please provide the details below.") %>

<%= form_for @conn, Routes.o_auth_path(@conn, :register), [as: "authorization"], fn f -> %>
- <%= label f, :nickname, "Nickname" %> - <%= text_input f, :nickname, value: @nickname %> + <%= label f, :nickname, Gettext.dpgettext("static_pages", "oauth register page nickname prompt", "Nickname") %> + <%= text_input f, :nickname, value: @nickname, autocomplete: "username" %>
- <%= label f, :email, "Email" %> - <%= text_input f, :email, value: @email %> + <%= label f, :email, Gettext.dpgettext("static_pages", "oauth register page email prompt", "Email") %> + <%= text_input f, :email, value: @email, autocomplete: "email" %>
-<%= submit "Proceed as new user", name: "op", value: "register" %> +<%= submit Gettext.dpgettext("static_pages", "oauth register page register button", "Proceed as new user"), name: "op", value: "register" %> -

Alternatively, sign in to connect to existing account.

+

<%= Gettext.dpgettext("static_pages", "oauth register page login prompt", "Alternatively, sign in to connect to existing account.") %>

- <%= label f, :name, "Name or email" %> - <%= text_input f, :name %> + <%= label f, :name, Gettext.dpgettext("static_pages", "oauth register page login username prompt", "Name or email") %> + <%= text_input f, :name, autocomplete: "username" %>
- <%= label f, :password, "Password" %> - <%= password_input f, :password %> + <%= label f, :password, Gettext.dpgettext("static_pages", "oauth register page login password prompt", "Password") %> + <%= password_input f, :password, autocomplete: "password" %>
-<%= submit "Proceed as existing user", name: "op", value: "connect" %> +<%= submit Gettext.dpgettext("static_pages", "oauth register page login button", "Proceed as existing user"), name: "op", value: "connect" %> <%= hidden_input f, :client_id, value: @client_id %> <%= hidden_input f, :redirect_uri, value: @redirect_uri %> diff --git a/lib/pleroma/web/templates/o_auth/o_auth/show.html.eex b/lib/pleroma/web/templates/o_auth/o_auth/show.html.eex index 181a9519a..31ae3cd1b 100644 --- a/lib/pleroma/web/templates/o_auth/o_auth/show.html.eex +++ b/lib/pleroma/web/templates/o_auth/o_auth/show.html.eex @@ -20,36 +20,38 @@
<%= if @app do %> -

Application <%= @app.client_name %> is requesting access to your account.

+

<%= raw Gettext.dpgettext("static_pages", "oauth authorize message", "Application %{client_name} is requesting access to your account.", client_name: html_escape(@app.client_name)) %>

<%= render @view_module, "_scopes.html", Map.merge(assigns, %{form: f}) %> <% end %> <%= if @user do %>
- Cancel - <%= submit "Approve", class: "button--approve" %> + + <%= Gettext.dpgettext("static_pages", "oauth authorize cancel button", "Cancel") %> + + <%= submit Gettext.dpgettext("static_pages", "oauth authorize approve button", "Approve"), class: "button--approve" %>
<% else %> <%= if @params["registration"] in ["true", true] do %> -

This is the first time you visit! Please enter your Pleroma handle.

-

Choose carefully! You won't be able to change this later. You will be able to change your display name, though.

+

<%= Gettext.dpgettext("static_pages", "oauth register page title", "This is the first time you visit! Please enter your Pleroma handle.") %>

+

<%= Gettext.dpgettext("static_pages", "oauth register nickname unchangeable warning", "Choose carefully! You won't be able to change this later. You will be able to change your display name, though.") %>

- <%= label f, :nickname, "Pleroma Handle" %> - <%= text_input f, :nickname, placeholder: "lain" %> + <%= label f, :nickname, Gettext.dpgettext("static_pages", "oauth register nickname prompt", "Pleroma Handle") %> + <%= text_input f, :nickname, placeholder: "lain", autocomplete: "username" %>
<%= hidden_input f, :name, value: @params["name"] %> <%= hidden_input f, :password, value: @params["password"] %>
<% else %>
- <%= label f, :name, "Username" %> + <%= label f, :name, Gettext.dpgettext("static_pages", "oauth login username prompt", "Username") %> <%= text_input f, :name %>
- <%= label f, :password, "Password" %> + <%= label f, :password, Gettext.dpgettext("static_pages", "oauth login password prompt", "Password") %> <%= password_input f, :password %>
- <%= submit "Log In" %> + <%= submit Gettext.dpgettext("static_pages", "oauth login button", "Log In") %> <% end %> <% end %>
diff --git a/priv/gettext/static_pages.pot b/priv/gettext/static_pages.pot index b230fbaa7..f9d535838 100644 --- a/priv/gettext/static_pages.pot +++ b/priv/gettext/static_pages.pot @@ -160,3 +160,148 @@ msgstr "" msgctxt "tag feed description" msgid "These are public toots tagged with #%{tag}. You can interact with them if you have an account anywhere in the fediverse." msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/oob_token_exists.html.eex:1 +msgctxt "oauth authorization exists page title" +msgid "Authorization exists" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/show.html.eex:32 +msgctxt "oauth authorize approve button" +msgid "Approve" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/show.html.eex:30 +msgctxt "oauth authorize cancel button" +msgid "Cancel" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/show.html.eex:23 +msgctxt "oauth authorize message" +msgid "Application %{client_name} is requesting access to your account." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/oob_authorization_created.html.eex:1 +msgctxt "oauth authorized page title" +msgid "Successfully authorized" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/consumer.html.eex:1 +msgctxt "oauth external provider page title" +msgid "Sign in with external provider" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/consumer.html.eex:13 +msgctxt "oauth external provider sign in button" +msgid "Sign in with %{strategy}" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/show.html.eex:54 +msgctxt "oauth login button" +msgid "Log In" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/show.html.eex:51 +msgctxt "oauth login password prompt" +msgid "Password" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/show.html.eex:47 +msgctxt "oauth login username prompt" +msgid "Username" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/show.html.eex:39 +msgctxt "oauth register nickname prompt" +msgid "Pleroma Handle" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/show.html.eex:37 +msgctxt "oauth register nickname unchangeable warning" +msgid "Choose carefully! You won't be able to change this later. You will be able to change your display name, though." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/register.html.eex:18 +msgctxt "oauth register page email prompt" +msgid "Email" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/register.html.eex:10 +msgctxt "oauth register page fill form prompt" +msgid "If you'd like to register a new account, please provide the details below." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/register.html.eex:35 +msgctxt "oauth register page login button" +msgid "Proceed as existing user" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/register.html.eex:31 +msgctxt "oauth register page login password prompt" +msgid "Password" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/register.html.eex:24 +msgctxt "oauth register page login prompt" +msgid "Alternatively, sign in to connect to existing account." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/register.html.eex:27 +msgctxt "oauth register page login username prompt" +msgid "Name or email" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/register.html.eex:14 +msgctxt "oauth register page nickname prompt" +msgid "Nickname" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/register.html.eex:22 +msgctxt "oauth register page register button" +msgid "Proceed as new user" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/register.html.eex:8 +msgctxt "oauth register page title" +msgid "Registration Details" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/show.html.eex:36 +msgctxt "oauth register page title" +msgid "This is the first time you visit! Please enter your Pleroma handle." +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/_scopes.html.eex:2 +msgctxt "oauth scopes message" +msgid "The following permissions will be granted" +msgstr "" + +#, elixir-format +#: lib/pleroma/web/templates/o_auth/o_auth/oob_authorization_created.html.eex:2 +#: lib/pleroma/web/templates/o_auth/o_auth/oob_token_exists.html.eex:2 +msgctxt "oauth token code message" +msgid "Token code is
%{token}" +msgstr ""