views/shared/authentication etc i18n (#15131)

* views/shared/authentication etc i18n

* remove ja.yml

* Update _providers_registration_form.html.erb

* Update registrations_spec.rb

* Update _email_registration_form.html.erb

* Update _forem_creator_signup.html.erb

* Update spec/requests/registrations_spec.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>

* Update dashboard_spec.rb

* Update dashboard_spec.rb

* Update _forem_creator_signup.html.erb

* Update _forem_creator_signup.html.erb

Co-authored-by: Michael Kohl <citizen428@forem.com>
This commit is contained in:
yheuhtozr 2021-12-02 01:56:33 +09:00 committed by GitHub
parent 25dd42704e
commit cca3bed043
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 226 additions and 67 deletions

View file

@ -8,7 +8,7 @@
<% end %>
</p>
<div>
<a href="<%= sign_up_path(state: "new-user") %>" class="crayons-btn w-100 mb-2" aria-label="Create new account"><%= t("core.create_account") %></a>
<a href="<%= sign_up_path %>" class="crayons-btn crayons-btn--ghost-brand w-100" aria-label="Log in"><%= t("core.log_in") %></a>
<a href="<%= sign_up_path(state: "new-user") %>" class="crayons-btn w-100 mb-2" aria-label="<%= t("views.auth.create.aria_label") %>"><%= t("views.auth.create.text") %></a>
<a href="<%= sign_up_path %>" class="crayons-btn crayons-btn--ghost-brand w-100" aria-label="<%= t("views.auth.login.aria_label") %>"><%= t("views.auth.login.text") %></a>
</div>
</div>

View file

@ -1,6 +1,6 @@
<a href="<%= sign_up_path(state: "new-user") %>" class="crayons-btn" aria-label="Create new account" data-no-instant>
<%= t("core.create_account") %>
<a href="<%= sign_up_path(state: "new-user") %>" class="crayons-btn" aria-label="<%= t("views.auth.create.aria_label") %>" data-no-instant>
<%= t("views.auth.create.text") %>
</a>
<a href="<%= sign_up_path %>" class="crayons-btn crayons-btn--ghost-brand" aria-label="Log in">
<%= t("core.log_in") %>
<a href="<%= sign_up_path %>" class="crayons-btn crayons-btn--ghost-brand" aria-label="<%= t("views.auth.login.aria_label") %>">
<%= t("views.auth.login.text") %>
</a>

View file

@ -1,5 +1,5 @@
<% if Settings::Community.tagline.present? %>
<%= Settings::Community.tagline %>
<% else %>
Log in to customize your experience and get involved.
<%= t("views.auth.tagline") %>
<% end %>

View file

@ -1 +1,4 @@
<a href="/"><%= community_name %></a> is a community of <%= display_estimated_user_count? ? number_with_delimiter(estimated_user_count) : "" %> amazing <%= community_members_label %>
<%= t("views.auth.title.text_html",
name: community_name,
maybe_size: display_estimated_user_count? ? t("views.auth.title.size", num: number_with_delimiter(estimated_user_count)) : "",
label: community_members_label) %>

View file

@ -15,11 +15,11 @@
</div>
<div class="actions pt-3">
<%= f.submit "Continue", class: "crayons-btn crayons-btn--l w-100" %>
<%= f.submit t("views.auth.login.continue"), class: "crayons-btn crayons-btn--l w-100" %>
</div>
<% end %>
<p class="pt-6 fs-s align-center">
<a href="<%= new_password_path(:user) %>">
I forgot my password
<%= t("views.auth.login.forgot") %>
</a>
</p>

View file

@ -11,7 +11,7 @@
<div class="crayons-card crayons-card--secondary crayons-notice crayons-notice--danger" role="alert" data-testid="signup-errors">
<div class="crayons-card__header">
<h3 class="crayons-card__headline">
Whoops, we found <%= pluralize(resource.errors.size, "problem") %>
<%= t("views.auth.register.errors", count: resource.errors.size) %>
</h3>
</div>
<div class="crayons-card__body">
@ -23,16 +23,16 @@
</div>
</div>
<% else %>
<p class="pb-4 fw-bold">Create your account</p>
<p class="pb-4 fw-bold"><%= t("views.auth.register.create") %></p>
<% end %>
<% if Settings::Authentication.display_email_domain_allow_list_publicly &&
Settings::Authentication.allowed_registration_email_domains.any? %>
<div class="crayons-notice crayons-notice--info" aria-live="polite">
<% if Settings::Authentication.allowed_registration_email_domains.one? %>
Registration restricted to <strong>@<%= Settings::Authentication.allowed_registration_email_domains.first %></strong> emails.
<%= t("views.auth.register.allow.one_html", domain: Settings::Authentication.allowed_registration_email_domains.first) %>
<% else %>
Registration restricted to the following emails
<%= t("views.auth.register.allow.list") %>
<ul>
<% Settings::Authentication.allowed_registration_email_domains.each do |domain| %>
<li>
@ -50,41 +50,41 @@
</div>
<div class="crayons-field mt-2">
<%= f.label :name, class: "crayons-field__label", aria: { label: "Name" } do %>
Name
<span class="crayons-field__required crayons-hover-tooltip" data-tooltip="* - required">*</span>
<%= f.label :name, class: "crayons-field__label", aria: { label: t("views.auth.register.field.name.aria_label") } do %>
<%= t("views.auth.register.field.name.label") %>
<span class="crayons-field__required crayons-hover-tooltip" data-tooltip="<%= t("views.auth.register.field.required") %>">*</span>
<% end %>
<%= f.text_field :name, class: "crayons-textfield", required: true %>
</div>
<div class="crayons-field mt-2">
<%= f.label :username, class: "crayons-field__label", aria: { label: "Username" } do %>
Username
<span class="crayons-field__required crayons-hover-tooltip" data-tooltip="* - required">*</span>
<%= f.label :username, class: "crayons-field__label", aria: { label: t("views.auth.register.field.username.aria_label") } do %>
<%= t("views.auth.register.field.username.label") %>
<span class="crayons-field__required crayons-hover-tooltip" data-tooltip="<%= t("views.auth.register.field.required") %>">*</span>
<% end %>
<%= f.text_field :username, class: "crayons-textfield", required: true %>
</div>
<div class="crayons-field mt-2">
<%= f.label :email, class: "crayons-field__label", aria: { label: "Email" } do %>
Email
<span class="crayons-field__required crayons-hover-tooltip" data-tooltip="* - required">*</span>
<%= f.label :email, class: "crayons-field__label", aria: { label: t("views.auth.register.field.email.aria_label") } do %>
<%= t("views.auth.register.field.email.label") %>
<span class="crayons-field__required crayons-hover-tooltip" data-tooltip="<%= t("views.auth.register.field.required") %>">*</span>
<% end %>
<%= f.email_field :email, autocomplete: "email", class: "crayons-textfield", required: true %>
</div>
<div class="crayons-field mt-2">
<%= f.label :password, class: "crayons-field__label", aria: { label: "Password" } do %>
Password
<span class="crayons-field__required crayons-hover-tooltip" data-tooltip="* - required">*</span>
<%= f.label :password, class: "crayons-field__label", aria: { label: t("views.auth.register.field.password.aria_label") } do %>
<%= t("views.auth.register.field.password.label") %>
<span class="crayons-field__required crayons-hover-tooltip" data-tooltip="<%= t("views.auth.register.field.required") %>">*</span>
<% end %>
<%= f.password_field :password, autocomplete: "current-password", class: "crayons-textfield", required: true %>
</div>
<div class="crayons-field mt-2">
<%= f.label :password_confirmation, class: "crayons-field__label", aria: { label: "Password Confirmation" } do %>
Password Confirmation
<span class="crayons-field__required crayons-hover-tooltip" data-tooltip="* - required">*</span>
<%= f.label :password_confirmation, class: "crayons-field__label", aria: { label: t("views.auth.register.field.confirm.aria_label") } do %>
<%= t("views.auth.register.field.confirm.label") %>
<span class="crayons-field__required crayons-hover-tooltip" data-tooltip="<%= t("views.auth.register.field.required") %>">*</span>
<% end %>
<%= f.password_field :password_confirmation, autocomplete: "current-password", class: "crayons-textfield", required: true %>
</div>
@ -94,8 +94,8 @@
<%= f.hidden_field :forem_owner_secret, value: params[:forem_owner_secret] %>
<% else %>
<div class="crayons-field mt-2">
<%= f.label :forem_owner_secret, "New Forem Secret", class: "crayons-field__label" %>
<%= f.password_field :forem_owner_secret, class: "crayons-textfield", required: true, placeholder: "As provided by your Forem host" %>
<%= f.label :forem_owner_secret, t("views.auth.register.secret.label"), class: "crayons-field__label" %>
<%= f.password_field :forem_owner_secret, class: "crayons-textfield", required: true, placeholder: t("views.auth.register.secret.placeholder") %>
</div>
<% end %>
<% end %>
@ -107,7 +107,7 @@
<% end %>
<div class="actions pt-3">
<%= f.submit "Sign up", class: "crayons-btn" %>
<%= f.submit t("views.auth.register.submit"), class: "crayons-btn" %>
</div>
<% end %>
</div>

View file

@ -26,7 +26,7 @@
<div class="crayons-card crayons-card--secondary crayons-notice crayons-notice--danger my-8" role="alert" data-testid="signup-errors">
<div class="crayons-card__header">
<h3 class="crayons-card__headline">
Whoops, we found <%= pluralize(resource.errors.size, "problem") %>
<%= t("views.auth.register.errors", count: resource.errors.size) %>
</h3>
</div>
<div class="crayons-card__body">
@ -40,48 +40,50 @@
<% end %>
<div class="align-center">
<p class="pb-4 fs-2xl m:fs-3xl lh-tight fw-bold">Let's start your Forem journey!</p>
<p class="color-base-70 fs-l m:fs-xl">Create your admin account first.</p>
<p class="color-base-70 fs-l m:fs-xl">Then we'll walk you through your Forem setup.</p>
<p class="pb-4 fs-2xl m:fs-3xl lh-tight fw-bold"><%= t("views.auth.creator.text1") %></p>
<p class="color-base-70 fs-l m:fs-xl"><%= t("views.auth.creator.text2") %></p>
<p class="color-base-70 fs-l m:fs-xl"><%= t("views.auth.creator.text3") %></p>
</div>
<div class="crayons-field mt-6">
<%= f.label :name, "Name", for: "name", class: "crayons-field__label" %>
<%= f.label :name, t("views.auth.register.field.name.label"), for: "name", class: "crayons-field__label" %>
<%= f.text_field :name, id: "name", placeholder: "John Doe", class: "crayons-textfield js-creator-signup-name", required: true %>
<div class="js-creator-signup-username-hint-row hidden">
<div class="fs-xs color-base-60 flex">
<span>Your username will be&nbsp;</span>
<button type="button" aria-label="Edit username" class="cursor-pointer border-none bg-transparent p-0 js-creator-edit-username flex color-base-90" role="button">
<span class="js-creator-signup-username-hint"></span>
<%= inline_svg_tag("pencil.svg", class: "cursor-pointer crayons-icon opacity-75 ml-1", aria_hidden: true, title: "Edit username") %>
</button>
<%= t("views.auth.creator.hint.text_html", start: tag("span", nil, true), end: "</span>".html_safe,
button: tag.button(
tag.span(class: "js-creator-signup-username-hint") + inline_svg_tag("pencil.svg", class: "cursor-pointer crayons-icon opacity-75 ml-1", aria_hidden: true, title: t("views.auth.creator.hint.icon")),
class: "cursor-pointer border-none bg-transparent p-0 js-creator-edit-username flex color-base-90",
role: "button", type: "button",
aria: { label: t("views.auth.creator.hint.aria_label") },
)) %>
</div>
</div>
</div>
<div class="crayons-field mt-6 <%= "hidden" unless any_errors %> js-creator-signup-username-row">
<%= f.label :username, "Username", for: "username", class: "crayons-field__label" %>
<%= f.text_field :username, pattern: "[A-Za-z0-9_]+", maxlength: "30", title: "A username can only contain letters, numbers and underscores. The maximum username length can be 30 characters.", id: "username", class: "js-creator-signup-username crayons-textfield",
<%= f.label :username, t("views.auth.register.field.username.label"), for: "username", class: "crayons-field__label" %>
<%= f.text_field :username, pattern: "[A-Za-z0-9_]+", maxlength: "30", title: t("views.auth.register.field.username.desc"), id: "username", class: "js-creator-signup-username crayons-textfield",
aria: { describedby: "username-helper-text" } %>
<p id="username-helper-text" class="fs-xs color-base-60 mt-1">It can only contain letters, numbers and underscores. The maximum username length can be 30 characters.</p>
<p id="username-helper-text" class="fs-xs color-base-60 mt-1"><%= t("views.auth.register.field.username.desc") %></p>
</div>
<div class="crayons-field mt-6">
<%= f.label :email, "Email", for: "email", class: "crayons-field__label" %>
<%= f.email_field :email, placeholder: "john@example.com", autocomplete: "email", id: "email", class: "crayons-textfield", required: true %>
<%= f.label :email, t("views.auth.register.field.email.label"), for: "email", class: "crayons-field__label" %>
<%= f.email_field :email, placeholder: t("views.auth.register.field.email.placeholder"), autocomplete: "email", id: "email", class: "crayons-textfield", required: true %>
</div>
<div class="crayons-field mt-6">
<%= f.label :password, "Password", class: "crayons-field__label" %>
<%= f.label :password, t("views.auth.register.field.password.label"), class: "crayons-field__label" %>
<div class="relative">
<%= f.password_field :password, minlength: "8", class: "crayons-textfield js-password", placeholder: "••••••••", required: true, aria: { describedby: "password-helper-text" } %>
<button type="button" class="crayons-btn crayons-btn--ghost crayons-btn--s js-creator-password-visibility h-100 absolute z-elevate right-0" aria-label="Show password" aria-pressed="false">
<%= inline_svg_tag("eye.svg", class: "crayons-icon js-eye", data: { testid: "mask-icon" }, aria_hidden: true, title: "Show password") %>
<%= inline_svg_tag("eye-off.svg", class: "crayons-icon hidden js-eye-off", data: { testid: "unmask-icon" }, aria_hidden: true, title: "Hide password") %>
<%= f.password_field :password, minlength: "8", class: "crayons-textfield js-password", placeholder: t("views.auth.register.field.password.placeholder"), required: true, aria: { describedby: "password-helper-text" } %>
<button type="button" class="crayons-btn crayons-btn--ghost crayons-btn--s js-creator-password-visibility h-100 absolute z-elevate right-0" aria-label="<%= t("views.auth.register.field.password.show") %>" aria-pressed="false">
<%= inline_svg_tag("eye.svg", class: "crayons-icon js-eye", data: { testid: "mask-icon" }, aria_hidden: true, title: t("views.auth.register.field.password.show")) %>
<%= inline_svg_tag("eye-off.svg", class: "crayons-icon hidden js-eye-off", data: { testid: "unmask-icon" }, aria_hidden: true, title: t("views.auth.register.field.password.hide")) %>
</button>
</div>
<p id="password-helper-text" class="fs-xs color-base-60 mt-1">Minimum 8 characters</p>
<p id="password-helper-text" class="fs-xs color-base-60 mt-1"><%= t("views.auth.register.field.password.desc") %></p>
</div>
<% if ForemInstance.needs_owner_secret? %>
@ -89,16 +91,16 @@
<%= f.hidden_field :forem_owner_secret, value: params[:forem_owner_secret] %>
<% else %>
<div class="crayons-field mt-6">
<%= f.label :forem_owner_secret, "New Forem Secret", class: "crayons-field__label" %>
<%= f.password_field :forem_owner_secret, class: "crayons-textfield", required: ForemInstance.needs_owner_secret?, placeholder: "As provided by your Forem host" %>
<%= f.label :forem_owner_secret, t("views.auth.register.secret.label"), class: "crayons-field__label" %>
<%= f.password_field :forem_owner_secret, class: "crayons-textfield", required: ForemInstance.needs_owner_secret?, placeholder: t("views.auth.register.secret.placeholder") %>
</div>
<% end %>
<% end %>
<div class="flex flex-col pt-6">
<%= f.submit "Create my account", class: "crayons-btn" %>
<%= f.submit t("views.auth.creator.submit"), class: "crayons-btn" %>
</div>
<% end %>
</div>
<%= inline_svg_tag("forem-background.svg", aria: true, title: "forem background", class: "forem-background absolute bottom-0 right-0 hidden m:block") %>
<%= inline_svg_tag("forem-background.svg", aria: true, title: t("views.auth.background"), class: "forem-background absolute bottom-0 right-0 hidden m:block") %>
</main>

View file

@ -1,21 +1,21 @@
<% title "Let's get started with Forem" %>
<% title t("views.auth.wizard.meta.title") %>
<div class="crayons-card crayons-card--secondary crayons-notice crayons-notice--success mx-auto mt-8 mb-10 p-4 fs-2xl lh-base align-center" style="width:96%;max-width:1300px;" aria-live="polite">
<h1 class="m-7 mb-3">Let's start your Forem journey</h1>
<h1 class="m-7 mb-3"><%= t("views.auth.wizard.heading") %></h1>
<img class="m-7 mb-2 radius-default" alt="Dancing Baby Groot GIF" src="https://media.giphy.com/media/F9hQLAVhWnL56/giphy.gif" style="height:220px" />
<p class="mb-4 mt-6">
Create an account. It will be the first super admin account.
<%= t("views.auth.wizard.step_1") %>
</p>
<p class="mb-4">
Once you sign up below, you can configure your community at <a href="<%= admin_config_path %>"><%= admin_config_path %></a>.
<%= t("views.auth.wizard.step_2_html", path: link_to(admin_config_path, admin_config_path)) %>
</p>
<p class="mb-4">
There is lots you can do as an admin, but there is a learning curve.
<%= t("views.auth.wizard.step_3") %>
</p>
<p class="mb-8">
Please reach out to the Forem team if you are unsure about anything!
<%= t("views.auth.wizard.step_4") %>
</p>
<p class="mb-7 fw-bold">
For Empowering Community 🌱
<%= t("views.auth.wizard.step_5") %>
</p>
<%= render "shared/authentication/email_registration_form" %>
</div>

View file

@ -4,12 +4,12 @@
<%= form_with url: provider.sign_in_path(state: "navbar_basic"), class: "flex w-100", local: true do |f| %>
<%= f.button type: :submit, class: "crayons-btn crayons-btn--l crayons-btn--brand-#{provider.provider_name} crayons-btn--icon-left grow-1 whitespace-nowrap" do %>
<%= inline_svg_tag("#{provider.provider_name}.svg", aria_hidden: true, class: "crayons-icon", title: provider.provider_name) %>
<%= params[:state] == "new-user" ? "Sign up" : "Continue" %> with <%= provider.official_name %>
<%= t("views.auth.provider.text", action: params[:state] == "new-user" ? t("views.auth.provider.signup") : t("views.auth.provider.login"), provider: provider.official_name) %>
<% end %>
<% end %>
<% end %>
<% if params[:state] == "new-user" && Settings::Authentication.allow_email_password_registration && !ForemInstance.invitation_only? %>
<%= link_to "#{inline_svg_tag('email.svg', aria_hidden: true, class: 'crayons-icon', title: 'email')}Sign up with Email".html_safe,
<%= link_to "#{inline_svg_tag('email.svg', aria_hidden: true, class: 'crayons-icon', title: t('views.auth.provider.email.icon'))}#{t('views.auth.provider.email.text')}".html_safe,
request.params.merge(state: "email_signup").except("i"),
class: "crayons-btn crayons-btn--l crayons-btn--brand-email crayons-btn--icon-left whitespace-nowrap",
data: { no_instant: "" } %>

View file

@ -0,0 +1,77 @@
---
en:
views:
auth:
background: forem background
create:
aria_label: Create new account
text: Create account
creator:
text1: Let's start your Forem journey!
text2: Create your admin account first.
text3: Then we'll walk you through your Forem setup.
hint:
aria_label: Edit username
icon: Edit username
text_html: "%{start}Your username will be\_%{end}%{button}"
submit: Create my account
login:
aria_label: Log in
text: Log in
continue: Continue
forgot: I forgot my password
provider:
text: "%{action} with %{provider}"
login: Continue
signup: Sign up
email:
icon: email
text: Sign up with Email
register:
errors:
one: Whoops, we found %{count} problem
other: Whoops, we found %{count} problems
allow:
one_html: Registration restricted to <strong>@%{domain}</strong> emails.
list: Registration restricted to the following emails
create: Create your account
field:
name:
aria_label: Name
label: Name
username:
aria_label: Username
desc: A username can only contain letters, numbers and underscores. The maximum username length can be 30 characters.
label: Username
email:
aria_label: Email
label: Email
placeholder: john@example.com
password:
aria_label: Password
desc: Minimum 8 characters
label: Password
placeholder: "••••••••"
hide: Hide password
show: Show password
confirm:
aria_label: Password Confirmation
label: Password Confirmation
required: "* - required"
secret:
label: New Forem Secret
placeholder: As provided by your Forem host
submit: Sign up
wizard:
meta:
title: Let's get started with Forem
heading: Let's start your Forem journey
step_1: Create an account. It will be the first super admin account.
step_2_html: Once you sign up below, you can configure your community at %{path}.
step_3: There is lots you can do as an admin, but there is a learning curve.
step_4: Please reach out to the Forem team if you are unsure about anything!
step_5: "For Empowering Community 🌱"
tagline: Log in to customize your experience and get involved.
title:
text_html: <a href="/">%{name}</a> is a community of %{maybe_size}amazing %{label}
size: "%{num} "

View file

@ -0,0 +1,77 @@
---
fr:
views:
auth:
background: forem background
create:
aria_label: Create new account
text: Créer un profil
creator:
text1: Let's start your Forem journey!
text2: Create your admin account first.
text3: Then we'll walk you through your Forem setup.
hint:
aria_label: Edit username
icon: Edit username
text_html: "%{start}Your username will be\_%{end}%{button}"
submit: Create my account
login:
aria_label: Log in
text: Se connecter
continue: Continue
forgot: I forgot my password
provider:
text: "%{action} with %{provider}"
login: Continue
signup: Sign up
email:
icon: email
text: Sign up with Email
register:
errors:
one: Whoops, we found %{count} problem
other: Whoops, we found %{count} problems
allow:
one_html: Registration restricted to <strong>@%{domain}</strong> emails.
list: Registration restricted to the following emails
create: Create your account
field:
name:
aria_label: Name
label: Name
username:
aria_label: Username
desc: A username can only contain letters, numbers and underscores. The maximum username length can be 30 characters.
label: Username
email:
aria_label: Email
label: Email
placeholder: john@example.com
password:
aria_label: Password
desc: Minimum 8 characters
label: Password
placeholder: "••••••••"
hide: Hide password
show: Show password
confirm:
aria_label: Password Confirmation
label: Password Confirmation
required: "* - required"
secret:
label: New Forem Secret
placeholder: As provided by your Forem host
submit: Sign up
wizard:
meta:
title: Let's get started with Forem
heading: Let's start your Forem journey
step_1: Create an account. It will be the first super admin account.
step_2_html: Once you sign up below, you can configure your community at %{path}.
step_3: There is lots you can do as an admin, but there is a learning curve.
step_4: Please reach out to the Forem team if you are unsure about anything!
step_5: "For Empowering Community 🌱"
tagline: Log in to customize your experience and get involved.
title:
text_html: <a href="/">%{name}</a> is a community of %{maybe_size}amazing %{label}
size: "%{num} "

View file

@ -156,7 +156,7 @@ RSpec.describe "Registrations", type: :request do
it "renders the creator onboarding form" do
get root_path
expect(response.body).to include("Let's start your Forem journey!")
expect(response.body).to include(CGI.escapeHTML("Let's start your Forem journey!"))
expect(response.body).to include("Create your admin account first")
end
end