i18nliner 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/i18nliner/extensions/core.rb +15 -0
- data/lib/i18nliner/processors/ruby_processor.rb +1 -1
- data/lib/i18nliner/reserved_keys.rb +4 -0
- data/lib/i18nliner.rb +1 -1
- data/spec/extensions/core_spec.rb +5 -0
- data/spec/processors/ruby_processor_spec.rb +1 -1
- data/spec/reserved_keys_spec.rb +8 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49a54d15655300760797d011db9521a123b23892478badcee8cfab3c7c890e25
|
4
|
+
data.tar.gz: 97409ad1106e9ed7c68567038bca41495e204545fce5b605b2b30e591072c399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d81cc7123036ef5a7f19224d2400b384f4049bee9be1ea9a99d40b12ea2db8739f547861e93bff7c51f7639c1877c0ae672a850325e85a59817ba678b455d31a
|
7
|
+
data.tar.gz: 0b465bc13a850bd61ffdbc2459d698f55719cc5cc5cab1bd55ca8e8bfabba8a12a7214def2c95a0fd682b50d4fd4af03092fd4815702081524f1fe92e468a18c
|
@@ -18,9 +18,19 @@ module I18nliner
|
|
18
18
|
|
19
19
|
wrappers = options.delete(:wrappers) || options.delete(:wrapper)
|
20
20
|
result = super(key, options)
|
21
|
+
|
22
|
+
# In rails 6.1+ views, sometimes an Object is used for the default, and that object needs to remain
|
23
|
+
# an object or it won't be recognized if it comes back as a string
|
24
|
+
return result if result.nil? || result.instance_of?(Object)
|
25
|
+
|
26
|
+
# If you are actually using nonprintable characters in your source string, you should feel ashamed
|
27
|
+
result = result.gsub("\\\\", "\uE124").gsub("\\*", "\uE123")
|
21
28
|
if wrappers
|
22
29
|
result = apply_wrappers(result, wrappers)
|
23
30
|
end
|
31
|
+
was_html_safe = result.html_safe?
|
32
|
+
result = result.gsub("\uE123", '*').gsub("\uE124", "\\")
|
33
|
+
result = result.html_safe if was_html_safe
|
24
34
|
|
25
35
|
result
|
26
36
|
rescue ArgumentError
|
@@ -58,10 +68,15 @@ module I18nliner
|
|
58
68
|
wrappers = Array(wrappers)
|
59
69
|
wrappers = Hash[wrappers.each_with_index.map{ |w, i| ['*' * (1 + i), w]}]
|
60
70
|
end
|
71
|
+
# If you are actually using nonprintable characters in your source string, you should feel ashamed
|
72
|
+
string.gsub!("\\\\", 26.chr)
|
73
|
+
string.gsub!("\\*", 27.chr)
|
61
74
|
wrappers.sort_by{ |k, v| -k.length }.each do |k, v|
|
62
75
|
pattern = pattern_for(k)
|
63
76
|
string.gsub!(pattern, v)
|
64
77
|
end
|
78
|
+
string.gsub!(27.chr, '*')
|
79
|
+
string.gsub!(26.chr, "\\")
|
65
80
|
string.html_safe
|
66
81
|
end
|
67
82
|
|
data/lib/i18nliner.rb
CHANGED
@@ -77,6 +77,11 @@ describe I18nliner::Extensions::Core do
|
|
77
77
|
expect(i18n.translate("*bacon* > narwhals", :wrappers => ['<b>\1</b>'])).
|
78
78
|
to eq "<b>bacon</b> > narwhals"
|
79
79
|
end
|
80
|
+
|
81
|
+
it "should allow escaping asterisks and backslashes" do
|
82
|
+
result = i18n.translate("Hello \\\\*b\\*b*.", :wrapper => '<b>\1</b>')
|
83
|
+
expect(result).to eq 'Hello \<b>b*b</b>.'
|
84
|
+
end
|
80
85
|
end
|
81
86
|
end
|
82
87
|
|
@@ -9,7 +9,7 @@ describe I18nliner::Processors::RubyProcessor do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#scope_for" do
|
12
|
-
if defined?(::Rails)
|
12
|
+
if defined?(::Rails)
|
13
13
|
context "with a controller" do
|
14
14
|
subject { @processor.scope_for("app/controllers/foos/bars_controller.rb") }
|
15
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18nliner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Jensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.0'
|
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: '
|
26
|
+
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ruby_parser
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- lib/i18nliner/processors/erb_processor.rb
|
189
189
|
- lib/i18nliner/processors/ruby_processor.rb
|
190
190
|
- lib/i18nliner/railtie.rb
|
191
|
+
- lib/i18nliner/reserved_keys.rb
|
191
192
|
- lib/i18nliner/scope.rb
|
192
193
|
- lib/tasks/i18nliner.rake
|
193
194
|
- spec/commands/check_spec.rb
|
@@ -205,6 +206,7 @@ files:
|
|
205
206
|
- spec/pre_processors/erb_pre_processor_spec.rb
|
206
207
|
- spec/processors/erb_processor_spec.rb
|
207
208
|
- spec/processors/ruby_processor_spec.rb
|
209
|
+
- spec/reserved_keys_spec.rb
|
208
210
|
homepage: http://github.com/jenseng/i18nliner
|
209
211
|
licenses: []
|
210
212
|
metadata: {}
|
@@ -216,14 +218,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
218
|
requirements:
|
217
219
|
- - ">="
|
218
220
|
- !ruby/object:Gem::Version
|
219
|
-
version:
|
221
|
+
version: '2.7'
|
220
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
223
|
requirements:
|
222
224
|
- - ">="
|
223
225
|
- !ruby/object:Gem::Version
|
224
226
|
version: 1.3.5
|
225
227
|
requirements: []
|
226
|
-
rubygems_version: 3.
|
228
|
+
rubygems_version: 3.1.6
|
227
229
|
signing_key:
|
228
230
|
specification_version: 4
|
229
231
|
summary: I18n made simple
|