awesome_translations 0.0.63 → 0.0.64

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9ed16ef4e8875b37a380944c539d17d07c53a1344aa7dad547ed883cc91bbdb
4
- data.tar.gz: f305b5327c5ac17fd9a2e3b0f5671badb9e2aa0e3c84c32813f7159682fc8387
3
+ metadata.gz: 62035170a703c453f82d55eae3b2703bc5d8e356568d47935f4cac04fbc253a0
4
+ data.tar.gz: 21e2067c0fd54de04c7cfbaeb5be1d0bb614ff1426ee3fa943a88840bfadd713
5
5
  SHA512:
6
- metadata.gz: cdc74dbb6c544e79bb8a4d4c029b6278301556d8199f6c7d62f1f8295209e649de17cd18aaefdf674589dcb537d68e46ed3eaddfd8c9d69b9aa335cfae7917a7
7
- data.tar.gz: 20385ca733b110411e364cfcbe475bbef097784c607496a714b4016f1a7e5b0b4e6b9a4b5f15693157c53db41d3904c5e5c72abf1bd72ed7f7307e8949996625
6
+ metadata.gz: af3499ac5a0426e95277ddcc395757fbfcb6a1616cd24a62178cd66996acaafbade9b5f134a56122322e1122a0cd92b809900498a4bbc2fa048db72c3fbb8e56
7
+ data.tar.gz: 49f979fd7db8e6316bd4ebe1535080725fd360f1e8fc25f13947c2e87475c8545c441139ecde536d2f214181795dd3aafe5218307e80c5fc814597be5e4cbc13
@@ -22,7 +22,7 @@ private
22
22
 
23
23
  helper_method :translations_to_clean_up
24
24
  def translations_to_clean_up
25
- @translations_to_migrate ||= AwesomeTranslations::CacheDatabaseGenerator::TranslationValue
25
+ @translations_to_clean_up ||= AwesomeTranslations::CacheDatabaseGenerator::TranslationValue
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")
@@ -11,7 +11,7 @@ class AwesomeTranslations::MovalsController < AwesomeTranslations::ApplicationCo
11
11
  end
12
12
 
13
13
  def create
14
- params[:m].each do |translation_value_id, _handler_translation_id|
14
+ params[:m].each_key do |translation_value_id|
15
15
  translation_value = AwesomeTranslations::CacheDatabaseGenerator::TranslationValue.find(translation_value_id)
16
16
  translation_value.migrate_to_awesome_translations_namespace!
17
17
  end
@@ -1,7 +1,8 @@
1
1
  class AwesomeTranslations::ErbInspector::FileInspector
2
- JS_FILE_EXTS = [".coffee", ".coffee.erb", ".es6", ".es6.erb", ".js", ".js.erb", ".jsx"].freeze
2
+ JS_FILE_EXTS = [".cjs", ".coffee", ".coffee.erb", ".es6", ".es6.erb", ".js", ".js.erb", ".jsx", ".mjs"].freeze
3
3
  METHOD_NAMES = %w[t controller_t helper_t].freeze
4
4
  VALID_BEGINNING = '(^|\s+|\(|\{|\[|<%=\s*|I18n\.)'.freeze
5
+ VALID_BEGINNING_JS = '(^|\s+|\(|\[|I18n\.)'.freeze
5
6
 
6
7
  attr_reader :root_path, :file_path
7
8
 
@@ -18,6 +19,7 @@ class AwesomeTranslations::ErbInspector::FileInspector
18
19
  extname = File.extname(full_path)
19
20
  translations_found = []
20
21
  line_no = 0
22
+ @namespace = nil
21
23
 
22
24
  fp.each_line do |line|
23
25
  line_no += 1
@@ -68,12 +70,16 @@ private
68
70
  end
69
71
 
70
72
  def parse_content_js(line_no, line, translations_found, yielder)
71
- line.scan(/I18n\.t\('(.+?)'\s*(\)|,)/) do |match|
72
- add_translation(line_no, "I18n-js.t", match[0], translations_found, yielder)
73
+ line.scan(/useI18n\(\s*\{\s*namespace:\s*"(.+)"/) do |match|
74
+ @namespace = match[0]
73
75
  end
74
76
 
75
- line.scan(/I18n\.t\("(.+?)"\s*(\)|,)/) do |match|
76
- add_translation(line_no, "I18n-js.t", match[0], translations_found, yielder)
77
+ line.scan(/#{VALID_BEGINNING_JS}t\('(.+?)'\s*(\)|,)/o) do |match|
78
+ add_translation(line_no, "I18n-js.t", match[1], translations_found, yielder)
79
+ end
80
+
81
+ line.scan(/#{VALID_BEGINNING_JS}t\("(.+?)"\s*(\)|,)/o) do |match|
82
+ add_translation(line_no, "I18n-js.t", match[1], translations_found, yielder)
77
83
  end
78
84
  end
79
85
 
@@ -103,6 +109,8 @@ private
103
109
  end
104
110
 
105
111
  def add_translation(line_no, method, key, translations_found, yielder)
112
+ key = "#{@namespace}#{key}" if key.start_with?(".") && @namespace
113
+
106
114
  translation_inspector = AwesomeTranslations::ErbInspector::TranslationInspector.new(
107
115
  last_method: @last_method,
108
116
  root_path: @root_path,
@@ -22,7 +22,7 @@ class AwesomeTranslations::Handlers::DeviseHandler < AwesomeTranslations::Handle
22
22
  def translations_for_group(group)
23
23
  ArrayEnumerator.new do |yielder|
24
24
  dir = Rails.root.join("config", "locales", "awesome_translations", group.id).to_s
25
- __send__("translations_for_#{group.id}", dir, group, yielder)
25
+ __send__(:"translations_for_#{group.id}", dir, group, yielder)
26
26
  end
27
27
  end
28
28
 
@@ -18,7 +18,7 @@ class AwesomeTranslations::Handlers::RailsHandler < AwesomeTranslations::Handler
18
18
  def translations_for_group(group)
19
19
  ArrayEnumerator.new do |yielder|
20
20
  dir = Rails.root.join("config", "locales", "awesome_translations", group.id).to_s
21
- __send__("translations_for_#{group.id}", dir, group, yielder)
21
+ __send__(:"translations_for_#{group.id}", dir, group, yielder)
22
22
  end
23
23
  end
24
24
 
@@ -22,7 +22,7 @@ class AwesomeTranslations::Handlers::WillPaginateHandler < AwesomeTranslations::
22
22
  def translations_for_group(group)
23
23
  ArrayEnumerator.new do |yielder|
24
24
  dir = Rails.root.join("config", "locales", "awesome_translations", group.id).to_s
25
- __send__("translations_for_#{group.id}", dir, group, yielder)
25
+ __send__(:"translations_for_#{group.id}", dir, group, yielder)
26
26
  end
27
27
  end
28
28
 
@@ -1,3 +1,3 @@
1
1
  module AwesomeTranslations
2
- VERSION = "0.0.63".freeze
2
+ VERSION = "0.0.64".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesome_translations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.63
4
+ version: 0.0.64
5
5
  platform: ruby
6
6
  authors:
7
- - Kasper Johansen
8
- autorequire:
7
+ - Kasper Stöckel
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-30 00:00:00.000000000 Z
11
+ date: 2024-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active-record-transactioner
@@ -124,7 +124,7 @@ dependencies:
124
124
  version: 0.0.3
125
125
  description: Semi-automatic maintenance of most translations in a Rails app.
126
126
  email:
127
- - kaspernj@gmail.com
127
+ - k@spernj.org
128
128
  executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
@@ -204,7 +204,7 @@ homepage: https://www.github.com/kaspernj/awesome_translations
204
204
  licenses: []
205
205
  metadata:
206
206
  rubygems_mfa_required: 'true'
207
- post_install_message:
207
+ post_install_message:
208
208
  rdoc_options: []
209
209
  require_paths:
210
210
  - lib
@@ -219,8 +219,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  - !ruby/object:Gem::Version
220
220
  version: '0'
221
221
  requirements: []
222
- rubygems_version: 3.2.32
223
- signing_key:
222
+ rubygems_version: 3.4.10
223
+ signing_key:
224
224
  specification_version: 4
225
225
  summary: Semi-automatic maintenance of most translations in a Rails app.
226
226
  test_files: []