r18n-core 2.1.5 → 2.1.6

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
  SHA1:
3
- metadata.gz: fd9a66e4eaa844bf54da00c46f9cee94cc17aeae
4
- data.tar.gz: 96922df7f0f8e8a2a1aaf0780209fc8cc31a65f8
3
+ metadata.gz: d01ca11bf73f68b371d98508755f5fcbd8360290
4
+ data.tar.gz: 32074b227246a93c6ff71f5748ab4914c8f50285
5
5
  SHA512:
6
- metadata.gz: 76c32b637fdd52c47d95c4c7231ed1de6cd917bcc975a3b05ef2a459a488a9633729f641222f90fe8e14e3eb0d98c0e6d796e24a2565beca76496f91cc675a26
7
- data.tar.gz: ea6dd26bae7c951de5507ad81976677bbf44d37449f0ea70e6e38eb29f5d68997beed374acddbdf46eaf5e702b4a234bffab8f43ed9dc0f7bd3341a648d84d47
6
+ metadata.gz: ecba6af5cf4a56c6c1b42895c66e258f1f03bea79dc2aa9545289c43fe76d2cc87c8e7d49dff796529fb9f1ff70fb86d74d62279caef66dee32ee1bc2232c72f
7
+ data.tar.gz: 7592e2e32e74a06d8a6db4383c97ddaa83813c52ac53dec5190f6cc8f715d47ad72e99a2b1aac70b6a52500eb31331d5e242589bfc9256e02ad96b6d6a72ccd9
data/ChangeLog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.1.6 (Berlin)
2
+ * Better `TranslatedString` → `String` converting (by Patrik Rak).
3
+ * Add Ruby on Rails 5 support.
4
+
1
5
  ## 2.1.5 (මාතර)
2
6
  * Fix Ruby 2.4 support (by Alexander Popov)
3
7
 
@@ -29,11 +29,9 @@ module R18n
29
29
  # Returns a new string object containing a copy of +str+, which translated
30
30
  # for +path+ to +locale+
31
31
  def initialize(value, locale, path, filters = nil)
32
- value = value.to_s if value.is_a? TranslatedString
33
- super(value)
32
+ super(value.to_s)
34
33
  @filters = filters
35
34
  @locale = locale
36
- @value = value
37
35
  @path = path
38
36
  end
39
37
 
@@ -55,9 +53,9 @@ module R18n
55
53
  # Override to_s to make string html safe if `html_safe` method is defined.
56
54
  def to_s
57
55
  if respond_to? :html_safe
58
- @value.html_safe
56
+ super.html_safe
59
57
  else
60
- @value
58
+ String.new(super)
61
59
  end
62
60
  end
63
61
 
@@ -93,7 +93,7 @@ module R18n
93
93
  when String
94
94
  c = { locale: locale, path: path }
95
95
  v = @filters.process_string(:passive, value, c, [])
96
- value = TranslatedString.new(v, locale, path, @filter)
96
+ value = TranslatedString.new(v, locale, path, @filters)
97
97
  when Typed
98
98
  value.locale = locale
99
99
  value.path = path
@@ -1,3 +1,3 @@
1
1
  module R18n
2
- VERSION = '2.1.5'.freeze unless defined? R18n::VERSION
2
+ VERSION = '2.1.6'.freeze unless defined? R18n::VERSION
3
3
  end
@@ -18,6 +18,21 @@ describe R18n::Translation do
18
18
  expect(i18n.one | 'default').to eq('One')
19
19
  end
20
20
 
21
+ it "returns strings which can be used as normal strings" do
22
+ i18n = R18n::I18n.new('en', DIR)
23
+ expect(i18n.not.exists).not_to be_translated
24
+ expect(i18n.not.exists.to_s).to be_kind_of(String)
25
+ expect(i18n.not.exists.to_s.split.first).to be_kind_of(String)
26
+ expect(i18n.not.exists.to_s.split.first.to_s).to be_kind_of(String)
27
+
28
+ expect(i18n.one).to be_translated
29
+ expect(i18n.one.to_s).to be_kind_of(String)
30
+ expect(i18n.one.to_s.split.first).to be_kind_of(String)
31
+ expect(i18n.one.to_s.split.first.to_s).to be_kind_of(String)
32
+ expect(i18n.one.split.first).to be_kind_of(String)
33
+ expect(i18n.one.split.first.to_s).to be_kind_of(String)
34
+ end
35
+
21
36
  it "returns html escaped string" do
22
37
  klass = Class.new(R18n::TranslatedString) do
23
38
  def html_safe
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r18n-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Sitnik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-02 00:00:00.000000000 Z
11
+ date: 2017-05-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  R18n is a i18n tool to translate your Ruby application.