solidus_i18n 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +35 -50
- data/config/routes.rb +0 -14
- data/lib/solidus_i18n.rb +0 -5
- data/lib/solidus_i18n/engine.rb +0 -39
- data/lib/solidus_i18n/version.rb +2 -2
- data/solidus_i18n.gemspec +0 -13
- data/spec/{lib/solidus_i18n/locale_spec.rb → solidus_i18n_spec.rb} +16 -4
- data/spec/spec_helper.rb +0 -1
- metadata +3 -242
- data/app/assets/javascripts/spree/backend/edit_inline_locales.js.coffee.erb +0 -56
- data/app/assets/javascripts/spree/backend/helpers.js.coffee.erb +0 -14
- data/app/assets/javascripts/spree/backend/inline_table_locales.js.coffee +0 -16
- data/app/assets/javascripts/spree/backend/solidus_i18n.js +0 -2
- data/app/assets/javascripts/spree/backend/templates/available_locales.hbs.erb +0 -31
- data/app/assets/javascripts/spree/backend/translations.js.coffee +0 -3
- data/app/assets/javascripts/spree/frontend/locale.js.coffee +0 -3
- data/app/assets/javascripts/spree/frontend/solidus_i18n.js +0 -2
- data/app/assets/stylesheets/spree/backend/solidus_i18n.css +0 -8
- data/app/assets/stylesheets/spree/frontend/solidus_i18n.css +0 -8
- data/app/controllers/spree/admin/locales_controller.rb +0 -16
- data/app/controllers/spree/api/available_locales_controller.rb +0 -28
- data/app/controllers/spree/api/base_controller_decorator.rb +0 -3
- data/app/controllers/spree/base_controller_decorator.rb +0 -3
- data/app/controllers/spree/locale_controller_decorator.rb +0 -5
- data/app/helpers/solidus_i18n/locale_helper.rb +0 -29
- data/app/models/spree/store_decorator.rb +0 -13
- data/app/overrides/spree/admin/shared/_configuration_menu/add_i18n_tab.html.erb.deface +0 -2
- data/app/overrides/spree/shared/_main_nav_bar/locale_selector.html.erb.deface +0 -16
- data/app/views/spree/admin/locales/show.html.erb +0 -21
- data/app/views/spree/api/available_locales/show.json.jbuilder +0 -8
- data/config/initializers/country_names.rb +0 -51
- data/config/initializers/routing_filter.rb +0 -2
- data/db/migrate/20150609154031_remove_translations_from_spree_tables.rb +0 -65
- data/db/migrate/20170523151209_add_available_locales_on_store.rb +0 -14
- data/lib/generators/solidus_i18n/install/install_generator.rb +0 -27
- data/lib/solidus_i18n/configuration.rb +0 -9
- data/lib/solidus_i18n/controller_locale_helper.rb +0 -29
- data/lib/solidus_i18n/locale.rb +0 -9
- data/spec/controllers/locales_controller_spec.rb +0 -25
- data/spec/features/admin/translations_spec.rb +0 -56
- data/spec/features/russian_errors_translation_spec.rb +0 -17
- data/spec/features/translation_spec.rb +0 -31
- data/spec/features/translations_spec.rb +0 -30
- data/spec/helpers/locale_helper_spec.rb +0 -35
- data/spec/support/capybara.rb +0 -6
- data/spec/support/database_cleaner.rb +0 -23
- data/spec/support/factory_girl.rb +0 -5
- data/spec/support/i18n.rb +0 -5
- data/spec/support/spree.rb +0 -12
@@ -1,14 +0,0 @@
|
|
1
|
-
class AddAvailableLocalesOnStore < SolidusSupport::Migration[4.2]
|
2
|
-
def change
|
3
|
-
add_column :spree_stores, :preferences, :text
|
4
|
-
|
5
|
-
reversible do |dir|
|
6
|
-
dir.up do
|
7
|
-
Spree::Store.reset_column_information
|
8
|
-
Spree::Store.all.each do |store|
|
9
|
-
store.update_attributes(preferred_available_locales: SolidusI18n::Config.available_locales)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module SolidusI18n
|
2
|
-
module Generators
|
3
|
-
class InstallGenerator < Rails::Generators::Base
|
4
|
-
class_option :auto_run_migrations, type: :boolean, default: true
|
5
|
-
|
6
|
-
def add_javascripts
|
7
|
-
append_file 'vendor/assets/javascripts/spree/backend/all.js',
|
8
|
-
"//= require spree/backend/solidus_i18n\n"
|
9
|
-
append_file 'vendor/assets/javascripts/spree/frontend/all.js',
|
10
|
-
"//= require spree/frontend/solidus_i18n\n"
|
11
|
-
end
|
12
|
-
|
13
|
-
def add_migrations
|
14
|
-
run 'bin/rake solidus_i18n:install:migrations'
|
15
|
-
end
|
16
|
-
|
17
|
-
def run_migrations
|
18
|
-
if options[:auto_run_migrations] ||
|
19
|
-
['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
|
20
|
-
run 'bin/rake db:migrate'
|
21
|
-
else
|
22
|
-
puts "Skiping rake db:migrate, don't forget to run it!"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module SolidusI18n
|
2
|
-
# The fact this logic is in a single module also helps to apply a custom
|
3
|
-
# locale on the spree/api context since api base controller inherits from
|
4
|
-
# MetalController instead of Spree::BaseController
|
5
|
-
module ControllerLocaleHelper
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
included do
|
9
|
-
prepend_before_action :set_user_language
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
# Overrides the Spree::Core::ControllerHelpers::Common logic so that only
|
14
|
-
# supported locales defined by SolidusI18n::Config.supported_locales can
|
15
|
-
# actually be set
|
16
|
-
def set_user_language
|
17
|
-
# params[:locale] can be added by routing-filter gem
|
18
|
-
I18n.locale = \
|
19
|
-
if params[:locale] && current_store.preferred_available_locales.include?(params[:locale].to_sym)
|
20
|
-
params[:locale]
|
21
|
-
elsif respond_to?(:config_locale, true) && !config_locale.blank?
|
22
|
-
config_locale
|
23
|
-
else
|
24
|
-
Rails.application.config.i18n.default_locale || I18n.default_locale
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/solidus_i18n/locale.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Spree::HomeController, type: :controller do
|
4
|
-
let(:store) { create(:store) }
|
5
|
-
routes { Spree::Core::Engine.routes }
|
6
|
-
|
7
|
-
before do
|
8
|
-
reset_spree_preferences
|
9
|
-
store.update_attributes(preferred_available_locales: %i[en es])
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'tries not supported fr locale' do
|
13
|
-
it 'falls back do default locale' do
|
14
|
-
get :index, params: { locale: 'fr' }
|
15
|
-
expect(I18n.locale).to eq :en
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'tries supported es locale' do
|
20
|
-
it 'takes this locale' do
|
21
|
-
get :index, params: { locale: 'es' }
|
22
|
-
expect(I18n.locale).to eq :es
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.feature 'Translations', :js do
|
4
|
-
stub_authorization!
|
5
|
-
|
6
|
-
given!(:store) { create(:store) }
|
7
|
-
|
8
|
-
background do
|
9
|
-
reset_spree_preferences
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'localization settings' do
|
13
|
-
given(:language) { Spree.t(:this_file_language, scope: 'i18n', locale: 'de') }
|
14
|
-
given(:french) { Spree.t(:this_file_language, scope: 'i18n', locale: 'fr') }
|
15
|
-
|
16
|
-
background do
|
17
|
-
visit spree.root_path
|
18
|
-
store.update_attributes(preferred_available_locales: [])
|
19
|
-
|
20
|
-
visit spree.edit_admin_general_settings_path
|
21
|
-
click_on 'Locales'
|
22
|
-
end
|
23
|
-
|
24
|
-
scenario 'adds german to available locales' do
|
25
|
-
within("#store-id-#{store.id}") do
|
26
|
-
expect(page).to_not have_content(language)
|
27
|
-
find('a[data-action="edit"]').click
|
28
|
-
|
29
|
-
targetted_select2_search(language, from: '.available-locales')
|
30
|
-
|
31
|
-
find('a[data-action="save"]').click
|
32
|
-
|
33
|
-
wait_for_ajax
|
34
|
-
|
35
|
-
expect(page).to have_content(language)
|
36
|
-
expect(store.reload.preferred_available_locales).to include(:de)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
scenario 'adds french to available locales' do
|
41
|
-
within("#store-id-#{store.id}") do
|
42
|
-
expect(page).to_not have_content(french)
|
43
|
-
find('a[data-action="edit"]').click
|
44
|
-
|
45
|
-
targetted_select2_search(french, from: '.available-locales')
|
46
|
-
|
47
|
-
find('a[data-action="save"]').click
|
48
|
-
|
49
|
-
wait_for_ajax
|
50
|
-
|
51
|
-
expect(page).to have_content(french)
|
52
|
-
expect(store.reload.preferred_available_locales).to include(:fr)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe 'Russian errors translations' do
|
5
|
-
def translation(count)
|
6
|
-
Spree.t(:errors_prohibited_this_record_from_being_saved, count: count)
|
7
|
-
end
|
8
|
-
|
9
|
-
context 'when current locale is Russian' do
|
10
|
-
it 'translation is available' do
|
11
|
-
I18n.locale = :ru
|
12
|
-
expect(translation(1)).to eq 'Одна ошибка не позволяет сохранить запись в базе'
|
13
|
-
expect(translation(3)).to eq '3 ошибки не позволяют сохранить запись в базе'
|
14
|
-
expect(translation(10)).to eq '10 ошибок не позволяют сохранить запись в базе'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe 'Translation' do
|
5
|
-
def translation
|
6
|
-
I18n.t('activerecord.attributes.spree/address.zipcode')
|
7
|
-
end
|
8
|
-
|
9
|
-
context 'when current locale is en' do
|
10
|
-
it 'translation is available' do
|
11
|
-
I18n.locale = :en
|
12
|
-
expect(translation).to eq 'Zip Code'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# German is chosen as an example of language whose translations are found in a file.
|
17
|
-
context 'when current locale is German' do
|
18
|
-
it 'translation is available' do
|
19
|
-
I18n.locale = :de
|
20
|
-
expect(translation).to eq 'PLZ'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Chilean spanish is chosen
|
25
|
-
context 'when current locale is Chilean Spanish' do
|
26
|
-
it 'translation is available' do
|
27
|
-
I18n.locale = :'es-CL'
|
28
|
-
expect(translation).to eq 'Código Postal'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.feature 'Translations', :js do
|
6
|
-
given(:language) { Spree.t(:this_file_language, scope: 'i18n', locale: 'pt-BR') }
|
7
|
-
given(:store) { create(:store) }
|
8
|
-
|
9
|
-
background do
|
10
|
-
reset_spree_preferences
|
11
|
-
store.update_attributes(preferred_available_locales: %i[en pt-BR])
|
12
|
-
end
|
13
|
-
|
14
|
-
context 'page' do
|
15
|
-
context 'switches locale from the dropdown' do
|
16
|
-
before do
|
17
|
-
visit spree.root_path
|
18
|
-
select(language, from: Spree.t(:language, scope: 'i18n'))
|
19
|
-
end
|
20
|
-
|
21
|
-
scenario 'selected translation is applied' do
|
22
|
-
expect(page).to have_content(/#{Spree.t(:home, locale: 'pt-BR')}/i)
|
23
|
-
end
|
24
|
-
|
25
|
-
scenario 'JS cart link is translated' do
|
26
|
-
expect(page).to have_content(/#{Spree.t(:cart, locale: 'pt-BR')}/i)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe SolidusI18n::LocaleHelper do
|
4
|
-
describe '#all_locales_options' do
|
5
|
-
subject { all_locales_options }
|
6
|
-
|
7
|
-
it 'includes en' do
|
8
|
-
is_expected.to include(["English (US)", :en])
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'includes ja' do
|
12
|
-
is_expected.to include(["日本語 (ja-JP)", :ja])
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'locales' do
|
16
|
-
subject { all_locales_options.map(&:last) }
|
17
|
-
|
18
|
-
it 'includes each locale only once' do
|
19
|
-
is_expected.to match_array(subject.uniq)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should match Locale.all' do
|
23
|
-
is_expected.to match_array SolidusI18n::Locale.all
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'locale presentation' do
|
28
|
-
subject { all_locales_options.map(&:first) }
|
29
|
-
|
30
|
-
it 'should all be unique' do
|
31
|
-
is_expected.to match_array(subject.uniq)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/spec/support/capybara.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'database_cleaner'
|
2
|
-
|
3
|
-
RSpec.configure do |config|
|
4
|
-
config.before(:suite) do
|
5
|
-
DatabaseCleaner.clean_with :truncation
|
6
|
-
end
|
7
|
-
|
8
|
-
config.before do
|
9
|
-
DatabaseCleaner.strategy = :transaction
|
10
|
-
end
|
11
|
-
|
12
|
-
config.before(:each, :js) do
|
13
|
-
DatabaseCleaner.strategy = :truncation
|
14
|
-
end
|
15
|
-
|
16
|
-
config.before do
|
17
|
-
DatabaseCleaner.start
|
18
|
-
end
|
19
|
-
|
20
|
-
config.after do
|
21
|
-
DatabaseCleaner.clean
|
22
|
-
end
|
23
|
-
end
|
data/spec/support/i18n.rb
DELETED
data/spec/support/spree.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'spree/testing_support/factories'
|
2
|
-
require 'spree/testing_support/preferences'
|
3
|
-
require 'spree/testing_support/url_helpers'
|
4
|
-
require 'spree/testing_support/capybara_ext'
|
5
|
-
require 'spree/testing_support/controller_requests'
|
6
|
-
require 'spree/testing_support/authorization_helpers'
|
7
|
-
|
8
|
-
RSpec.configure do |config|
|
9
|
-
config.include Spree::TestingSupport::UrlHelpers
|
10
|
-
config.include Spree::TestingSupport::Preferences
|
11
|
-
config.include Spree::TestingSupport::ControllerRequests, type: :controller
|
12
|
-
end
|