i18nliner 0.1.2 → 0.2.0
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7db05f72a6f74269e7600897f2910d08749e1e8d8a334cbd8678e5ed7fe3640b
|
|
4
|
+
data.tar.gz: 3ee6d0d8ed3bb20ed38f7d639d9b2a151c1a3ff1c3c09dc7379a8246fcbc6599
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 59db484754a91d810436e65063f705026bbbfdf042a141ca053d0555616a97e83a89cd59cb9654f7d9243ee28a0f81169d1e82f7697b5f55333ea4f55ec71abd
|
|
7
|
+
data.tar.gz: 397e276a16b5fc43603de1abdeb1594ccb3a13ed2709809299f1a68d1b536983a66d37ed5d41684cfeb6eb1e3bda381c8e4e121fb6dbacc0e1903973a3ffc6ce
|
|
@@ -53,15 +53,24 @@ module I18nliner
|
|
|
53
53
|
private
|
|
54
54
|
|
|
55
55
|
def apply_wrappers(string, wrappers)
|
|
56
|
+
# In rails 6.1+ views, sometimes an Object is used for the default, and that object needs to remain
|
|
57
|
+
# an object or it won't be recognized if it comes back as a string
|
|
58
|
+
return string if string.instance_of?(Object)
|
|
59
|
+
|
|
56
60
|
string = string.html_safe? ? string.dup : ERB::Util.h(string)
|
|
57
61
|
unless wrappers.is_a?(Hash)
|
|
58
62
|
wrappers = Array(wrappers)
|
|
59
63
|
wrappers = Hash[wrappers.each_with_index.map{ |w, i| ['*' * (1 + i), w]}]
|
|
60
64
|
end
|
|
65
|
+
# If you are actually using nonprintable characters in your source string, you should feel ashamed
|
|
66
|
+
string.gsub!("\\\\", 26.chr)
|
|
67
|
+
string.gsub!("\\*", 27.chr)
|
|
61
68
|
wrappers.sort_by{ |k, v| -k.length }.each do |k, v|
|
|
62
69
|
pattern = pattern_for(k)
|
|
63
70
|
string.gsub!(pattern, v)
|
|
64
71
|
end
|
|
72
|
+
string.gsub!(27.chr, '*')
|
|
73
|
+
string.gsub!(26.chr, "\\")
|
|
65
74
|
string.html_safe
|
|
66
75
|
end
|
|
67
76
|
|
|
@@ -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.0
|
|
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-09 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
|
|
@@ -218,14 +218,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
218
218
|
requirements:
|
|
219
219
|
- - ">="
|
|
220
220
|
- !ruby/object:Gem::Version
|
|
221
|
-
version:
|
|
221
|
+
version: '2.7'
|
|
222
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
requirements:
|
|
224
224
|
- - ">="
|
|
225
225
|
- !ruby/object:Gem::Version
|
|
226
226
|
version: 1.3.5
|
|
227
227
|
requirements: []
|
|
228
|
-
rubygems_version: 3.
|
|
228
|
+
rubygems_version: 3.1.6
|
|
229
229
|
signing_key:
|
|
230
230
|
specification_version: 4
|
|
231
231
|
summary: I18n made simple
|