Skip to content

Commit

Permalink
I18n: translate all strings and add i18n-tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
patriciomacadden committed Feb 13, 2024
1 parent fdd4bd5 commit cf294ab
Show file tree
Hide file tree
Showing 26 changed files with 891 additions and 188 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ gem "turbo-rails"
gem "importmap-rails"
gem "standard"
gem "appraisal"
gem "i18n-tasks"

# Start debugger with binding.b [https://github.com/ruby/debug]
gem "debug", ">= 1.0.0"
30 changes: 30 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ GEM
ast (2.4.2)
base64 (0.1.1)
bcrypt (3.1.19)
better_html (2.0.2)
actionview (>= 6.0)
activesupport (>= 6.0)
ast (~> 2.0)
erubi (~> 1.4)
parser (>= 2.4)
smart_properties
bigdecimal (3.1.4)
bindex (0.8.1)
builder (3.2.4)
Expand All @@ -103,8 +110,20 @@ GEM
erubi (1.12.0)
globalid (1.2.1)
activesupport (>= 6.1)
highline (3.0.1)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
i18n-tasks (1.0.13)
activesupport (>= 4.0.2)
ast (>= 2.1.0)
better_html (>= 1.0, < 3.0)
erubi
highline (>= 2.0.0)
i18n
parser (>= 3.2.2.1)
rails-i18n
rainbow (>= 2.2.2, < 4.0)
terminal-table (>= 1.5.1)
importmap-rails (1.2.1)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
Expand Down Expand Up @@ -137,6 +156,8 @@ GEM
net-smtp (0.4.0)
net-protocol
nio4r (2.7.0)
nokogiri (1.16.2-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-darwin)
Expand Down Expand Up @@ -181,6 +202,9 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails-i18n (7.0.8)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8)
railties (7.1.0.rc2)
actionpack (= 7.1.0.rc2)
activesupport (= 7.1.0.rc2)
Expand Down Expand Up @@ -216,13 +240,15 @@ GEM
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
smart_properties (1.17.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.6.6-aarch64-linux)
sqlite3 (1.6.6-arm64-darwin)
sqlite3 (1.6.6-x86_64-darwin)
sqlite3 (1.6.6-x86_64-linux)
Expand All @@ -239,6 +265,8 @@ GEM
lint_roller (~> 1.1)
rubocop-performance (~> 1.19.0)
stringio (3.0.8)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.2.2)
timeout (0.4.0)
turbo-rails (1.4.0)
Expand All @@ -260,6 +288,7 @@ GEM
zeitwerk (2.6.12)

PLATFORMS
aarch64-linux
arm64-darwin-20
arm64-darwin-22
x86_64-darwin-20
Expand All @@ -270,6 +299,7 @@ PLATFORMS
DEPENDENCIES
appraisal
debug (>= 1.0.0)
i18n-tasks
importmap-rails
puma
revise_auth!
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/revise_auth/email_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ class ReviseAuth::EmailController < ReviseAuthController
# GET /profile/email?confirmation_token=abcdef
def show
if User.find_by_token_for(:email_verification, params[:confirmation_token])&.confirm_email_change
flash[:notice] = I18n.t("revise_auth.email_confirmed")
flash[:notice] = t(".email_confirmed")
redirect_to(user_signed_in? ? profile_path : root_path)
else
redirect_to root_path, alert: I18n.t("revise_auth.email_confirm_failed")
redirect_to root_path, alert: t(".email_confirm_failed")
end
end

def update
if current_user.update(email_params)
current_user.send_confirmation_instructions
flash[:notice] = I18n.t("revise_auth.confirmation_email_sent", email: current_user.unconfirmed_email)
flash[:notice] = t(".confirmation_email_sent", email: current_user.unconfirmed_email)
end

redirect_to profile_path
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/revise_auth/password_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ class ReviseAuth::PasswordController < ReviseAuthController

def update
if current_user.update(password_params)
redirect_to profile_path, notice: I18n.t("revise_auth.password_changed")
redirect_to profile_path, notice: t(".password_changed")
else
flash[:alert] = I18n.t("revise_auth.incorrect_password")
flash[:alert] = t(".incorrect_password")
render "revise_auth/registrations/edit", status: :unprocessable_entity
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/revise_auth/password_resets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def create
user = User.find_by(email: user_params[:email])
user&.send_password_reset_instructions

flash[:notice] = I18n.t("revise_auth.password_reset_sent")
flash[:notice] = t(".password_reset_sent")
redirect_to login_path
end

Expand All @@ -18,7 +18,7 @@ def edit

def update
if @user.update(password_params)
flash[:notice] = I18n.t("revise_auth.password_changed")
flash[:notice] = t("revise_auth.password.update.password_changed")
redirect_to login_path
else
render :edit, status: :unprocessable_entity
Expand All @@ -32,7 +32,7 @@ def set_user

return if @user.present?

flash[:alert] = I18n.t("revise_auth.password_link_invalid")
flash[:alert] = t(".invalid_password_link")
redirect_to new_password_reset_path
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/revise_auth/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def edit

def update
if current_user.update(profile_params)
redirect_to profile_path, notice: I18n.t("revise_auth.account_updated")
redirect_to profile_path, notice: t(".account_updated")
else
render :edit, status: :unprocessable_entity
end
Expand All @@ -29,7 +29,7 @@ def update
def destroy
current_user.destroy
logout
redirect_to root_path, status: :see_other, alert: I18n.t("revise_auth.account_deleted")
redirect_to root_path, status: :see_other, alert: t(".account_deleted")
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/revise_auth/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def create
login(user)
redirect_to resolve_after_login_path
else
flash[:alert] = I18n.t("revise_auth.invalid_email_or_password")
flash[:alert] = t(".invalid_email_or_password")
render :new, status: :unprocessable_entity
end
end
Expand Down
8 changes: 4 additions & 4 deletions app/views/revise_auth/mailer/confirm_email.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p>Welcome <%= @user.unconfirmed_email %>!</p>
<p><%=t ".welcome", email: @user.unconfirmed_email %></p>

<p>You can confirm your account email through the link below:</p>
<p><%=t ".confirm_below" %></p>

<p><%= link_to "Confirm my account", profile_email_url(confirmation_token: @token) %></p>
<p><%= link_to t(".confirm"), profile_email_url(confirmation_token: @token) %></p>

<p>This link will expire in 24 hours.</p>
<p><%=t ".expiration_notice" %></p>
7 changes: 3 additions & 4 deletions app/views/revise_auth/mailer/password_reset.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<p>We've received a password reset request for your login. If this was you just visit the
the link below to finish up. If it wasn't you, you can simply ignore this email.</p>
<p><%=t ".reset_password_below" %></p>

<p><%= link_to "Reset my password", edit_password_reset_url(token: @token) %></p>
<p><%= link_to t(".reset_password"), edit_password_reset_url(token: @token) %></p>

<p>This link will expire in 1 hour.</p>
<p><%=t ".expiration_notice" %></p>
4 changes: 2 additions & 2 deletions app/views/revise_auth/password_resets/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>Reset Your Password</h1>
<h1><%=t ".reset_password" %></h1>

<%= form_with model: @user, url: sign_up_path do |form| %>
<% if form.object.errors.any? %>
Expand All @@ -20,6 +20,6 @@
</div>

<div>
<%= form.button "Reset password" %>
<%= form.button t(".reset_password") %>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/revise_auth/password_resets/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>Send Password Reset Instructions</h1>
<h1><%=t ".send_password_reset_instructions" %></h1>

<%= form_with model: @user, url: password_resets_path do |form| %>
<% if form.object.errors.any? %>
Expand All @@ -15,6 +15,6 @@
</div>

<div>
<%= form.button "Send Reset Instructions" %>
<%= form.button t(".send_password_reset_instructions") %>
</div>
<% end %>
26 changes: 13 additions & 13 deletions app/views/revise_auth/registrations/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<h1>Profile</h1>
<h1><%=t ".profile" %></h1>

<%= form_with model: current_user, url: profile_email_path do |form| %>
<fieldset>
<legend>Change Email Address</legend>
<legend><%=t ".change_email_address" %></legend>

<% if current_user.unconfirmed_email? %>
<p>Waiting for confirmation of <%= current_user.unconfirmed_email %></p>
<p><%=t ".waiting_confirmation", email: current_user.unconfirmed_email %></p>
<% end %>

<% if form.object.errors.any? %>
Expand All @@ -16,23 +16,23 @@
</ul>
<% end %>

<p>Your email address is: <%= current_user.email %></p>
<p>To change your email, we will send a confirmation email to your new address to complete the change.</p>
<p><%=t ".current_email_address", email: current_user.email %></p>
<p><%=t ".confirmation_instructions" %></p>

<div>
<%= form.label :unconfirmed_email, "Email address" %>
<%= form.label :unconfirmed_email, t(".new_email") %>
<%= form.email_field :unconfirmed_email, required: true %>
</div>

<div>
<%= form.button "Save Changes" %>
<%= form.button t(".save") %>
</div>
</fieldset>
<% end %>

<%= form_with model: current_user, url: profile_password_path do |form| %>
<fieldset>
<legend>Change Password</legend>
<legend><%=t ".change_password" %></legend>

<% if form.object.errors.any? %>
<ul>
Expand All @@ -43,12 +43,12 @@
<% end %>

<div>
<%= form.label :password_challenge, "Current password" %>
<%= form.label :password_challenge %>
<%= form.password_field :password_challenge, required: true %>
</div>

<div>
<%= form.label :password, "New password" %>
<%= form.label :password, t(".new_password") %>
<%= form.password_field :password, required: true %>
</div>

Expand All @@ -58,14 +58,14 @@
</div>

<div>
<%= form.button "Save Changes" %>
<%= form.button t(".save") %>
</div>
</fieldset>
<% end %>

<%= form_with url: profile_path, method: :delete do |form| %>
<fieldset>
<legend>Delete my account</legend>
<%= form.button "Delete account", data: { turbo_confirm: "Are you sure?" } %>
<legend><%=t ".delete_account" %></legend>
<%= form.button t(".delete_account"), data: { turbo_confirm: t(".confirm") } %>
</fieldset>
<% end %>
6 changes: 3 additions & 3 deletions app/views/revise_auth/registrations/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<h1>Sign Up</h1>
<h1><%=t ".sign_up" %></h1>

<%= form_with model: @user, url: sign_up_path do |form| %>
<% if form.object.errors.any? %>
<ul>
<% form.object.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
<% end %>

</ul>
<div>
<%= form.label :email %>
<%= form.email_field :email, required: true, autofocus: true %>
Expand All @@ -25,6 +25,6 @@
</div>

<div>
<%= form.button "Sign Up" %>
<%= form.button t(".sign_up") %>
</div>
<% end %>
6 changes: 3 additions & 3 deletions app/views/revise_auth/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>Log in</h1>
<h1><%=t ".log_in" %></h1>

<%= form_with url: login_path do |form| %>
<div>
Expand All @@ -12,10 +12,10 @@
</div>

<div>
<%= form.button "Login" %>
<%= form.button t(".log_in") %>
</div>

<div>
<%= link_to "Reset your password", new_password_reset_path %>
<%= link_to t(".reset_password"), new_password_reset_path %>
</div>
<% end %>
Loading

0 comments on commit cf294ab

Please sign in to comment.