text_helpers 1.0.0 → 1.0.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 +4 -4
- data/lib/text_helpers/translation.rb +3 -3
- data/lib/text_helpers/version.rb +1 -1
- data/test/lib/text_helpers/translation_test.rb +9 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97f5f8d490471d60b7cc9286f2fb49460862917a1ed6b6d36c984fb8f5a22ac3
|
4
|
+
data.tar.gz: a2fadb5cea94f89c87cf31ef1a7dbb8779739c6aab67d2b9f143968498cc25e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73f98e2a518aeafb35653d9d713a3b983d456d2e947bc98fcc1c519d9b8b7034f741eb2985475336e5b9fe6786ebc8502e2fe9994001a259c19c1c0800b769d2
|
7
|
+
data.tar.gz: 37a0c2ba7e0510dd38d720abafb43ba6342f1af8b578422b520d82956aa9a46df22b87a6774b615f1665a21b11618f185229face8e8c9b44513c44081cd1f2f0
|
@@ -37,11 +37,11 @@ module TextHelpers
|
|
37
37
|
options = html_safe_options(options)
|
38
38
|
text = I18n.t(key, **{
|
39
39
|
scope: self.translation_scope,
|
40
|
-
default: "!#{key}!"
|
40
|
+
default: "!#{key}!",
|
41
|
+
cascade: true,
|
41
42
|
}.merge(options)).strip
|
42
43
|
|
43
|
-
interpolation_options = options
|
44
|
-
interpolation_options[:cascade] = true unless interpolation_options.has_key?(:cascade)
|
44
|
+
interpolation_options = { cascade: true }.merge(options)
|
45
45
|
|
46
46
|
# Interpolate any keypaths (e.g., `!some.lookup.path/key!`) found in the text.
|
47
47
|
while text =~ KEYPATH_MATCHER do
|
data/lib/text_helpers/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "../../test_helper"
|
2
2
|
|
3
3
|
describe TextHelpers::Translation do
|
4
4
|
before do
|
@@ -242,6 +242,14 @@ describe TextHelpers::Translation do
|
|
242
242
|
I18n.backend = @original_backend
|
243
243
|
end
|
244
244
|
|
245
|
+
it "cascades the requested key by default" do
|
246
|
+
I18n.backend.store_translations(:en, {test_scoped_key: "a translation"})
|
247
|
+
assert_equal "a translation", @helper.text(:test_scoped_key, scope: "some.unnecessary.scope")
|
248
|
+
|
249
|
+
I18n.backend.store_translations(:en, {some: {test_scoped_key: "a scoped translation"}})
|
250
|
+
assert_equal "a scoped translation", @helper.text(:test_scoped_key, scope: "some.unnecessary.scope")
|
251
|
+
end
|
252
|
+
|
245
253
|
it "cascades the interpolated key by default" do
|
246
254
|
I18n.backend.store_translations(:en, {test_scoped_key: "a translation"})
|
247
255
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: text_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Horner
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03
|
11
|
+
date: 2020-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -108,7 +108,7 @@ homepage: https://github.com/ahorner/text-helpers
|
|
108
108
|
licenses:
|
109
109
|
- MIT
|
110
110
|
metadata: {}
|
111
|
-
post_install_message:
|
111
|
+
post_install_message:
|
112
112
|
rdoc_options: []
|
113
113
|
require_paths:
|
114
114
|
- lib
|
@@ -123,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.1.
|
127
|
-
signing_key:
|
126
|
+
rubygems_version: 3.1.4
|
127
|
+
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: TextHelpers is a gem which supplies some basic utilities for text localization
|
130
130
|
in Rails projects. The library is intended to make it simple to keep your application's
|