extract_i18n 0.7.2 → 0.8.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd69038581ae691be4cae64c1e320b3fb8c5c8bb60b9ef27bc4dd11f3394e6f9
4
- data.tar.gz: 7bfdf2f5bdc0dce6c08c917ee92cd30c42f2f057ea87be8cd3aa124b404bd4bf
3
+ metadata.gz: 8d8ad8ad587b0c1b29c6da66a422145d8863cf8ab3d427c96a689412b33de731
4
+ data.tar.gz: d56c08e023298fab0d2fc897ed318d6e994a78432ceb8630f386ae212c941c9f
5
5
  SHA512:
6
- metadata.gz: 75b0ce1094da7625e45dc043fcc487a9f29feea63b4530b599ef4d6a7fa00cc24d1a344b6ef95bc6de1339f80785984e0cf11ae95fc103df537547a31b022092
7
- data.tar.gz: 26862c6a277ed348546507cd04a11b066271c73f7422c403bc62bd1870beb96b20793cb413fe1c1e38fe3526b25ee74ee346d47d51933f79dafda30b2aca5426
6
+ metadata.gz: 2c7abee0591c99c71382fd5bf1cc244ccecbcc143e64024c012ddf0ea1d9b76614dd893dcc334cff547cafa3c163ac9dcbe799d16b7e9597ccbeccddd11b65fe
7
+ data.tar.gz: 6b11f294e3123b136027d4e79b4f7f887fbeae7d41c15fb8e23e3b7d0382e8793da054c734a9f1b6866323f40e1bdff89df2caa02273dc1cceeb59dc49174528
@@ -98,7 +98,7 @@ module ExtractI18n
98
98
  end
99
99
 
100
100
  def original_content
101
- @original_content ||= File.read(@file_path)
101
+ File.read(@file_path)
102
102
  end
103
103
  end
104
104
  end
@@ -70,9 +70,15 @@ module ExtractI18n
70
70
 
71
71
  ERB_REGEXPS.each do |regexp|
72
72
  regexp.replace!(text) do |string_format, data|
73
- key = SecureRandom.uuid
74
- erb_directives[key] = data[:inner_text]
75
- string_format % { inner_text: key }
73
+ code = data[:inner_text].strip
74
+ # skip t(...) / I18n.t(...) calls
75
+ if code =~ /\A(?:I18n\.)?t\(\s*(['"]).+?\1\s*\)\z/
76
+ "<%=#{data[:inner_text]}%>"
77
+ else
78
+ key = SecureRandom.uuid
79
+ erb_directives[key] = data[:inner_text]
80
+ string_format % { inner_text: key }
81
+ end
76
82
  end
77
83
  end
78
84
  erb_directives
@@ -17,6 +17,10 @@ module ExtractI18n
17
17
  raise NotImplementedError
18
18
  end
19
19
 
20
+ def to_s
21
+ text
22
+ end
23
+
20
24
  attr_writer :key
21
25
 
22
26
  def key
@@ -93,7 +93,9 @@ module ExtractI18n
93
93
  t_template: "#{before}#{html_tag}t('%s'%s)#{after}"
94
94
  )
95
95
  final_line = yield(change)
96
- return parse_html_arguments(final_line, &block)
96
+ if final_line != @word.indentation + line
97
+ return parse_html_arguments(final_line, &block)
98
+ end
97
99
  end
98
100
  end
99
101
  if final_line == line
@@ -34,7 +34,7 @@ module ExtractI18n
34
34
  @i18n_string = i18n_string
35
35
  @key = i18n_key
36
36
  @interpolate_arguments = interpolate_arguments
37
- @source_line = source_line
37
+ @source_line = source_line.nil? ? "" : source_line
38
38
  @remove = remove
39
39
  @t_template = t_template
40
40
  @interpolation_type = interpolation_type
@@ -42,9 +42,9 @@ module ExtractI18n
42
42
 
43
43
  def format
44
44
  s = ""
45
- s += PASTEL.cyan("replace: ") + PASTEL.blue(@source_line).
45
+ s += PASTEL.cyan("\nreplace: ") + PASTEL.blue(@source_line).
46
46
  gsub(@remove, PASTEL.red(@remove))
47
- unless @source_line.include?("\n")
47
+ unless @source_line.end_with?("\n")
48
48
  s += "\n"
49
49
  end
50
50
  if @source_line[@remove]
@@ -53,7 +53,7 @@ module ExtractI18n
53
53
  else
54
54
  s += PASTEL.cyan("with: ") + PASTEL.green(i18n_t)
55
55
  end
56
- unless @source_line.include?("\n")
56
+ unless @source_line.end_with?("\n")
57
57
  s += "\n"
58
58
  end
59
59
  s += PASTEL.cyan("add i18n: ") + PASTEL.blue("#{@key}: #{@i18n_string}")
@@ -1,3 +1,3 @@
1
1
  module ExtractI18n
2
- VERSION = "0.7.2"
2
+ VERSION = "0.8.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extract_i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Wienert
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-27 00:00:00.000000000 Z
11
+ date: 2025-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -164,7 +164,7 @@ licenses:
164
164
  - MIT
165
165
  metadata:
166
166
  rubygems_mfa_required: 'true'
167
- post_install_message:
167
+ post_install_message:
168
168
  rdoc_options: []
169
169
  require_paths:
170
170
  - lib
@@ -179,8 +179,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  requirements: []
182
- rubygems_version: 3.5.11
183
- signing_key:
182
+ rubygems_version: 3.2.33
183
+ signing_key:
184
184
  specification_version: 4
185
185
  summary: Extact i18n from Ruby files using Ruby parser and slim files using regex
186
186
  test_files: []