Make oauth pages translatable

This commit is contained in:
Tusooa Zhu 2022-02-28 02:11:57 -05:00 committed by Sam Therapy
parent 0ffb91a2d3
commit 5c674211ea
Signed by: sam
GPG key ID: 4D8B07C18F31ACBD
8 changed files with 174 additions and 25 deletions

View file

@ -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

View file

@ -1,5 +1,5 @@
<div class="scopes-input">
<%= 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") %>
<div class="scopes">
<%= 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 %>

View file

@ -1,4 +1,4 @@
<h2>Sign in with external provider</h2>
<h2><%= Gettext.dpgettext("static_pages", "oauth external provider page title", "Sign in with external provider") %></h2>
<%= form_for @conn, Routes.o_auth_path(@conn, :prepare_request), [as: "authorization", method: "get"], fn f -> %>
<div style="display: none">
@ -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 %>

View file

@ -1,2 +1,2 @@
<h1>Successfully authorized</h1>
<h2>Token code is <br><%= @auth.token %></h2>
<h1><%= Gettext.dpgettext("static_pages", "oauth authorized page title", "Successfully authorized") %></h1>
<h2><%= raw Gettext.dpgettext("static_pages", "oauth token code message", "Token code is <br>%{token}", token: html_escape(@auth.token)) %></h2>

View file

@ -1,2 +1,2 @@
<h1>Authorization exists</h1>
<h2>Access token is <br><%= @token.token %></h2>
<h1><%= Gettext.dpgettext("static_pages", "oauth authorization exists page title", "Authorization exists") %></h1>
<h2><%= raw Gettext.dpgettext("static_pages", "oauth token code message", "Token code is <br>%{token}", token: html_escape(@auth.token)) %></h2>

View file

@ -5,34 +5,34 @@
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<% end %>
<h2>Registration Details</h2>
<h2><%= Gettext.dpgettext("static_pages", "oauth register page title", "Registration Details") %></h2>
<p>If you'd like to register a new account, please provide the details below.</p>
<p><%= Gettext.dpgettext("static_pages", "oauth register page fill form prompt", "If you'd like to register a new account, please provide the details below.") %></p>
<%= form_for @conn, Routes.o_auth_path(@conn, :register), [as: "authorization"], fn f -> %>
<div class="input">
<%= label f, :nickname, "Nickname" %>
<%= label f, :nickname, Gettext.dpgettext("static_pages", "oauth register page nickname prompt", "Nickname") %>
<%= text_input f, :nickname, value: @nickname, autocomplete: "username" %>
</div>
<div class="input">
<%= label f, :email, "Email" %>
<%= label f, :email, Gettext.dpgettext("static_pages", "oauth register page email prompt", "Email") %>
<%= text_input f, :email, value: @email, autocomplete: "email" %>
</div>
<%= 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" %>
<p>Alternatively, sign in to connect to existing account.</p>
<p><%= Gettext.dpgettext("static_pages", "oauth register page login prompt", "Alternatively, sign in to connect to existing account.") %></p>
<div class="input">
<%= label f, :name, "Name or email" %>
<%= label f, :name, Gettext.dpgettext("static_pages", "oauth register page login username prompt", "Name or email") %>
<%= text_input f, :name, autocomplete: "username" %>
</div>
<div class="input">
<%= label f, :password, "Password" %>
<%= label f, :password, Gettext.dpgettext("static_pages", "oauth register page login password prompt", "Password") %>
<%= password_input f, :password, autocomplete: "password" %>
</div>
<%= 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 %>

View file

@ -20,21 +20,23 @@
<div class="container__content">
<%= if @app do %>
<p>Application <strong><%= @app.client_name %></strong> is requesting access to your account.</p>
<p><%= raw Gettext.dpgettext("static_pages", "oauth authorize message", "Application <strong>%{client_name}</strong> is requesting access to your account.", client_name: html_escape(@app.client_name)) %></p>
<%= render @view_module, "_scopes.html", Map.merge(assigns, %{form: f}) %>
<% end %>
<%= if @user do %>
<div class="actions">
<a class="button button--cancel" href="/">Cancel</a>
<%= submit "Approve", class: "button--approve" %>
<a class="button button--cancel" href="/">
<%= Gettext.dpgettext("static_pages", "oauth authorize cancel button", "Cancel") %>
</a>
<%= submit Gettext.dpgettext("static_pages", "oauth authorize approve button", "Approve"), class: "button--approve" %>
</div>
<% else %>
<%= if @params["registration"] in ["true", true] do %>
<h3>This is the first time you visit! Please enter your Pleroma handle.</h3>
<p>Choose carefully! You won't be able to change this later. You will be able to change your display name, though.</p>
<h3><%= Gettext.dpgettext("static_pages", "oauth register page title", "This is the first time you visit! Please enter your Pleroma handle.") %></h3>
<p><%= 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.") %></p>
<div class="input">
<%= label f, :nickname, "Pleroma Handle" %>
<%= label f, :nickname, Gettext.dpgettext("static_pages", "oauth register nickname prompt", "Pleroma Handle") %>
<%= text_input f, :nickname, placeholder: "lain", autocomplete: "username" %>
</div>
<%= hidden_input f, :name, value: @params["name"] %>
@ -42,14 +44,14 @@
<br>
<% else %>
<div class="input">
<%= label f, :name, "Username" %>
<%= label f, :name, Gettext.dpgettext("static_pages", "oauth login username prompt", "Username") %>
<%= text_input f, :name %>
</div>
<div class="input">
<%= label f, :password, "Password" %>
<%= label f, :password, Gettext.dpgettext("static_pages", "oauth login password prompt", "Password") %>
<%= password_input f, :password %>
</div>
<%= submit "Log In" %>
<%= submit Gettext.dpgettext("static_pages", "oauth login button", "Log In") %>
<% end %>
<% end %>
</div>

View file

@ -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 <strong>%{client_name}</strong> 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 <br>%{token}"
msgstr ""