solidus_i18n 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,4 +3,8 @@ Spree::Core::Engine.routes.draw do
3
3
  filter :locale
4
4
 
5
5
  post '/locale/set', to: 'locale#set', defaults: { format: :json }, as: :set_locale
6
+
7
+ namespace :admin do
8
+ resource :locale, only: [:show, :update]
9
+ end
6
10
  end
@@ -1,4 +1,4 @@
1
- class RemoveTranslationsFromSpreeTables < ActiveRecord::Migration
1
+ class RemoveTranslationsFromSpreeTables < SolidusSupport::Migration[4.2]
2
2
  def up
3
3
  # Don't migrate if we still use Globalize, i.e. through spree_globalize Gem
4
4
  return if defined?(Globalize)
@@ -1,7 +1,8 @@
1
1
  require 'rails-i18n'
2
2
  require 'solidus_core'
3
+ require 'solidus_support'
3
4
  require 'solidus_i18n/engine'
5
+ require 'solidus_i18n/locale'
4
6
  require 'solidus_i18n/version'
5
- require 'solidus_i18n/utils'
6
7
  require 'coffee_script'
7
8
  require 'deface'
@@ -6,7 +6,7 @@ module SolidusI18n
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
- prepend_before_filter :set_user_language
9
+ prepend_before_action :set_user_language
10
10
 
11
11
  private
12
12
 
@@ -9,7 +9,7 @@ module SolidusI18n
9
9
 
10
10
  module VERSION
11
11
  MAJOR = 1
12
- MINOR = 1
12
+ MINOR = 2
13
13
  TINY = 0
14
14
  PRE = nil
15
15
 
@@ -24,16 +24,17 @@ Gem::Specification.new do |s|
24
24
  s.has_rdoc = false
25
25
 
26
26
  s.add_runtime_dependency 'i18n_data', '~> 0.7.0'
27
- s.add_runtime_dependency 'rails-i18n', '~> 4.0.1'
27
+ s.add_runtime_dependency 'rails-i18n', ['>= 4.0.1', '< 6']
28
28
  s.add_runtime_dependency 'kaminari-i18n', '~> 0.3.2'
29
29
  s.add_runtime_dependency 'routing-filter', '~> 0.6.0'
30
30
  s.add_runtime_dependency 'solidus_core', ['>= 1.1', '< 3']
31
+ s.add_runtime_dependency 'solidus_support'
31
32
  s.add_runtime_dependency 'deface', '~> 1.0'
32
33
 
33
34
  s.add_development_dependency 'byebug'
34
35
  s.add_development_dependency 'capybara', '~> 2.4.4'
35
36
  s.add_development_dependency 'database_cleaner', '~> 1.3'
36
- s.add_development_dependency 'factory_girl', '~> 4.5'
37
+ s.add_development_dependency 'factory_bot', '~> 4.5'
37
38
  s.add_development_dependency 'ffaker', '>= 1.25.0'
38
39
  s.add_development_dependency 'poltergeist', '~> 1.5'
39
40
  s.add_development_dependency 'pry-rails', '>= 0.3.0'
@@ -10,14 +10,14 @@ RSpec.describe Spree::HomeController, type: :controller do
10
10
 
11
11
  context 'tries not supported fr locale' do
12
12
  it 'falls back do default locale' do
13
- get :index, locale: 'fr'
13
+ get :index, params: { locale: 'fr' }
14
14
  expect(I18n.locale).to eq :en
15
15
  end
16
16
  end
17
17
 
18
18
  context 'tries supported es locale' do
19
19
  it 'takes this locale' do
20
- get :index, locale: 'es'
20
+ get :index, params: { locale: 'es' }
21
21
  expect(I18n.locale).to eq :es
22
22
  end
23
23
  end
@@ -16,6 +16,7 @@ RSpec.feature 'Translations', :js do
16
16
  background do
17
17
  SolidusI18n::Config.available_locales = []
18
18
  visit spree.edit_admin_general_settings_path
19
+ click_on "Locales"
19
20
  end
20
21
 
21
22
  scenario 'adds german to available locales' do
@@ -1,5 +1,5 @@
1
- require 'factory_girl'
1
+ require 'factory_bot'
2
2
 
3
3
  RSpec.configure do |config|
4
- config.include FactoryGirl::Syntax::Methods
4
+ config.include FactoryBot::Syntax::Methods
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-06 00:00:00.000000000 Z
11
+ date: 2018-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n_data
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: rails-i18n
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 4.0.1
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '6'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: 4.0.1
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '6'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: kaminari-i18n
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +92,20 @@ dependencies:
86
92
  - - "<"
87
93
  - !ruby/object:Gem::Version
88
94
  version: '3'
95
+ - !ruby/object:Gem::Dependency
96
+ name: solidus_support
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
89
109
  - !ruby/object:Gem::Dependency
90
110
  name: deface
91
111
  requirement: !ruby/object:Gem::Requirement
@@ -143,7 +163,7 @@ dependencies:
143
163
  - !ruby/object:Gem::Version
144
164
  version: '1.3'
145
165
  - !ruby/object:Gem::Dependency
146
- name: factory_girl
166
+ name: factory_bot
147
167
  requirement: !ruby/object:Gem::Requirement
148
168
  requirements:
149
169
  - - "~>"
@@ -261,13 +281,14 @@ files:
261
281
  - app/assets/javascripts/spree/frontend/solidus_i18n.js
262
282
  - app/assets/stylesheets/spree/backend/solidus_i18n.css
263
283
  - app/assets/stylesheets/spree/frontend/solidus_i18n.css
264
- - app/controllers/spree/admin/general_settings_controller_decorator.rb
284
+ - app/controllers/spree/admin/locales_controller.rb
265
285
  - app/controllers/spree/api/base_controller_decorator.rb
266
286
  - app/controllers/spree/base_controller_decorator.rb
267
287
  - app/controllers/spree/locale_controller_decorator.rb
268
288
  - app/helpers/solidus_i18n/locale_helper.rb
269
- - app/overrides/spree/admin/general_settings/edit/localization_settings.html.erb.deface
289
+ - app/overrides/spree/admin/shared/_configuration_menu/add_i18n_tab.html.erb.deface
270
290
  - app/overrides/spree/shared/_main_nav_bar/locale_selector.html.erb.deface
291
+ - app/views/spree/admin/locales/show.html.erb
271
292
  - bin/rails
272
293
  - config/initializers/country_names.rb
273
294
  - config/initializers/routing_filter.rb
@@ -318,7 +339,6 @@ files:
318
339
  - lib/solidus_i18n/controller_locale_helper.rb
319
340
  - lib/solidus_i18n/engine.rb
320
341
  - lib/solidus_i18n/locale.rb
321
- - lib/solidus_i18n/utils.rb
322
342
  - lib/solidus_i18n/version.rb
323
343
  - lib/tasks/solidus_i18n/upgrade.rake
324
344
  - solidus_i18n.gemspec
@@ -354,7 +374,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
354
374
  requirements:
355
375
  - none
356
376
  rubyforge_project:
357
- rubygems_version: 2.6.8
377
+ rubygems_version: 2.7.3
358
378
  signing_key:
359
379
  specification_version: 4
360
380
  summary: Provides locale information for use in Solidus.
@@ -1,12 +0,0 @@
1
- Spree::Admin::GeneralSettingsController.class_eval do
2
- before_filter :update_i18n_settings, only: :update
3
-
4
- private
5
-
6
- def update_i18n_settings
7
- params.each do |name, value|
8
- next unless SolidusI18n::Config.has_preference? name
9
- SolidusI18n::Config[name] = value.map(&:to_sym)
10
- end
11
- end
12
- end
@@ -1,20 +0,0 @@
1
- <!-- insert_after '[data-hook=admin_general_setting_mail_from_address]'-->
2
- <div class="panel panel-default panel-localization">
3
- <div class="panel-heading">
4
- <h1 class="panel-title">
5
- <%= Spree.t(:'i18n.localization_settings') %>
6
- </h1>
7
- </div>
8
-
9
- <div class="panel-body" data-hook="localization_settings_body">
10
- <div class="form-group">
11
- <label for="available_locales_">
12
- <%= Spree.t(:'i18n.available_locales') %>
13
- </label>
14
- <%= select_available_locales %>
15
- <p class="help-block">
16
- <%= Spree.t(:'i18n.locales_displayed_on_frontend_select_box') %>
17
- </p>
18
- </div>
19
- </div>
20
- </div>
@@ -1,56 +0,0 @@
1
- require 'active_support/core_ext'
2
-
3
- module SolidusI18n
4
- module Utils
5
- # Retrieve comments, translation data in hash form
6
- def read_file(filename, basename)
7
- # Add error checking for failed file read?
8
- (comments, data) = IO.read(filename).split(/#{basename}:\s*\n/)
9
- return comments, create_hash(data)
10
- end
11
- module_function :read_file
12
-
13
- # Creates hash of translation data
14
- def create_hash(data)
15
- words = {}
16
- return words unless data
17
- parent = []
18
- previous_key = 'base'
19
- data.split("\n").each do |w|
20
- next if w.strip.blank? || w.strip[0] == '#'
21
- (key, value) = w.split(':', 2)
22
- value ||= ''
23
- # Determine level of current key in comparison to parent array
24
- shift = (key =~ /\w/) / 2 - parent.size
25
- key = key.sub(/^\s+/, '')
26
- # If key is child of previous key, add previous key as parent
27
- parent << previous_key if shift > 0
28
- # If key is not related to previous key, remove parent keys
29
- (shift*-1).times { parent.pop } if shift < 0
30
- # Track key in case next key is child of this key
31
- previous_key = key
32
- words[parent.join(':') + ':' + key] = value
33
- end
34
- words
35
- end
36
- module_function :create_hash
37
-
38
- # Writes to file from translation data hash structure
39
- def write_file(filename, basename, _comments, words, comment_values = true, _fallback_values = {})
40
- File.open(filename, 'w') do |log|
41
- log.puts(basename + ": \n")
42
- words.sort.each do |k, v|
43
- keys = k.split(':')
44
- # Add indentation for children keys
45
- (keys.size - 1).times do
46
- keys[keys.size - 1] = ' ' + keys[keys.size - 1]
47
- end
48
- value = v.strip
49
- value = ('#' + value) if comment_values && !value.blank?
50
- log.puts "#{keys[keys.size - 1]}: #{value}\n"
51
- end
52
- end
53
- end
54
- module_function :write_file
55
- end
56
- end