releaf-i18n_database 1.1.19 → 2.0.1

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/releaf_i18n_database_manifest.js +2 -0
  3. data/app/controllers/releaf/i18n_database/translations_controller.rb +1 -1
  4. data/app/lib/releaf/i18n_database/parse_spreadsheet_translations.rb +2 -2
  5. data/app/lib/releaf/i18n_database/translations_store.rb +1 -1
  6. data/app/lib/releaf/i18n_database/translations_utilities.rb +1 -1
  7. data/app/models/releaf/i18n_database/i18n_entry.rb +1 -1
  8. data/app/views/releaf/i18n_database/translations/_form_fields.haml +1 -1
  9. data/lib/releaf-i18n_database.rb +1 -1
  10. data/lib/releaf/i18n_database/engine.rb +2 -2
  11. metadata +17 -63
  12. data/spec/builders/translations/builder_common_spec.rb +0 -39
  13. data/spec/builders/translations/edit_builder_spec.rb +0 -93
  14. data/spec/builders/translations/index_builder_spec.rb +0 -96
  15. data/spec/builders/translations/table_builder_spec.rb +0 -68
  16. data/spec/controllers/i18n_backend/translations_controller_spec.rb +0 -148
  17. data/spec/features/translations_spec.rb +0 -426
  18. data/spec/fixtures/all_translations_exported.xlsx +0 -0
  19. data/spec/fixtures/invalid.xls +0 -3
  20. data/spec/fixtures/invalid.xlsx +0 -3
  21. data/spec/fixtures/time.formats.xlsx +0 -0
  22. data/spec/fixtures/translations_import.xlsx +0 -0
  23. data/spec/fixtures/unsupported_import_file.png +0 -0
  24. data/spec/lib/releaf/i18n_database/backend_spec.rb +0 -198
  25. data/spec/lib/releaf/i18n_database/configuration_spec.rb +0 -13
  26. data/spec/lib/releaf/i18n_database/humanize_missing_translations_spec.rb +0 -24
  27. data/spec/lib/releaf/i18n_database/parse_spreadsheet_translations_spec.rb +0 -151
  28. data/spec/lib/releaf/i18n_database/translations_store_spec.rb +0 -530
  29. data/spec/lib/releaf/i18n_database/translations_utilities_spec.rb +0 -175
  30. data/spec/models/i18n_database/i18n_entry_spec.rb +0 -50
  31. data/spec/models/i18n_database/i18n_entry_translation_spec.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99882449e7f18be42bd7a2973dc3cbe21178378a03c3dd040d83286b4e72e76d
4
- data.tar.gz: a6a0bd1208703a20215d9724036a975c9b3e8801ff12e09d0572b0e93005266a
3
+ metadata.gz: afc6d90826c0b3f735b41f966a7b8cc75534a2aaf48767d58e206827af9d518c
4
+ data.tar.gz: 6a77acd32a7f86f1e044816529b3a57ba284b8ffff18bf7af13358d8e4ff37a8
5
5
  SHA512:
6
- metadata.gz: 9501a91f46fe8a961be8e878809aa25a1c99fa4ea3ac1e89638dbda0c02b2d2781e43c88f7e14fd0f66eae250dc3e4a8fc3a97fb80ebed6205cc8d9d9d43f894
7
- data.tar.gz: 39ca3dcbb46ba37076685d5ffb14f4232244d995282fb745714f6de6da84a1cc0175ab3975e9062d78470b37bfef5e8105b548d24d4bc2eaa0e46d831335ed76
6
+ metadata.gz: c0c6ea46f74fe2de5bcf734a115af278fc0c7f4e52af3d640150a1801e6786a959ab71e9983d9b4d1ff189a4e900f3fc5c5c7daeb74a256b8ebd044fa055ef34
7
+ data.tar.gz: 4352e52cd0d81b365c6fdfedb2cbb7c3d8059a2ed9bf7932805f2025396e3a9407d5953f1fc46335ce181529bec8a7bf76017e2ff0c930889bd379f32a72d34f
@@ -0,0 +1,2 @@
1
+ //= link controllers/releaf/i18n_database/translations.css
2
+ //= link controllers/releaf/i18n_database/translations.js
@@ -152,7 +152,7 @@ class Releaf::I18nDatabase::TranslationsController < ::Releaf::ActionController
152
152
  end
153
153
 
154
154
  def export_file_name
155
- "#{Rails.application.class.parent_name.underscore}_translations_#{Time.now.strftime('%Y_%m_%d_%H_%M_%S')}.xlsx"
155
+ "#{Rails.application.class.module_parent_name.underscore}_translations_#{Time.now.strftime('%Y_%m_%d_%H_%M_%S')}.xlsx"
156
156
  end
157
157
 
158
158
  def import_file_path
@@ -34,8 +34,8 @@ module Releaf::I18nDatabase
34
34
  end
35
35
 
36
36
  def file_format_error?(error_class_name, error_message)
37
- return true if ['Zip::ZipError','Ole::Storage::FormatError' ].include?(error_class_name)
38
- error_class_name == 'ArgumentError' && error_message.match("Don't know how to open file").present?
37
+ return true if ['Zip::Error','Ole::Storage::FormatError' ].include?(error_class_name)
38
+ error_class_name == 'ArgumentError' && error_message.match("Can't detect the type").present?
39
39
  end
40
40
 
41
41
  def translations
@@ -68,7 +68,7 @@ class Releaf::I18nDatabase::TranslationsStore
68
68
  Releaf::I18nDatabase::I18nEntryTranslation
69
69
  .joins(:i18n_entry)
70
70
  .where.not(text: '')
71
- .pluck("CONCAT(locale, '.', releaf_i18n_entries.key) AS translation_key", "text")
71
+ .pluck(Arel.sql("CONCAT(locale, '.', releaf_i18n_entries.key) AS translation_key"), "text")
72
72
  .to_h
73
73
  end
74
74
 
@@ -13,7 +13,7 @@ module Releaf::I18nDatabase
13
13
  blank_where_collection = blank_where_collection.where(column.eq('').or(column.eq(nil)))
14
14
  end
15
15
 
16
- collection.where(blank_where_collection.where_values.reduce(:or))
16
+ collection.where(blank_where_collection.where_clause.send(:predicates).reduce(:or))
17
17
  end
18
18
 
19
19
  def self.filter_by_text(collection, lookup_string)
@@ -3,7 +3,7 @@ module Releaf::I18nDatabase
3
3
  self.table_name = "releaf_i18n_entries"
4
4
 
5
5
  validates_presence_of :key
6
- validates_uniqueness_of :key
6
+ validates_uniqueness_of :key, case_sensitive: true
7
7
  validates_length_of :key, maximum: 255
8
8
 
9
9
  has_many :i18n_entry_translation, dependent: :destroy,
@@ -14,7 +14,7 @@
14
14
  %input{type: "text", class: "text", name: "translations[][localizations][#{locale}]"}
15
15
  %td.delete-column.only-icon
16
16
  = releaf_button(nil, "times", class: %w(danger remove-nested-item), title: t("Remove", scope: controller_scope_name))
17
- %section.nested{data: {name: "translations", releaf: {template: html_escape(template_html)}}}
17
+ %section.nested{data: {name: "translations", releaf: {template: template_html.to_str}}}
18
18
  %table.table
19
19
  %thead
20
20
  %tr
@@ -1,4 +1,4 @@
1
- require 'axlsx_rails'
1
+ require 'caxlsx_rails'
2
2
  require 'i18n'
3
3
  require 'rails-i18n'
4
4
  require 'roo'
@@ -1,7 +1,7 @@
1
1
  module Releaf::I18nDatabase
2
2
  class Engine < ::Rails::Engine
3
- initializer 'precompile', group: :all do |app|
4
- app.config.assets.precompile += %w(controllers/releaf/i18n_database/*)
3
+ initializer 'releaf_i18n_database.assets_precompile', group: :all do |app|
4
+ app.config.assets.precompile << "releaf_i18n_database_manifest.js"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: releaf-i18n_database
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.19
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - CubeSystems
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-17 00:00:00.000000000 Z
11
+ date: 2020-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: releaf-core
@@ -16,48 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.19
19
+ version: 2.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.19
26
+ version: 2.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails-i18n
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 4.0.0
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 4.0.0
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: axlsx_rails
42
+ name: caxlsx_rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.3'
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: 0.3.0
47
+ version: '0.6'
51
48
  type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
52
  - - "~>"
56
53
  - !ruby/object:Gem::Version
57
- version: '0.3'
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: 0.3.0
54
+ version: '0.6'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: roo
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -79,6 +73,7 @@ extensions: []
79
73
  extra_rdoc_files: []
80
74
  files:
81
75
  - LICENSE
76
+ - app/assets/config/releaf_i18n_database_manifest.js
82
77
  - app/assets/javascripts/controllers/releaf/i18n_database/translations.js
83
78
  - app/assets/stylesheets/controllers/releaf/i18n_database/translations.scss
84
79
  - app/builders/releaf/i18n_database/translations/builders_common.rb
@@ -99,31 +94,11 @@ files:
99
94
  - lib/releaf/i18n_database/engine.rb
100
95
  - lib/releaf/i18n_database/humanize_missing_translations.rb
101
96
  - misc/translations.xlsx
102
- - spec/builders/translations/builder_common_spec.rb
103
- - spec/builders/translations/edit_builder_spec.rb
104
- - spec/builders/translations/index_builder_spec.rb
105
- - spec/builders/translations/table_builder_spec.rb
106
- - spec/controllers/i18n_backend/translations_controller_spec.rb
107
- - spec/features/translations_spec.rb
108
- - spec/fixtures/all_translations_exported.xlsx
109
- - spec/fixtures/invalid.xls
110
- - spec/fixtures/invalid.xlsx
111
- - spec/fixtures/time.formats.xlsx
112
- - spec/fixtures/translations_import.xlsx
113
- - spec/fixtures/unsupported_import_file.png
114
- - spec/lib/releaf/i18n_database/backend_spec.rb
115
- - spec/lib/releaf/i18n_database/configuration_spec.rb
116
- - spec/lib/releaf/i18n_database/humanize_missing_translations_spec.rb
117
- - spec/lib/releaf/i18n_database/parse_spreadsheet_translations_spec.rb
118
- - spec/lib/releaf/i18n_database/translations_store_spec.rb
119
- - spec/lib/releaf/i18n_database/translations_utilities_spec.rb
120
- - spec/models/i18n_database/i18n_entry_spec.rb
121
- - spec/models/i18n_database/i18n_entry_translation_spec.rb
122
97
  homepage: https://github.com/cubesystems/releaf
123
98
  licenses:
124
99
  - MIT
125
100
  metadata: {}
126
- post_install_message:
101
+ post_install_message:
127
102
  rdoc_options: []
128
103
  require_paths:
129
104
  - lib
@@ -138,29 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
113
  - !ruby/object:Gem::Version
139
114
  version: '0'
140
115
  requirements: []
141
- rubyforge_project:
142
- rubygems_version: 2.7.7
143
- signing_key:
116
+ rubygems_version: 3.0.8
117
+ signing_key:
144
118
  specification_version: 4
145
119
  summary: i18n database gem for releaf
146
- test_files:
147
- - spec/builders/translations/table_builder_spec.rb
148
- - spec/builders/translations/index_builder_spec.rb
149
- - spec/builders/translations/builder_common_spec.rb
150
- - spec/builders/translations/edit_builder_spec.rb
151
- - spec/features/translations_spec.rb
152
- - spec/models/i18n_database/i18n_entry_spec.rb
153
- - spec/models/i18n_database/i18n_entry_translation_spec.rb
154
- - spec/lib/releaf/i18n_database/translations_utilities_spec.rb
155
- - spec/lib/releaf/i18n_database/humanize_missing_translations_spec.rb
156
- - spec/lib/releaf/i18n_database/backend_spec.rb
157
- - spec/lib/releaf/i18n_database/configuration_spec.rb
158
- - spec/lib/releaf/i18n_database/translations_store_spec.rb
159
- - spec/lib/releaf/i18n_database/parse_spreadsheet_translations_spec.rb
160
- - spec/fixtures/all_translations_exported.xlsx
161
- - spec/fixtures/unsupported_import_file.png
162
- - spec/fixtures/time.formats.xlsx
163
- - spec/fixtures/translations_import.xlsx
164
- - spec/fixtures/invalid.xlsx
165
- - spec/fixtures/invalid.xls
166
- - spec/controllers/i18n_backend/translations_controller_spec.rb
120
+ test_files: []
@@ -1,39 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Releaf::I18nDatabase::Translations::BuildersCommon, type: :class do
4
- class I18nBuildersCommonInheriter < Releaf::Builders::IndexBuilder
5
- include Releaf::I18nDatabase::Translations::BuildersCommon
6
- end
7
- class TableBuilderTestHelper < ActionView::Base; end
8
- let(:template){ TableBuilderTestHelper.new }
9
- let(:subject){ I18nBuildersCommonInheriter.new(template) }
10
-
11
- describe "#action_url" do
12
- before do
13
- request = ActionDispatch::Request.new("X")
14
- allow(request).to receive(:query_parameters).and_return(a: "b", c: "d")
15
- allow(subject).to receive(:request).and_return(request)
16
- end
17
-
18
- it "returns url for given action with current query params" do
19
- allow(subject).to receive(:url_for).with(a: "b", c: "d", action: :edit).and_return("url")
20
- expect(subject.action_url(:edit)).to eq("url")
21
- end
22
-
23
- context "when extra params given" do
24
- it "merges given params to url" do
25
- allow(subject).to receive(:url_for).with(a: "b", c: "z", action: :edit, format: "xx").and_return("url")
26
- expect(subject.action_url(:edit, format: "xx", c: "z")).to eq("url")
27
- end
28
- end
29
- end
30
-
31
- describe "#export_button" do
32
- it "returns export button" do
33
- allow(subject).to receive(:t).with("Export").and_return("exp")
34
- allow(subject).to receive(:action_url).with(:export, format: :xlsx).and_return("_exp_url_")
35
- allow(subject).to receive(:button).with("exp", "download", class: "secondary", href: "_exp_url_").and_return("btn")
36
- expect(subject.export_button).to eq('btn')
37
- end
38
- end
39
- end
@@ -1,93 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Releaf::I18nDatabase::Translations::EditBuilder, type: :class do
4
- class TableBuilderTestHelper < ActionView::Base
5
- def protect_against_forgery?; end
6
- end
7
- let(:template){ TableBuilderTestHelper.new }
8
- let(:resource_class){ Releaf::I18nDatabase::Translation }
9
- let(:subject){ described_class.new(template) }
10
-
11
- describe "#section" do
12
- it "returns section blocks wrapped within edit form" do
13
- allow(subject).to receive(:action_url).with(:update).and_return("update_url")
14
- allow(subject).to receive(:section_blocks).and_return(["a", "b"])
15
- result = '<section><form action="update_url" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" />ab</form></section>'
16
- expect(subject.section).to eq(result)
17
- end
18
- end
19
-
20
- describe "#section_body" do
21
- it "returns section body with form fields partial" do
22
- allow(subject).to receive(:render).with(partial: "form_fields", locals: {builder: subject}).and_return("xxx")
23
- expect(subject.section_body).to eq('<div class="body">xxx</div>')
24
- end
25
- end
26
-
27
- describe "#import?" do
28
- it "returns template `import` value" do
29
- allow(subject).to receive(:template_variable).with("import").and_return("x")
30
- expect(subject.import?).to eq("x")
31
- end
32
- end
33
-
34
- describe "#save_button" do
35
- it "returns localized value for given resource and column(locale)" do
36
- allow(subject).to receive(:save_button_text).and_return("sv_txt")
37
- allow(subject).to receive(:button).with("sv_txt", "check", class: "primary", data: { type: 'ok' }, type: "submit").and_return("save_btn")
38
- expect(subject.save_button).to eq("save_btn")
39
- end
40
- end
41
-
42
- describe "#save_button_text" do
43
- context "when within import view" do
44
- it "returns translated `Import` text" do
45
- allow(subject).to receive(:t).with("Import").and_return("_import_")
46
- allow(subject).to receive(:import?).and_return(true)
47
- expect(subject.save_button_text).to eq("_import_")
48
- end
49
- end
50
-
51
- context "when not within import view" do
52
- it "returns translated `Save` text" do
53
- allow(subject).to receive(:t).with("Save").and_return("_save_")
54
- allow(subject).to receive(:import?).and_return(false)
55
- expect(subject.save_button_text).to eq("_save_")
56
- end
57
- end
58
- end
59
-
60
- describe "#footer_secondary_tools" do
61
- before do
62
- allow(subject).to receive(:back_to_index_button).and_return("indx_btn")
63
- allow(subject).to receive(:export_button).and_return("xprt_btn")
64
- end
65
-
66
- it "returns array with back and export links" do
67
- allow(subject).to receive(:import?).and_return(false)
68
- expect(subject.footer_secondary_tools).to eq(["indx_btn", "xprt_btn"])
69
- end
70
-
71
- context "when within import view" do
72
- it "does not incliude export button" do
73
- allow(subject).to receive(:import?).and_return(true)
74
- expect(subject.footer_secondary_tools).to eq(["indx_btn"])
75
- end
76
- end
77
- end
78
-
79
- describe "#back_to_index_button" do
80
- it "returns localized value for given resource and column(locale)" do
81
- allow(subject).to receive(:t).with("Back to list").and_return("back")
82
- allow(subject).to receive(:action_url).with(:index).and_return("index_path")
83
- allow(subject).to receive(:button).with("back", "caret-left", class: "secondary", href: "index_path").and_return("index_btn")
84
- expect(subject.back_to_index_button).to eq("index_btn")
85
- end
86
- end
87
-
88
- describe "#section_header" do
89
- it "returns nil" do
90
- expect(subject.section_header).to be nil
91
- end
92
- end
93
- end
@@ -1,96 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Releaf::I18nDatabase::Translations::IndexBuilder, type: :class do
4
- class IndexBuilderTestHelper < ActionView::Base
5
- include Releaf::ApplicationHelper
6
- delegate :resource_class, :table_options, to: :controller
7
-
8
- def protect_against_forgery?; end
9
-
10
- def controller
11
- @controller ||= begin
12
- c = Releaf::I18nDatabase::TranslationsController.new
13
- c.setup
14
- c
15
- end
16
- end
17
- end
18
- let(:template){ IndexBuilderTestHelper.new }
19
- let(:resource_class){ Releaf::I18nDatabase::Translation }
20
- let(:subject){ described_class.new(template) }
21
-
22
- describe "#text_search_content" do
23
- it "adds blank translation checbox to text search" do
24
- allow(subject).to receive(:t).and_return("search")
25
- allow(subject).to receive(:params).and_return(search: "xx")
26
- allow(subject).to receive(:button).and_return("btn")
27
- allow(subject).to receive(:search_only_blank_ui).and_return("_blank_ui_")
28
- expect(subject.text_search_content).to start_with("_blank_ui_")
29
- end
30
- end
31
-
32
- describe "#search_only_blank_ui" do
33
- before do
34
- allow(subject).to receive(:t).with("Only blank").and_return("trnls")
35
- end
36
-
37
- it "returns only blank translation search ui" do
38
- allow(subject).to receive(:params).and_return(search: "xx")
39
- expect(subject.search_only_blank_ui).to match_html(%Q[
40
- <div class="search-field" data-name="only-blank">
41
- <input type="checkbox" name="only_blank" id="only_blank" value="true" />
42
- <label for="only_blank">trnls</label>
43
- </div>
44
- ])
45
- end
46
-
47
- it "reflects `only_blank` params to checkbox state" do
48
- allow(subject).to receive(:params).and_return(only_blank: "1", search: true)
49
- expect(subject.search_only_blank_ui).to match_html(%Q[
50
- <div class="search-field" data-name="only-blank">
51
- <input type="checkbox" name="only_blank" id="only_blank" value="true" checked="checked" />
52
- <label for=\"only_blank\">trnls</label>
53
- </div>
54
- ])
55
- end
56
- end
57
-
58
- describe "#footer_primary_tools" do
59
- it "returns array with edit button" do
60
- allow(subject).to receive(:edit_button).and_return("btn")
61
- expect(subject.footer_primary_tools).to eq(["btn"])
62
- end
63
- end
64
-
65
- describe "#footer_secondary_tools" do
66
- it "returns array with edit button" do
67
- allow(subject).to receive(:export_button).and_return("a")
68
- allow(subject).to receive(:import_button).and_return("b")
69
- allow(subject).to receive(:import_form).and_return("c")
70
- expect(subject.footer_secondary_tools).to eq(["a", "b", "c"])
71
- end
72
- end
73
-
74
- describe "#import_form" do
75
- it "returns import form" do
76
- allow(subject).to receive(:url_for).with(action: 'import').and_return("import_url")
77
- result = "<form class=\"import\" enctype=\"multipart/form-data\" action=\"import_url\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"file\" name=\"import_file\" id=\"import_file\" /></form>"
78
- expect(subject.import_form).to eq(result)
79
- end
80
- end
81
-
82
- describe "#edit_button" do
83
- it "return edit button" do
84
- allow(subject).to receive(:t).with("Edit").and_return("edt")
85
- allow(subject).to receive(:action_url).with(:edit).and_return("edt_url")
86
- allow(subject).to receive(:button).with("edt", "edit", class: "primary", href: "edt_url").and_return("edt_btn")
87
- expect(subject.edit_button).to eq("edt_btn")
88
- end
89
- end
90
-
91
- describe "#text_search_available?" do
92
- it "return true" do
93
- expect(subject.text_search_available?).to be true
94
- end
95
- end
96
- end