awesome_translations 0.0.57 → 0.0.61

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +1 -1
  3. data/app/controllers/awesome_translations/clean_ups_controller.rb +1 -1
  4. data/app/controllers/awesome_translations/groups_controller.rb +1 -0
  5. data/app/controllers/awesome_translations/handlers_controller.rb +1 -0
  6. data/app/helpers/awesome_translations/application_helper.rb +0 -1
  7. data/app/models/awesome_translations/group.rb +2 -2
  8. data/app/models/awesome_translations/translated_value.rb +6 -3
  9. data/app/models/awesome_translations/translation.rb +9 -4
  10. data/app/views/awesome_translations/duplicates/index.html.erb +2 -2
  11. data/app/views/awesome_translations/groups/show.html.erb +9 -4
  12. data/app/views/awesome_translations/handler_translations/index.html.erb +21 -6
  13. data/app/views/awesome_translations/handlers/show.html.erb +29 -6
  14. data/app/views/awesome_translations/movals/index.html.erb +2 -2
  15. data/lib/awesome_translations/cache_database_generator/group.rb +10 -3
  16. data/lib/awesome_translations/cache_database_generator/handler.rb +9 -2
  17. data/lib/awesome_translations/cache_database_generator/handler_translation.rb +13 -3
  18. data/lib/awesome_translations/cache_database_generator/translation_key.rb +4 -4
  19. data/lib/awesome_translations/cache_database_generator/translation_value.rb +3 -1
  20. data/lib/awesome_translations/cache_database_generator.rb +2 -2
  21. data/lib/awesome_translations/config.rb +3 -3
  22. data/lib/awesome_translations/controller_translate_functionality.rb +2 -2
  23. data/lib/awesome_translations/engine.rb +0 -4
  24. data/lib/awesome_translations/erb_inspector/file_inspector.rb +4 -4
  25. data/lib/awesome_translations/erb_inspector/translation_inspector.rb +8 -8
  26. data/lib/awesome_translations/erb_inspector.rb +1 -0
  27. data/lib/awesome_translations/global_translator.rb +14 -28
  28. data/lib/awesome_translations/handlers/file_handler.rb +1 -0
  29. data/lib/awesome_translations/handlers/model_handler.rb +1 -1
  30. data/lib/awesome_translations/handlers/validations_handler.rb +4 -4
  31. data/lib/awesome_translations/handlers.rb +1 -0
  32. data/lib/awesome_translations/model_inspector.rb +23 -17
  33. data/lib/awesome_translations/object_extensions.rb +2 -2
  34. data/lib/awesome_translations/translation_migrator.rb +3 -3
  35. data/lib/awesome_translations/version.rb +1 -1
  36. data/lib/awesome_translations.rb +1 -1
  37. data/lib/tasks/awesome_translations_tasks.rake +1 -4
  38. data/spec/controllers/groups_controller_spec.rb +5 -5
  39. data/spec/controllers/handlers_controller_spec.rb +4 -4
  40. data/spec/controllers/users_controller_spec.rb +4 -2
  41. data/spec/dummy/Rakefile +1 -1
  42. data/spec/dummy/app/assets/config/manifest.js +3 -0
  43. data/spec/dummy/app/controllers/application_controller.rb +3 -7
  44. data/spec/dummy/app/controllers/users_controller.rb +1 -1
  45. data/spec/dummy/app/mailers/my_mailer.rb +1 -1
  46. data/spec/dummy/app/models/application_record.rb +3 -0
  47. data/spec/dummy/app/models/role.rb +2 -5
  48. data/spec/dummy/app/models/user.rb +1 -1
  49. data/spec/dummy/bin/bundle +1 -1
  50. data/spec/dummy/bin/rails +1 -1
  51. data/spec/dummy/config/application.rb +7 -2
  52. data/spec/dummy/config/boot.rb +2 -2
  53. data/spec/dummy/config/environment.rb +1 -1
  54. data/spec/dummy/config.ru +1 -1
  55. data/spec/dummy/db/awesome_translations.sqlite3 +0 -0
  56. data/spec/dummy/db/development.sqlite3 +0 -0
  57. data/spec/dummy/db/test.sqlite3 +0 -0
  58. data/spec/dummy/log/development.log +52 -0
  59. data/spec/dummy/log/test.log +770 -0
  60. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/2m/2mnPY9uUnBNkGHLxtFaWv5hB3oA7sY2K1ZtwQlZLnAY.cache +2 -0
  61. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/3N/3NnKgR2TsTI1qCXKZpts0uJzp2dRJcoYp3nnFU6YE4o.cache +2 -0
  62. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/5r/5rpKlqLSFsRCibev7g6MQkIOhWuOah-1KAN3aqV_fYI.cache +0 -0
  63. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/6E/6ExTs_VkmUe-fovt99Kw8rq-xCfx0_qGsSoldSWScZI.cache +1 -0
  64. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8O/8OrG8phjC9s5-_7GAI2TEmRjsrGsuvq1gnJQPdMm8v8.cache +0 -0
  65. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8f/8f4REKYOWkNfHexyAVqGXnbOP3vky_ANapWzlRMDeQ4.cache +3 -0
  66. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8n/8n_viDw_qMQaQmqHM0ObPADed5uRyEYo3gDZIiTqUyA.cache +1 -0
  67. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/9e/9euY4B26kaHeiqfd1Qc0bsfRjpzmq36X6uqUfaRNtIs.cache +1 -0
  68. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/AB/AB5PxrhEqi8qOm7AmSf-sHDs9ffj_iTsytaHas2ryPA.cache +1 -0
  69. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/AI/AICJO1oM9dzlQ_N1QlHcCN9e8PC0wjtYk7-VmuNdfwg.cache +0 -0
  70. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ca/CaGQBiCuFgkHQ5gw8ZnGQqO8iP1md3GcllDsmaKBFdQ.cache +2 -0
  71. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ch/ChWez9UVXMuuBpLJMDRGuDmMuXy8gIuFo6794-wBgXc.cache +1 -0
  72. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/D9/D9eOwgl8pLlC7LJu-LL59UeHm9d-CH1mPgsA8j6xkMg.cache +1 -0
  73. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Do/Do83AoOat5W-c1g7piDGy2GMmffsY6JY0Qfuh5PY3GM.cache +2 -0
  74. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Hn/Hn53895nYKzu-g1FJKYS_yszYqCADXasTmN615R_qMQ.cache +1 -0
  75. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/It/ItV7jxV0bfHndR-H3cidDwpTFGhvs0ETLRqCTmZMXB8.cache +1 -0
  76. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/LL/LL0EenAcTXP-UNCqfcKtMF4Z8oDeWvdlwLQfuOVRPdw.cache +0 -0
  77. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Mj/MjwYGG9GkHD1fwwH2bg66EBYl3zCA_mqeDF9otey4-U.cache +3 -0
  78. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/NU/NUN9oO9gyoo-sY32AOLHdDACjLIxisCxXdKd84ou6cs.cache +2 -0
  79. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ob/ObuKkBd-camcT52YpgeuyheU-GDFLZCJnoVtq2plgW0.cache +0 -0
  80. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Og/Og_HPfE6734sqkQ0_h4EkOOx3Aoq1LABLH9ovjl6Bvw.cache +0 -0
  81. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Pw/Pwuhz_6So_JcSrxT0Uf4VaLhh_FFSJMKxLZFMbS0LNQ.cache +0 -0
  82. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/R-/R-nohuDiORrLlJJtKc5bQsjIRS8yTQFVR3EIxJx3JZw.cache +1 -0
  83. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/SX/SXA6qKBlsAQ-MLPi7-KPCPcSx9Gg2VR1xa-lCmgipgA.cache +1 -0
  84. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Sb/Sb1Vug319YfPL2Rci1PLMLXJjeIFYcNbHb5hKOvO1eo.cache +2 -0
  85. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/_f/_f0DjbdXTMEPb52THCCF5qbKkDs28tHHnap5ag4jsdU.cache +0 -0
  86. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/dT/dTb1O_9BwFdhA3VT1UTxY-XIIoAGDHGHVO9bzRUNIfc.cache +0 -0
  87. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/dV/dVTKOfd8qDIHT3VD-4emnl0yAIxcSF1pY0CUESPHwdM.cache +0 -0
  88. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/i0/i0TQIUsntlYrsibtn9YfB3qbI6bj8hLPom8KUfxR078.cache +1 -0
  89. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/jF/jFFXBsyFdv_TiNykX219AHs3Q7dQInYRP_80cAWZsgE.cache +0 -0
  90. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/mX/mXfx3VRudxpXrRx1aejtNA5YHOwND3kwWUfvdXHSors.cache +2 -0
  91. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/nG/nGQXdOLWsP4c926DJJBNXFUE0cKfZynnqN5aQ4T1I48.cache +1 -0
  92. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/oX/oXeqOS7RZb4eFbKrraeQtr6TUrXPTueLN_Crp7S0RLE.cache +1 -0
  93. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/p2/p27Ube4R6tciXRc0F8lpz6wUzmXIPxwqz7dKaUYVVuc.cache +1 -0
  94. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/pv/pv6tV3CDkIAmLXdU8EPLlNEkXAKJPufVD4VP30o4fWo.cache +2 -0
  95. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/q6/q6BYa32YJF11eGVapO4ouNl6gayPIsARgMavlzZmoi0.cache +2 -0
  96. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/r5/r5draRYO72lGMZZKpqYbscAWxAawJVG7uO0uyx3iw24.cache +1 -0
  97. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/r7/r7kGQJTsdrqs3i-prYAVnngsoc6uAtrjLTULTJdgy9g.cache +1 -0
  98. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/rI/rITk_65QtUwq61bjRPAksGeJxbLUFfz-sFPnQiZPHjw.cache +3 -0
  99. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/rR/rRS9OkVGJ9Wvs1fwZH-raqD4sXkbV8WmlLGIibYpZmI.cache +0 -0
  100. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/u9/u9nsXMBU9hA4UnH4SDHgk19ev_JNeeiS1-EZDrgStCI.cache +1 -0
  101. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/un/unZXcRqhGJwHvVWJmJ1rTizBZq6H5jF28E5-FHyTYL4.cache +1 -0
  102. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/wP/wP-1NwhQC0Sp_5PHpwAI7N0_N99vLNy0TA2FcMd6zgE.cache +0 -0
  103. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/x7/x7KkTV3ibfIEysLB_ug5bfmnn2VLV_BldukPR3EoPBk.cache +2 -0
  104. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/xr/xrDdkyCzfXr-pIE8gfvD8iFiWPuq9EwuZIl-uU9s0_o.cache +1 -0
  105. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/yc/yc3EXb1cvVLmwnk8aQN89bgVFeuwsVz2k2p0mvC2c3c.cache +1 -0
  106. data/spec/factories/group.rb +2 -2
  107. data/spec/factories/handler.rb +4 -4
  108. data/spec/factories/handler_translation.rb +5 -5
  109. data/spec/factories/translation_key.rb +1 -1
  110. data/spec/factories/translation_value.rb +3 -3
  111. data/spec/features/clean_ups_spec.rb +2 -5
  112. data/spec/features/duplicates_spec.rb +5 -7
  113. data/spec/features/movals_spec.rb +8 -10
  114. data/spec/handlers/file_handler_spec.rb +8 -8
  115. data/spec/handlers/model_handler_spec.rb +4 -4
  116. data/spec/handlers/validations_handler_spec.rb +3 -3
  117. data/spec/handlers_spec.rb +1 -1
  118. data/spec/lib/cache_database_generator_spec.rb +4 -4
  119. data/spec/lib/erb_inspector/file_inspector_spec.rb +2 -2
  120. data/spec/lib/erb_inspector/translation_inspector_spec.rb +2 -2
  121. data/spec/lib/erb_inspector_spec.rb +5 -5
  122. data/spec/lib/model_inspector_spec.rb +4 -4
  123. data/spec/lib/translation_migrator_spec.rb +3 -3
  124. data/spec/models/awesome_translations/handler_spec.rb +1 -1
  125. data/spec/models/awesome_translations/translated_value_spec.rb +1 -3
  126. data/spec/models/awesome_translations/translation_spec.rb +7 -2
  127. data/spec/spec_helper.rb +7 -8
  128. metadata +186 -101
  129. data/config/initializers/simple_form_ransack.rb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9b94ef91440571e20b5449c6ee2cbcde310a1a6f
4
- data.tar.gz: 1e7a3cbe89d9fe1b2a93d6368bcbdcf4f8ba4c6c
2
+ SHA256:
3
+ metadata.gz: 8982155c60a5db849fe01b8007859a18edf3efb1895417bfef73e4dd525a317e
4
+ data.tar.gz: 58e47453d01189a483d665074ab374e770dd8fd1d96878626bbae5de64bcb0a4
5
5
  SHA512:
6
- metadata.gz: e0178ff4789c64a1a567e2c1f19f3e658fe7654b12f3a7ce39b588e261116473892673bb0ecf5edb4b10d61d96a1315855391f8bc20ecb6aa4d2e0bc17d45234
7
- data.tar.gz: 48e1da2055e05f3d8052f831e07bce331e0b774fe9e7879381479bb9fa693d9985d953c873760ec36444c7f91dba59620f1fc6a8a0b9464f1b4e963a54f6c8df
6
+ metadata.gz: 87904a819f4834458e15cf6c0d470104e2dbb380d9a5cbef0b3d31eb560905b395c0ae0cc7e767f430819ce2766d661f9d2d347b7830397546ca1e89e47dba9f
7
+ data.tar.gz: 91964d3d6c9916fe493d596f554792e2fa29c6eed492546123fc9483cc0496d780d1d51d22adde6de5513c95da56e98c6f59f67e829f05fa388749a408f44579
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include("lib/**/*.rb")
15
15
  end
16
16
 
17
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
17
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
18
18
  load "rails/tasks/engine.rake"
19
19
 
20
20
 
@@ -26,7 +26,7 @@ private
26
26
  .joins(:translation_key)
27
27
  .includes(:translation_key)
28
28
  .joins("LEFT JOIN handler_translations ON handler_translations.translation_key_id = translation_keys.id")
29
- .where("handler_translations.id IS NULL")
29
+ .where(handler_translations: {id: nil})
30
30
  .where("translation_values.file_path LIKE '%/config/locales/awesome_translations/%'")
31
31
  end
32
32
  end
@@ -14,6 +14,7 @@ class AwesomeTranslations::GroupsController < AwesomeTranslations::ApplicationCo
14
14
  @group.handler_translations.each do |translation|
15
15
  values = values_from_translation(translation)
16
16
  next unless values
17
+
17
18
  save_values(translation, values)
18
19
  end
19
20
 
@@ -16,6 +16,7 @@ class AwesomeTranslations::HandlersController < AwesomeTranslations::Application
16
16
  generator = AwesomeTranslations::CacheDatabaseGenerator.current
17
17
  generator.update_handlers do |handler_model|
18
18
  next unless handler_model.identifier == @handler.identifier
19
+
19
20
  generator.update_groups_for_handler(handler_model)
20
21
  end
21
22
 
@@ -2,7 +2,6 @@ require "baza_models"
2
2
 
3
3
  module ::AwesomeTranslations::ApplicationHelper
4
4
  include BazaModels::Helpers::RansackerHelper
5
- include SimpleFormRansackHelper
6
5
 
7
6
  def flash_message_class(type)
8
7
  type = type.to_s
@@ -1,7 +1,7 @@
1
1
  class AwesomeTranslations::Group
2
2
  attr_reader :handler, :id, :data
3
3
 
4
- def self.find_by_handler_and_id(handler, id)
4
+ def self.find_by(handler:, id:)
5
5
  handler.groups.each do |group|
6
6
  return group if group.id == id.to_s
7
7
  end
@@ -13,7 +13,7 @@ class AwesomeTranslations::Group
13
13
  @handler = args.fetch(:handler)
14
14
  @id = args.fetch(:id)
15
15
  @data = args[:data] || {}
16
- raise "Invalid ID: #{@id}" unless @id.present?
16
+ raise "Invalid ID: #{@id}" if @id.blank?
17
17
  end
18
18
 
19
19
  def translations(args = {})
@@ -17,24 +17,27 @@ class AwesomeTranslations::TranslatedValue
17
17
  alias inspect to_s
18
18
 
19
19
  def array_translation?
20
- return true if @key =~ /\[(\d+)\]\Z/
20
+ return true if /\[(\d+)\]\Z/.match?(@key)
21
+
21
22
  false
22
23
  end
23
24
 
24
25
  def array_key
25
26
  return unless (match = @key.match(/\A(.+)\[(\d+)\]\Z/))
27
+
26
28
  match[1]
27
29
  end
28
30
 
29
31
  def array_no
30
32
  return unless (match = @key.match(/\A(.+)\[(\d+)\]\Z/))
33
+
31
34
  match[2].to_i
32
35
  end
33
36
 
34
37
  def save!
35
38
  dir = File.dirname(@file)
36
39
  FileUtils.mkdir_p(dir) unless File.exist?(dir)
37
- File.open(@file, "w") { |fp| fp.write("#{@locale}:\n") } unless File.exist?(@file)
40
+ File.write(@file, "#{@locale}:\n") unless File.exist?(@file)
38
41
 
39
42
  translations = YAML.safe_load(File.read(@file))
40
43
  translations ||= {}
@@ -45,7 +48,7 @@ class AwesomeTranslations::TranslatedValue
45
48
  update_models
46
49
 
47
50
  I18n.load_path << file unless I18n.load_path.include?(file)
48
- File.open(file, "w") { |fp| fp.write(YAML.dump(translations)) }
51
+ File.write(file, YAML.dump(translations))
49
52
  end
50
53
 
51
54
  private
@@ -11,7 +11,7 @@ class AwesomeTranslations::Translation
11
11
  @key_show = data[:key_show]
12
12
  @default = data[:default]
13
13
 
14
- raise "Dir wasn't valid: '#{@dir}'." unless @dir.present?
14
+ raise "Dir wasn't valid: '#{@dir}'." if @dir.blank?
15
15
  end
16
16
 
17
17
  def last_key
@@ -23,17 +23,20 @@ class AwesomeTranslations::Translation
23
23
  end
24
24
 
25
25
  def array_translation?
26
- return true if @key =~ /\[(\d+)\]\Z/
26
+ return true if /\[(\d+)\]\Z/.match?(@key)
27
+
27
28
  false
28
29
  end
29
30
 
30
31
  def array_key
31
32
  return unless (match = @key.match(/\A(.+)\[(\d+)\]\Z/))
33
+
32
34
  match[1]
33
35
  end
34
36
 
35
37
  def array_no
36
38
  return unless (match = @key.match(/\A(.+)\[(\d+)\]\Z/))
39
+
37
40
  match[2].to_i
38
41
  end
39
42
 
@@ -65,6 +68,7 @@ class AwesomeTranslations::Translation
65
68
  def finished?
66
69
  I18n.available_locales.each do |locale|
67
70
  next if value_for?(locale)
71
+
68
72
  return false
69
73
  end
70
74
 
@@ -94,14 +98,15 @@ class AwesomeTranslations::Translation
94
98
  return nil unless value_for?(locale)
95
99
 
96
100
  if array_translation?
97
- I18n.with_locale(locale) { I18n.t(array_key)[array_no] }
101
+ I18n.with_locale(locale) { I18n.t(array_key, default: [])[array_no] }
98
102
  else
99
- I18n.with_locale(locale) { I18n.t(@key) }
103
+ I18n.with_locale(locale) { I18n.t(@key, default: nil, fallback: false) }
100
104
  end
101
105
  end
102
106
 
103
107
  def file_line_content?
104
108
  return true if @full_path && @line_no && File.exist?(@full_path)
109
+
105
110
  false
106
111
  end
107
112
 
@@ -1,6 +1,6 @@
1
1
  <% content_for(:header_title) { "Duplicates" } %>
2
2
 
3
- <%= simple_form_for :duplicates do |f| %>
3
+ <%= form_tag do %>
4
4
  <% count = 0 %>
5
5
 
6
6
  <div class="panel panel-default">
@@ -46,7 +46,7 @@
46
46
  <% if count > 0 %>
47
47
  <div class="panel panel-default">
48
48
  <div class="panel-body">
49
- <%= f.button :submit, "Delete duplicates" %>
49
+ <input class="btn btn-primary" type="submit" value="Delete duplicates" />
50
50
  </div>
51
51
  </div>
52
52
  <% end %>
@@ -14,10 +14,15 @@
14
14
  </div>
15
15
  </div>
16
16
  <div class="panel-body">
17
- <%= simple_form_for :q, method: :get do |f| %>
18
- <%= f.input :translation_key_key_cont, label: "Key contains", input_html: {value: @ransack_params[:translation_key_key_cont]}, autofocus: true %>
19
- <%= f.button :submit, "Filter", class: ["btn", "btn-primary"] %>
20
- <% end %>
17
+ <form method="get">
18
+ <div class="form-group">
19
+ <label for="q_translation_key_key_cont">
20
+ Key contains
21
+ </label>
22
+ <input class="form-control" id="q_translation_key_key_cont" name="q[translation_key_key_cont]" value="<%= params.dig(:q, :translation_key_key_cont) %>" />
23
+ </div>
24
+ <input class="btn btn-primary" type="submit" value="filter" />
25
+ </form>
21
26
  </div>
22
27
  </div>
23
28
 
@@ -7,12 +7,27 @@
7
7
  </div>
8
8
  </div>
9
9
  <div class="panel-body">
10
- <%= simple_search_form_for @ransack do |f| %>
11
- <%= f.input :translation_key_key_cont, label: "Key", autofocus: true %>
12
- <%= f.input :handler_name_cont %>
13
- <%= f.input :group_name_cont %>
14
- <%= f.button :submit, "Filter", class: ["btn", "btn-primary"] %>
15
- <% end %>
10
+ <form method="get">
11
+ <div class="form-group">
12
+ <label for="q_translation_key_key_cont">
13
+ Key contains
14
+ </label>
15
+ <input class="form-control" id="q_translation_key_key_cont" name="q[translation_key_key_cont]" value="<%= params.dig(:q, :translation_key_key_cont) %>" />
16
+ </div>
17
+ <div class="form-group">
18
+ <label for="q_handler_name_cont">
19
+ Handler name contains
20
+ </label>
21
+ <input class="form-control" id="q_handler_name_cont" name="q[handler_name_cont]" value="<%= params.dig(:q, :handler_name_cont) %>" />
22
+ </div>
23
+ <div class="form-group">
24
+ <label for="q_group_name_cont">
25
+ Group name contains
26
+ </label>
27
+ <input class="form-control" id="q_group_name_cont" name="q[group_name_cont]" value="<%= params.dig(:q, :group_name_cont) %>" />
28
+ </div>
29
+ <input class="btn btn-primary" type="submit" value="Filter" />
30
+ </form>
16
31
  </div>
17
32
  </div>
18
33
 
@@ -14,20 +14,43 @@
14
14
  </div>
15
15
  </div>
16
16
  <div class="panel-body">
17
- <%= simple_search_form_for @ransack, url: @handler do |f| %>
17
+ <form method="get">
18
18
  <div class="row">
19
19
  <div class="col-md-4">
20
- <%= f.input :name_cont, autofocus: true %>
20
+ <div class="form-group">
21
+ <label for="q_name_cont">
22
+ Name contains
23
+ </label>
24
+ <input class="form-control" id="q_name_cont" name="q[name_cont]" type="text" value="<%= params.dig(:q, :name_cont) %>" />
25
+ </div>
21
26
  </div>
22
27
  <div class="col-md-4">
23
- <%= f.input :with_translations, label: "With translations", collection: with_translations_collection %>
28
+ <div class="form-group">
29
+ <label for="q_with_translations">
30
+ With translations
31
+ </label>
32
+ <select class="form-control" id="q_with_translations" name="q[with_translations]">
33
+ <option />
34
+ <%= options_for_select(with_translations_collection, params.dig(:q, :with_translations)) %>
35
+ </select>
36
+ </div>
24
37
  </div>
25
38
  <div class="col-md-4">
26
- <%= f.input :with_missing_translations, label: "Missing translations", collection: with_missing_translations_collection %>
39
+ <div class="form-group">
40
+ <label for="q_with_missing_translations">
41
+ Missing translations
42
+ </label>
43
+
44
+ <select class="form-control" name="q[with_missing_translations]" id="q_with_missing_translations">
45
+ <option />
46
+ <%= options_for_select(with_missing_translations_collection, params.dig(:q, :with_missing_translations)) %>
47
+ </select>
48
+ </div>
27
49
  </div>
28
50
  </div>
29
- <%= f.button :submit, "Filter", class: ["btn", "btn-primary"] %>
30
- <% end %>
51
+
52
+ <input class="btn btn-primary" value="Filter" type="submit" />
53
+ </form>
31
54
  </div>
32
55
  </div>
33
56
 
@@ -1,6 +1,6 @@
1
1
  <% content_for(:header_title) { "Movals" } %>
2
2
 
3
- <%= simple_form_for :movals do |f| %>
3
+ <%= form_tag do %>
4
4
  <% count = 0 %>
5
5
 
6
6
  <div class="panel panel-default">
@@ -46,7 +46,7 @@
46
46
  <% if count > 0 %>
47
47
  <div class="panel panel-default">
48
48
  <div class="panel-body">
49
- <%= f.button :submit, "Move" %>
49
+ <input class="btn btn-primary" type="submit" value="Move" />
50
50
  </div>
51
51
  </div>
52
52
  <% end %>
@@ -3,8 +3,15 @@ class AwesomeTranslations::CacheDatabaseGenerator::Group < BazaModels::Model
3
3
 
4
4
  belongs_to :handler, class_name: "AwesomeTranslations::CacheDatabaseGenerator::Handler"
5
5
 
6
- has_many :handler_translations, dependent: :destroy, foreign_key: "group_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation"
7
- has_many :translation_keys, dependent: :destroy, foreign_key: "group_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"
6
+ has_many :handler_translations,
7
+ dependent: :destroy,
8
+ foreign_key: "group_id", # rubocop:disable Rails/RedundantForeignKey
9
+ class_name: "AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation"
10
+
11
+ has_many :translation_keys,
12
+ dependent: :destroy,
13
+ foreign_key: "group_id", # rubocop:disable Rails/RedundantForeignKey
14
+ class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"
8
15
 
9
16
  validates_presence_of :name, :handler
10
17
 
@@ -13,7 +20,7 @@ class AwesomeTranslations::CacheDatabaseGenerator::Group < BazaModels::Model
13
20
  end
14
21
 
15
22
  def at_group
16
- @at_group ||= AwesomeTranslations::Group.find_by_handler_and_id(at_handler, identifier)
23
+ @at_group ||= AwesomeTranslations::Group.find_by(handler: at_handler, id: identifier)
17
24
  end
18
25
 
19
26
  def to_param
@@ -1,6 +1,13 @@
1
1
  class AwesomeTranslations::CacheDatabaseGenerator::Handler < BazaModels::Model
2
- has_many :groups, dependent: :destroy, foreign_key: "handler_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::Group"
3
- has_many :handler_translations, dependent: :destroy, foreign_key: "handler_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation"
2
+ has_many :groups,
3
+ dependent: :destroy,
4
+ foreign_key: "handler_id", # rubocop:disable Rails/RedundantForeignKey
5
+ class_name: "AwesomeTranslations::CacheDatabaseGenerator::Group"
6
+
7
+ has_many :handler_translations,
8
+ dependent: :destroy,
9
+ foreign_key: "handler_id", # rubocop:disable Rails/RedundantForeignKey
10
+ class_name: "AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation"
4
11
 
5
12
  validates_presence_of :name
6
13
 
@@ -1,7 +1,15 @@
1
1
  class AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation < BazaModels::Model
2
- belongs_to :group, foreign_key: "group_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::Group"
3
- belongs_to :handler, foreign_key: "handler_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::Handler"
4
- belongs_to :translation_key, foreign_key: "translation_key_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"
2
+ belongs_to :group,
3
+ foreign_key: "group_id", # rubocop:disable Rails/RedundantForeignKey
4
+ class_name: "AwesomeTranslations::CacheDatabaseGenerator::Group"
5
+
6
+ belongs_to :handler,
7
+ foreign_key: "handler_id", # rubocop:disable Rails/RedundantForeignKey
8
+ class_name: "AwesomeTranslations::CacheDatabaseGenerator::Handler"
9
+
10
+ belongs_to :translation_key,
11
+ foreign_key: "translation_key_id", # rubocop:disable Rails/RedundantForeignKey
12
+ class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"
5
13
 
6
14
  validates_presence_of :handler, :translation_key
7
15
 
@@ -34,11 +42,13 @@ class AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation < BazaMode
34
42
 
35
43
  def array_key
36
44
  return unless (match = key.match(/\A(.+)\[(\d+)\]\Z/))
45
+
37
46
  match[1]
38
47
  end
39
48
 
40
49
  def array_no
41
50
  return unless (match = key.match(/\A(.+)\[(\d+)\]\Z/))
51
+
42
52
  match[2].to_i
43
53
  end
44
54
  end
@@ -1,15 +1,15 @@
1
1
  class AwesomeTranslations::CacheDatabaseGenerator::TranslationKey < BazaModels::Model
2
- belongs_to :group, foreign_key: "group_id"
3
- belongs_to :handler, foreign_key: "handler_id"
2
+ belongs_to :group, foreign_key: "group_id" # rubocop:disable Rails/RedundantForeignKey
3
+ belongs_to :handler, foreign_key: "handler_id" # rubocop:disable Rails/RedundantForeignKey
4
4
 
5
5
  has_many :handler_translations,
6
6
  dependent: :destroy,
7
- foreign_key: "translation_key_id",
7
+ foreign_key: "translation_key_id", # rubocop:disable Rails/RedundantForeignKey
8
8
  class_name: "AwesomeTranslations::CacheDatabaseGenerator::HandlerTranslation"
9
9
 
10
10
  has_many :translation_values,
11
11
  dependent: :destroy,
12
- foreign_key: "translation_key_id",
12
+ foreign_key: "translation_key_id", # rubocop:disable Rails/RedundantForeignKey
13
13
  class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationValue"
14
14
 
15
15
  validates_presence_of :group, :handler
@@ -1,5 +1,7 @@
1
1
  class AwesomeTranslations::CacheDatabaseGenerator::TranslationValue < BazaModels::Model
2
- belongs_to :translation_key, foreign_key: "translation_key_id", class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"
2
+ belongs_to :translation_key,
3
+ foreign_key: "translation_key_id", # rubocop:disable Rails/RedundantForeignKey
4
+ class_name: "AwesomeTranslations::CacheDatabaseGenerator::TranslationKey"
3
5
 
4
6
  validates_presence_of :translation_key
5
7
 
@@ -74,7 +74,7 @@ class AwesomeTranslations::CacheDatabaseGenerator
74
74
  end
75
75
 
76
76
  def cache_yml_translations
77
- cache_translations_in_dir(Rails.root.join("config", "locales"))
77
+ cache_translations_in_dir(Rails.root.join("config/locales"))
78
78
  end
79
79
 
80
80
  def cache_handler_translations
@@ -86,7 +86,7 @@ class AwesomeTranslations::CacheDatabaseGenerator
86
86
  end
87
87
 
88
88
  def self.database_path
89
- @database_path ||= Rails.root.join("db", "awesome_translations.sqlite3").to_s
89
+ @database_path ||= Rails.root.join("db/awesome_translations.sqlite3").to_s
90
90
  end
91
91
 
92
92
  def database_path
@@ -4,10 +4,10 @@ class AwesomeTranslations::Config
4
4
  def initialize
5
5
  @ignored_paths = [
6
6
  Rails.root.join(".git").to_s,
7
- Rails.root.join("config", "locales").to_s,
7
+ Rails.root.join("config/locales").to_s,
8
8
  Rails.root.join("log").to_s,
9
- Rails.root.join("public", "packs-test").to_s,
10
- Rails.root.join("public", "packs").to_s,
9
+ Rails.root.join("public/packs-test").to_s,
10
+ Rails.root.join("public/packs").to_s,
11
11
  Rails.root.join("node_modules").to_s,
12
12
  Rails.root.join("tmp").to_s,
13
13
  Rails.root.join("storage").to_s,
@@ -7,8 +7,8 @@ module AwesomeTranslations::ControllerTranslateFunctionality
7
7
  end
8
8
 
9
9
  module Methods
10
- def controller_t(key, args = {}, &blk)
11
- AwesomeTranslations::GlobalTranslator.translate(key, translation_args: [args], caller_number: 1, action_in_key: false, &blk)
10
+ def controller_t(key, *args, **opts, &blk)
11
+ AwesomeTranslations::GlobalTranslator.translate(key, action_in_key: false, caller_number: 1, translation_args: args, translation_opts: opts, &blk)
12
12
  end
13
13
  end
14
14
  end
@@ -1,7 +1,3 @@
1
- require "sass-rails"
2
- require "simple_form"
3
- require "simple_form_ransack"
4
-
5
1
  module AwesomeTranslations; end
6
2
 
7
3
  class AwesomeTranslations::Engine < ::Rails::Engine
@@ -50,19 +50,19 @@ class AwesomeTranslations::ErbInspector::FileInspector
50
50
  private
51
51
 
52
52
  def parse_content_liquid(line_no, line, translations_found, yielder)
53
- line.scan(/\"([^\"]+?)\"\s+\|\s+t\s*(\%}|\}\}|\|)/) do |match|
53
+ line.scan(/"([^"]+?)"\s+\|\s+t\s*(%}|\}\}|\|)/) do |match|
54
54
  add_translation(line_no, "t", match[0], translations_found, yielder)
55
55
  end
56
56
 
57
- line.scan(/\'([^\']+?)\'\s+\|\s+t\s*(\%}|\}\}|\|)/) do |match|
57
+ line.scan(/'([^']+?)'\s+\|\s+t\s*(%}|\}\}|\|)/) do |match|
58
58
  add_translation(line_no, "t", match[0], translations_found, yielder)
59
59
  end
60
60
 
61
- line.scan(/\"([^\"]+?)\"\s+\|\s+val:\s*\"([^\"]+?)\"\s*,\s*(.+?)\s*\|\s+t\s*/) do |match|
61
+ line.scan(/"([^"]+?)"\s+\|\s+val:\s*"([^"]+?)"\s*,\s*(.+?)\s*\|\s+t\s*/) do |match|
62
62
  add_translation(line_no, "t", match[0], translations_found, yielder)
63
63
  end
64
64
 
65
- line.scan(/'([^\"]+?)'\s+\|\s+val:\s*'([^\"]+?)'\s*,\s*(.+?)\s*\|\s+t\s*/) do |match|
65
+ line.scan(/'([^"]+?)'\s+\|\s+val:\s*'([^"]+?)'\s*,\s*(.+?)\s*\|\s+t\s*/) do |match|
66
66
  add_translation(line_no, "t", match[0], translations_found, yielder)
67
67
  end
68
68
  end
@@ -27,7 +27,7 @@ class AwesomeTranslations::ErbInspector::TranslationInspector
27
27
  end
28
28
 
29
29
  def global?
30
- !relative? && !key.include?(".")
30
+ !relative? && key.exclude?(".")
31
31
  end
32
32
 
33
33
  def relative?
@@ -49,16 +49,16 @@ private
49
49
  is_mailer = true
50
50
  elsif @full_key.start_with?("app/views/")
51
51
  # Remove "app/views" from view-translations since that doesn't get used in keys.
52
- @full_key.gsub!(/\Aapp\/views\//, "")
52
+ @full_key.delete_prefix!("app/views/")
53
53
  elsif @full_key.start_with?("app/controllers")
54
54
  # Remove "app/controllers" from controller-translations since that doesn't get used in keys.
55
55
  @full_key.gsub!(/\Aapp\/controllers(\/?)/, "")
56
56
  is_controller = true
57
57
  elsif @full_key.start_with?("app/cells")
58
- @full_key.gsub!(/\Aapp\/cells\//, "")
58
+ @full_key.delete_prefix!("app/cells/")
59
59
  elsif @full_key.start_with?("app/")
60
60
  # Remove "app" from controller- and helper-translations since that doesn't get used.
61
- @full_key.gsub!(/\Aapp\//, "")
61
+ @full_key.delete_prefix!("app/")
62
62
  end
63
63
 
64
64
  @full_key.tr!("/", ".")
@@ -66,7 +66,7 @@ private
66
66
  @full_key << file_key(@file_path)
67
67
  @full_key << ".#{@last_method}" if (is_mailer || is_controller) && @last_method && @method != "controller_t"
68
68
  @full_key << "."
69
- @full_key << @key.gsub(/\A\./, "")
69
+ @full_key << @key.delete_prefix(".")
70
70
  elsif @method == "I18n-js.t" || @method == "t" || @method == "helper_t" || @method == "controller_t"
71
71
  @full_key = @key
72
72
  else
@@ -81,10 +81,10 @@ private
81
81
  key = key.match(/\A(.+?)\./)[1]
82
82
 
83
83
  # Remove leading "_" from partials
84
- key = key.gsub(/\A_/, "")
84
+ key.delete_prefix!("_")
85
85
 
86
86
  # Remove '_controller' from controllers
87
- key = key.gsub(/_controller\Z/, "")
87
+ key.delete_suffix!("_controller")
88
88
 
89
89
  key
90
90
  end
@@ -92,7 +92,7 @@ private
92
92
  def generate_dir
93
93
  parts = %w[config locales awesome_translations]
94
94
 
95
- key_parts = @full_key.split(".").reject(&:blank?)
95
+ key_parts = @full_key.split(".").compact_blank
96
96
  key_parts.pop
97
97
 
98
98
  @dir = Rails.root.join(*(parts + key_parts)).to_s
@@ -34,6 +34,7 @@ private
34
34
 
35
35
  Dir.foreach(full_path) do |file|
36
36
  next if file == "." || file == ".."
37
+
37
38
  file_path = path.clone
38
39
  file_path << "/" unless file_path.empty?
39
40
  file_path << file