Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate login/sign up/password recover pages #92

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--- {}
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ source "https://rubygems.org"
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
gem "solidus", github: "solidusio/solidus", branch: branch

# Provides basic authentication functionality for testing parts of your engine
gem 'solidus_auth_devise'

if branch == 'master' || branch >= "v2.0"
gem "rails-controller-testing", group: :test
else
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/spree/devise_controllers_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
begin
Spree::UserPasswordsController.include SolidusI18n::ControllerLocaleHelper
Spree::UserRegistrationsController.include SolidusI18n::ControllerLocaleHelper
Spree::UserSessionsController.include SolidusI18n::ControllerLocaleHelper
Spree::Admin::UserSessionsController.include SolidusI18n::ControllerLocaleHelper
rescue NameError
# App is not using solidus_auth_devise
end
3 changes: 2 additions & 1 deletion config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ it:
add: Nuovo credito
back_to_user_list: Lista utenti
select_reason: Motivo
admin_login: Login
admin_login: Login amministratore
administration: Amministrazione
advertise: Promuovi
agree_to_privacy_policy: Accetta Politica di Privacy
Expand Down Expand Up @@ -708,6 +708,7 @@ it:
other: Subtotale (%{count} articoli)
categories: Categorie
category: Categoria
change_my_password: Cambia la mia password
charged: Addebitato
check_for_spree_alerts: Visualizza le segnalazioni di Spree
checkout: Checkout
Expand Down
13 changes: 12 additions & 1 deletion spec/features/admin/translations_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

RSpec.feature 'Translations', :js do
RSpec.feature 'Admin translations', :js do
stub_authorization!

given!(:store) { create(:store) }
Expand Down Expand Up @@ -53,4 +53,15 @@
end
end
end

context 'solidus_auth_devise pages translation' do
background do
store.update_attributes(preferred_available_locales: [:en, :it])
end

scenario 'the login page is translated' do
visit spree.admin_login_path(locale: "it")
expect(page).to have_content(/#{Spree.t(:admin_login, locale: :it)}/i)
end
end
end
28 changes: 26 additions & 2 deletions spec/features/translations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

require 'spec_helper'

RSpec.feature 'Translations', :js do
RSpec.feature 'Frontend translations', :js do
given(:language) { Spree.t(:this_file_language, scope: 'i18n', locale: 'pt-BR') }
given(:store) { create(:store) }

background do
reset_spree_preferences
store.update_attributes(preferred_available_locales: %i[en pt-BR])
store.update_attributes(preferred_available_locales: %i[en pt-BR it])
end

context 'page' do
Expand All @@ -27,4 +27,28 @@
end
end
end

context 'solidus_auth_devise pages translation' do
let(:locale) { :it }

scenario 'the login page is translated' do
visit spree.login_path(locale: locale)
expect(page).to have_content(/#{Spree.t(:login_as_existing, locale: locale)}/i)
end

scenario 'the signup page is translated' do
visit spree.signup_path(locale: locale)
expect(page).to have_content(/#{Spree.t(:new_customer, locale: locale)}/i)
end

scenario 'the forgot password page is translated' do
visit spree.recover_password_path(locale: locale)
expect(page).to have_content(/#{Spree.t(:forgot_password, locale: locale)}/i)
end

scenario 'the change password page is translated' do
visit spree.edit_password_path(locale: locale, reset_password_token: "123")
expect(page).to have_content(/#{Spree.t(:change_my_password, locale: locale)}/i)
end
end
end
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
config.expect_with :rspec do |expectations|
expectations.syntax = :expect
end

config.include Devise::Test::ControllerHelpers, type: :controller
end

Dir[File.join(File.dirname(__FILE__), '/support/**/*.rb')].each { |file| require file }