r18n-core 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ == 1.1.6 (Vitebsk)
2
+ * Return TranslatedString after global String filters.
3
+ * Fix path in global String filters.
4
+
1
5
  == 1.1.5 (Hilo)
2
6
  * Fix Sinatra plugin under multithreaded web-server (by Viktors Rotanovs).
3
7
  * Fix BigDecimal localizing (by François Beausoleil).
data/README.md CHANGED
@@ -429,6 +429,12 @@ If you want to load a translation with some type for filter, use
429
429
  t.users(5) #=> "5 users"
430
430
  ```
431
431
 
432
+ You can also set several loaders to merge translations from different sources:
433
+
434
+ ```ruby
435
+ R18n.default_places = [MyLoader.new, DBLoader.new, 'path/to/yaml']
436
+ ```
437
+
432
438
  ### Extension Translations
433
439
 
434
440
  For r18n plugin you can add loaders with translations, which will be used with
@@ -56,7 +56,12 @@ module R18n
56
56
  enabled(filters_type, String).each do |f|
57
57
  value = f.call(value, config, *params)
58
58
  end
59
- value
59
+
60
+ if value.class == String
61
+ TranslatedString.new(value, config[:locale], config[:path])
62
+ else
63
+ value
64
+ end
60
65
  end
61
66
 
62
67
  # Array of enabled filters with +filters_type+ for +type+.
@@ -150,7 +150,8 @@ module R18n
150
150
  value = @data[name]
151
151
  case value
152
152
  when TranslatedString
153
- @filters.process_string(:active, value, @path, params)
153
+ path = @path.empty? ? name : "#{@path}.#{name}"
154
+ @filters.process_string(:active, value, path, params)
154
155
  when Typed
155
156
  @filters.process_typed(:active, value, params)
156
157
  when nil
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module R18n
3
- VERSION = '1.1.5'.freeze unless defined? R18n::VERSION
3
+ VERSION = '1.1.6'.freeze unless defined? R18n::VERSION
4
4
  end
data/r18n-core.gemspec CHANGED
@@ -22,14 +22,4 @@ Gem::Specification.new do |s|
22
22
  s.author = 'Andrey "A.I." Sitnik'
23
23
  s.email = 'andrey@sitnik.ru'
24
24
  s.homepage = 'https://github.com/ai/r18n'
25
-
26
- s.add_development_dependency "bundler", [">= 1.0.10"]
27
- s.add_development_dependency "yard", [">= 0"]
28
- s.add_development_dependency "rake", [">= 0", "!= 0.9.0"]
29
- s.add_development_dependency "rspec-core", [">= 0"]
30
- s.add_development_dependency "rspec-expectations", [">= 0"]
31
- s.add_development_dependency "rspec-mocks", [">= 0"]
32
- s.add_development_dependency "kramdown", [">= 0"]
33
- s.add_development_dependency "RedCloth", [">= 0"]
34
- s.add_development_dependency "redcarpet", [">= 0"]
35
25
  end
data/spec/filters_spec.rb CHANGED
@@ -42,7 +42,7 @@ describe R18n::Filters do
42
42
  end
43
43
 
44
44
  it "should use passive filters" do
45
- filter = mock()
45
+ filter = double()
46
46
  filter.should_receive(:process).twice.and_return(1)
47
47
 
48
48
  R18n::Filters.add('my', :passive, :passive => true) { filter.process }
@@ -121,6 +121,22 @@ describe R18n::Filters do
121
121
  @i18n.my_filter[:unknown_value].should be_nil
122
122
  end
123
123
 
124
+ it "should set path in config" do
125
+ R18n::Filters.add(String) do |i, config|
126
+ config[:path]
127
+ end
128
+
129
+ @i18n.in.another.level.should == 'in.another.level'
130
+ end
131
+
132
+ it "should return translated string after filters" do
133
+ R18n::Filters.add(String) { |i, config| i + '1' }
134
+
135
+ @i18n.one.should be_a(R18n::TranslatedString)
136
+ @i18n.one.path.should == 'one'
137
+ @i18n.one.locale.should == R18n.locale('en')
138
+ end
139
+
124
140
  it "should use one config for cascade filters" do
125
141
  R18n::Filters.add('my') { |content, config| config[:new_secret] ? 2 : 1 }
126
142
  @i18n.my_filter.should == 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r18n-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,158 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-13 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: bundler
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 1.0.10
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: 1.0.10
30
- - !ruby/object:Gem::Dependency
31
- name: yard
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: rake
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- - - ! '!='
55
- - !ruby/object:Gem::Version
56
- version: 0.9.0
57
- type: :development
58
- prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
62
- - - ! '>='
63
- - !ruby/object:Gem::Version
64
- version: '0'
65
- - - ! '!='
66
- - !ruby/object:Gem::Version
67
- version: 0.9.0
68
- - !ruby/object:Gem::Dependency
69
- name: rspec-core
70
- requirement: !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ! '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
81
- - - ! '>='
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
- - !ruby/object:Gem::Dependency
85
- name: rspec-expectations
86
- requirement: !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ! '>='
90
- - !ruby/object:Gem::Version
91
- version: '0'
92
- type: :development
93
- prerelease: false
94
- version_requirements: !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ! '>='
98
- - !ruby/object:Gem::Version
99
- version: '0'
100
- - !ruby/object:Gem::Dependency
101
- name: rspec-mocks
102
- requirement: !ruby/object:Gem::Requirement
103
- none: false
104
- requirements:
105
- - - ! '>='
106
- - !ruby/object:Gem::Version
107
- version: '0'
108
- type: :development
109
- prerelease: false
110
- version_requirements: !ruby/object:Gem::Requirement
111
- none: false
112
- requirements:
113
- - - ! '>='
114
- - !ruby/object:Gem::Version
115
- version: '0'
116
- - !ruby/object:Gem::Dependency
117
- name: kramdown
118
- requirement: !ruby/object:Gem::Requirement
119
- none: false
120
- requirements:
121
- - - ! '>='
122
- - !ruby/object:Gem::Version
123
- version: '0'
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- none: false
128
- requirements:
129
- - - ! '>='
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- - !ruby/object:Gem::Dependency
133
- name: RedCloth
134
- requirement: !ruby/object:Gem::Requirement
135
- none: false
136
- requirements:
137
- - - ! '>='
138
- - !ruby/object:Gem::Version
139
- version: '0'
140
- type: :development
141
- prerelease: false
142
- version_requirements: !ruby/object:Gem::Requirement
143
- none: false
144
- requirements:
145
- - - ! '>='
146
- - !ruby/object:Gem::Version
147
- version: '0'
148
- - !ruby/object:Gem::Dependency
149
- name: redcarpet
150
- requirement: !ruby/object:Gem::Requirement
151
- none: false
152
- requirements:
153
- - - ! '>='
154
- - !ruby/object:Gem::Version
155
- version: '0'
156
- type: :development
157
- prerelease: false
158
- version_requirements: !ruby/object:Gem::Requirement
159
- none: false
160
- requirements:
161
- - - ! '>='
162
- - !ruby/object:Gem::Version
163
- version: '0'
12
+ date: 2013-08-25 00:00:00.000000000 Z
13
+ dependencies: []
164
14
  description: ! " R18n is a i18n tool to translate your Ruby application.\n It
165
15
  has nice Ruby-style syntax, filters, flexible locales, custom loaders,\n translation
166
16
  support for any classes, time and number localization, several\n user language
@@ -300,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
300
150
  version: '0'
301
151
  segments:
302
152
  - 0
303
- hash: 3696730246666431868
153
+ hash: -2490264881183161480
304
154
  required_rubygems_version: !ruby/object:Gem::Requirement
305
155
  none: false
306
156
  requirements:
@@ -309,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
309
159
  version: '0'
310
160
  segments:
311
161
  - 0
312
- hash: 3696730246666431868
162
+ hash: -2490264881183161480
313
163
  requirements: []
314
164
  rubyforge_project:
315
165
  rubygems_version: 1.8.23