From 26fe7677a91c6ab9b6f6aa05a2c083fc6e19ed50 Mon Sep 17 00:00:00 2001 From: Tim Cowlishaw Date: Thu, 31 Oct 2024 15:54:21 +0100 Subject: [PATCH] Move all user-facing web copy into localization files --- app/controllers/discourse_controller.rb | 2 +- app/controllers/ui/sessions_controller.rb | 18 +++++++++--------- app/controllers/ui/users_controller.rb | 2 +- app/views/layouts/_footer.html.erb | 20 ++++++++++---------- app/views/layouts/_nav.html.erb | 12 ++++++------ app/views/layouts/application.html.erb | 4 ++-- app/views/ui/sessions/new.html.erb | 10 +++++----- app/views/ui/users/index.html.erb | 10 +++++----- config/application.rb | 1 + config/locales/controllers/en.yml | 13 +++++++++++++ config/locales/users/en.yml | 6 ++++++ config/locales/views/footer/en.yml | 11 +++++++++++ config/locales/views/layout/en.yml | 2 ++ config/locales/views/nav/en.yml | 11 +++++++++++ config/locales/views/sessions/en.yml | 6 ++++++ spec/features/session_management_spec.rb | 2 +- 16 files changed, 90 insertions(+), 40 deletions(-) create mode 100644 config/locales/controllers/en.yml create mode 100644 config/locales/users/en.yml create mode 100644 config/locales/views/footer/en.yml create mode 100644 config/locales/views/layout/en.yml create mode 100644 config/locales/views/nav/en.yml create mode 100644 config/locales/views/sessions/en.yml diff --git a/app/controllers/discourse_controller.rb b/app/controllers/discourse_controller.rb index 80ea755d..b215554a 100644 --- a/app/controllers/discourse_controller.rb +++ b/app/controllers/discourse_controller.rb @@ -6,7 +6,7 @@ class DiscourseController < ApplicationController def sso if !current_user session[:discourse_url] = request.url - redirect_to new_ui_session_path(goto: request.path), notice: 'Please Log In before using SSO' + redirect_to new_ui_session_path(goto: request.path), notice: I18n.t(:login_before_sso_notice) return end secret = DISCOURSE_SSO_SECRET diff --git a/app/controllers/ui/sessions_controller.rb b/app/controllers/ui/sessions_controller.rb index faea7aba..34729b5a 100644 --- a/app/controllers/ui/sessions_controller.rb +++ b/app/controllers/ui/sessions_controller.rb @@ -6,7 +6,7 @@ class SessionsController < ApplicationController require 'net/https' def new - @title = "Welcome!" + @title = I18n.t(:new_session_title) redirect_to ui_users_url if current_user end @@ -29,11 +29,11 @@ def create if params[:goto].include? 'discourse' redirect_to session[:discourse_url] else - flash[:success] = "You have been successfully logged in!" + flash[:success] = I18n.t(:new_session_success) redirect_to (session[:user_return_to] || ui_users_path) end else - flash.now.alert = "Email or password is invalid" + flash.now.alert = I18n.t(:new_session_failure) render "new" end end @@ -46,11 +46,11 @@ def reset_password_email authorize user, :request_password_reset? user.send_password_reset end - flash[:notice] = 'Please check your email to reset the password.' + flash[:notice] = I18n.t(:password_reset_notice) end def password_reset_landing - @title = "Change password" + @title = I18n.t(:password_reset_landing_title) @token = params[:token] end @@ -58,7 +58,7 @@ def change_password @token = params.require(:token) if params.require(:password) != params.require(:password_confirmation) - flash[:alert] ="Your password doesn't match the confirmation" + flash[:alert] = I18n.t(:password_reset_failure) render "password_reset_landing" return end @@ -67,17 +67,17 @@ def change_password if @user authorize @user, :update_password? @user.update({ password: params.require(:password), password_reset_token: nil }) - flash[:success] = "Changed password for: #{@user.username}" + flash[:success] = I18n.t(:password_reset_success, username: @user.username) redirect_to new_ui_session_path else - flash[:alert] = 'Your reset code might be too old or have been used before.' + flash[:alert] = I18n.t(:password_reset_invalid) render "password_reset_landing" end end def destroy session[:user_id] = nil - redirect_to login_url, notice: "Logged out!" + redirect_to login_url, notice: I18n.t(:destroy_session_success) end end end diff --git a/app/controllers/ui/users_controller.rb b/app/controllers/ui/users_controller.rb index d256ccfe..08a68483 100644 --- a/app/controllers/ui/users_controller.rb +++ b/app/controllers/ui/users_controller.rb @@ -2,7 +2,7 @@ module Ui class UsersController < ApplicationController include SharedControllerMethods def index - @title = "User information" + @title = I18n.t(:users_index_title) end end end diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index b0ac312e..0f623b13 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -2,30 +2,30 @@
- " alt="Smart Citizen"> + " alt="<%= t :footer_logo_alt %>">
-
A project by
+
<%= t :footer_attribution %>
- " alt="Fablab BCN" /> + " alt="<%= t :footer_fablab_alt %>" />
- " alt="IAAC"> + " alt="<%= t :footer_iaac_alt %>">
@@ -35,13 +35,13 @@ " alt="" />
-

Smart Citizen has received funding from the
European Community’s H2020 Programme
under Grant Agreement No. 689954.

+

<%= t :footer_funding_html %>

-

Except where otherwise noted, content on this site by Smart Citizen® is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Check the Terms of use and Privacy Policy.

+

<%= t :footer_licence_html %>

diff --git a/app/views/layouts/_nav.html.erb b/app/views/layouts/_nav.html.erb index b13356d6..78d950d7 100644 --- a/app/views/layouts/_nav.html.erb +++ b/app/views/layouts/_nav.html.erb @@ -1,24 +1,24 @@