r18n-core 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +5 -0
- data/Rakefile +4 -24
- data/base/id.yml +31 -0
- data/lib/r18n-core/translated.rb +3 -2
- data/lib/r18n-core/version.rb +1 -1
- data/locales/id.rb +18 -0
- data/r18n-core.gemspec +1 -0
- data/spec/filters_spec.rb +36 -35
- data/spec/i18n_spec.rb +23 -23
- data/spec/locale_spec.rb +21 -21
- data/spec/locales/cs_spec.rb +1 -1
- data/spec/locales/en-us_spec.rb +1 -1
- data/spec/locales/en_spec.rb +1 -1
- data/spec/locales/fr_spec.rb +1 -1
- data/spec/locales/hu_spec.rb +2 -2
- data/spec/locales/it_spec.rb +1 -1
- data/spec/locales/pl_spec.rb +1 -1
- data/spec/locales/ru_spec.rb +1 -1
- data/spec/locales/sk_spec.rb +1 -1
- data/spec/locales/th_spec.rb +1 -1
- data/spec/r18n_spec.rb +23 -23
- data/spec/translated_spec.rb +23 -25
- data/spec/translation_spec.rb +10 -10
- data/spec/yaml_loader_spec.rb +6 -6
- metadata +44 -24
- data/.yardopts +0 -4
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4d1722656695a79ee26f9232bf464d6052b798a6
|
4
|
+
data.tar.gz: 312898e2722d61e6c924451901f53124124a3209
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a27c2c68f3b9dabe61f797fb10d5d14dacfd24063510b7f171d8036ad648b78fc07b32a045c6b0b171d797946cc3aa5cb327c7d9c750f41ca132ce3560ceb388
|
7
|
+
data.tar.gz: c66260207a48437d4ec10df95663a7e486a349f8531dceb2f441941421a25208b212cdefdb8babb616bf2ffefd59d0da1055bbcf40c04053f745b57c5808a1e3
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 1.1.7 (Tujuh)
|
2
|
+
* Return nil on untranslated in models with Translated.
|
3
|
+
* Add transliterate method to I18n backend.
|
4
|
+
* Add Indonesian locale (by Guntur Akhmad).
|
5
|
+
|
1
6
|
== 1.1.6 (Vitebsk)
|
2
7
|
* Return TranslatedString after global String filters.
|
3
8
|
* Fix path in global String filters.
|
data/Rakefile
CHANGED
@@ -1,33 +1,13 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'rubygems'
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
Bundler::GemHelper.install_tasks
|
8
|
-
rescue LoadError
|
9
|
-
puts "Bundler not available. Install it with: gem install bundler"
|
10
|
-
end
|
11
|
-
|
12
|
-
PKG_NAME = 'r18n-core'.freeze
|
13
|
-
require File.join(File.dirname(__FILE__), 'lib/r18n-core/version')
|
3
|
+
require 'bundler/setup'
|
4
|
+
Bundler::GemHelper.install_tasks
|
14
5
|
|
15
6
|
require 'rspec/core/rake_task'
|
16
|
-
|
17
7
|
RSpec::Core::RakeTask.new
|
8
|
+
task :default => :spec
|
18
9
|
|
19
|
-
require 'yard'
|
20
|
-
YARD::Rake::YardocTask.new do |yard|
|
21
|
-
yard.options << "--title='R18n #{R18n::VERSION}'"
|
22
|
-
end
|
23
|
-
|
24
|
-
task :clobber_doc do
|
25
|
-
rm_r 'doc' rescue nil
|
26
|
-
rm_r '.yardoc' rescue nil
|
27
|
-
end
|
28
10
|
task :clobber_package do
|
29
11
|
rm_r 'pkg' rescue nil
|
30
12
|
end
|
31
|
-
task :clobber => [:clobber_package
|
32
|
-
|
33
|
-
task :default => :spec
|
13
|
+
task :clobber => [:clobber_package]
|
data/base/id.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
ok: 'OK'
|
2
|
+
save: 'Simpan'
|
3
|
+
cancel: 'Batal'
|
4
|
+
'yes': 'Ya'
|
5
|
+
'no': 'Tidak'
|
6
|
+
exit: 'Keluar'
|
7
|
+
delete: 'Hapus'
|
8
|
+
|
9
|
+
human_time:
|
10
|
+
after_days: !!pl
|
11
|
+
1: 'setelah %1 hari'
|
12
|
+
n: 'setelah %1 hari'
|
13
|
+
tomorrow: 'besok'
|
14
|
+
after_hours: !!pl
|
15
|
+
1: 'setelah %1 jam'
|
16
|
+
n: 'setelah %1 jam'
|
17
|
+
after_minutes: !!pl
|
18
|
+
1: 'setelah %1 menit'
|
19
|
+
n: 'setelah %1 menit'
|
20
|
+
now: 'sekarang'
|
21
|
+
today: 'hari ini'
|
22
|
+
minutes_ago: !!pl
|
23
|
+
1: '%1 menit yang lalu'
|
24
|
+
n: '%1 menit yang lalu'
|
25
|
+
hours_ago: !!pl
|
26
|
+
1: '%1 jam yang lalu'
|
27
|
+
n: '%1 jam yang lalu'
|
28
|
+
yesterday: 'kemarin'
|
29
|
+
days_ago: !!pl
|
30
|
+
1: '%1 hari yang lalu'
|
31
|
+
n: '%1 hari yang lalu'
|
data/lib/r18n-core/translated.rb
CHANGED
@@ -127,6 +127,8 @@ module R18n
|
|
127
127
|
class_eval <<-EOS, __FILE__, __LINE__
|
128
128
|
def #{name}(*params)
|
129
129
|
unlocalized = self.class.unlocalized_getters(#{name.inspect})
|
130
|
+
result = nil
|
131
|
+
|
130
132
|
r18n.locales.each do |locale|
|
131
133
|
code = locale.code
|
132
134
|
next unless unlocalized.has_key? code
|
@@ -147,8 +149,7 @@ module R18n
|
|
147
149
|
end
|
148
150
|
end
|
149
151
|
|
150
|
-
|
151
|
-
r18n.locale, r18n.filter_list)
|
152
|
+
result
|
152
153
|
end
|
153
154
|
EOS
|
154
155
|
|
data/lib/r18n-core/version.rb
CHANGED
data/locales/id.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module R18n
|
2
|
+
class Locales::Id < Locale
|
3
|
+
set :title => 'Bahasa Indonesia',
|
4
|
+
|
5
|
+
:wday_names => %w{Minggu Senin Selasa Rabu Kamis Jumat
|
6
|
+
Sabtu},
|
7
|
+
:wday_abbrs => %w{Min Sen Sel Rab Kam Jum Sab},
|
8
|
+
|
9
|
+
:month_names => %w{Januari Februari Maret April Mei Juni Juli Agustus
|
10
|
+
September Oktober Nopember Desember},
|
11
|
+
:month_abbrs => %w{Jan Feb Mar Apr Mei Jun Jul Agu Sep Okt Nop Des},
|
12
|
+
|
13
|
+
:date_format => '%d/%m/%Y',
|
14
|
+
|
15
|
+
:number_decimal => ",",
|
16
|
+
:number_group => "."
|
17
|
+
end
|
18
|
+
end
|
data/r18n-core.gemspec
CHANGED
data/spec/filters_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe R18n::Filters do
|
|
19
19
|
(@system - @enabled).each { |i| R18n::Filters.off(i) if i.enabled? }
|
20
20
|
end
|
21
21
|
|
22
|
-
it "
|
22
|
+
it "adds new filter" do
|
23
23
|
filter = R18n::Filters.add('my', :my_filter) { |i, config| i }
|
24
24
|
|
25
25
|
filter.should be_a(R18n::Filters::Filter)
|
@@ -34,14 +34,14 @@ describe R18n::Filters do
|
|
34
34
|
@i18n.my_tree_filter.should == {'name' => 'value'}
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
37
|
+
it "adds filter for several types" do
|
38
38
|
filter = R18n::Filters.add(['my', 'your']) { |i, config| i + '1' }
|
39
39
|
@i18n.reload!
|
40
40
|
@i18n.my_filter.should == 'value1'
|
41
41
|
@i18n.your_filter.should == 'another1'
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "uses passive filters" do
|
45
45
|
filter = double()
|
46
46
|
filter.should_receive(:process).twice.and_return(1)
|
47
47
|
|
@@ -55,14 +55,14 @@ describe R18n::Filters do
|
|
55
55
|
@i18n.my_filter.should == 1
|
56
56
|
end
|
57
57
|
|
58
|
-
it "
|
58
|
+
it "uses cascade filters" do
|
59
59
|
filter = R18n::Filters.add('my', :one) { |i, config| i + '1' }
|
60
60
|
filter = R18n::Filters.add('my', :two) { |i, config| i + '2' }
|
61
61
|
filter = R18n::Filters.add('my', :three, :position => 0) { |i, c| i + '3' }
|
62
62
|
@i18n.my_filter.should == 'value312'
|
63
63
|
end
|
64
64
|
|
65
|
-
it "
|
65
|
+
it "returns name for nameless filter" do
|
66
66
|
R18n::Filters.instance_variable_set(:@last_auto_name, 0)
|
67
67
|
|
68
68
|
R18n::Filters.add('some').name.should == 1
|
@@ -72,7 +72,7 @@ describe R18n::Filters do
|
|
72
72
|
R18n::Filters.add('some').name.should == 4
|
73
73
|
end
|
74
74
|
|
75
|
-
it "
|
75
|
+
it "deletes filter by name" do
|
76
76
|
R18n::Filters.add('my', :my_filter) { '1' }
|
77
77
|
@i18n.my_filter.should == '1'
|
78
78
|
|
@@ -81,7 +81,7 @@ describe R18n::Filters do
|
|
81
81
|
@i18n.my_filter.should == 'value'
|
82
82
|
end
|
83
83
|
|
84
|
-
it "
|
84
|
+
it "deletes filter by object" do
|
85
85
|
filter = R18n::Filters.add('my') { '1' }
|
86
86
|
@i18n.my_filter.should == '1'
|
87
87
|
|
@@ -90,14 +90,14 @@ describe R18n::Filters do
|
|
90
90
|
@i18n.my_filter.should == 'value'
|
91
91
|
end
|
92
92
|
|
93
|
-
it "
|
93
|
+
it "uses global filters" do
|
94
94
|
R18n::Filters.add(String) { |result, config, a, b| result + a + b }
|
95
95
|
R18n::Filters.add(String) { |result, config| result + '!' }
|
96
96
|
|
97
97
|
@i18n.one('1', '2').should == 'One12!'
|
98
98
|
end
|
99
99
|
|
100
|
-
it "
|
100
|
+
it "turns off filter" do
|
101
101
|
filter = R18n::Filters.add('my', :one) { |i, config| i + '1' }
|
102
102
|
filter = R18n::Filters.add('my', :two) { |i, config| i + '2' }
|
103
103
|
|
@@ -110,7 +110,7 @@ describe R18n::Filters do
|
|
110
110
|
@i18n.my_filter.should == 'value12'
|
111
111
|
end
|
112
112
|
|
113
|
-
it "
|
113
|
+
it "sends config to filter" do
|
114
114
|
R18n::Filters.add('my') do |i, config|
|
115
115
|
config[:secret_value] = 1
|
116
116
|
config
|
@@ -121,7 +121,7 @@ describe R18n::Filters do
|
|
121
121
|
@i18n.my_filter[:unknown_value].should be_nil
|
122
122
|
end
|
123
123
|
|
124
|
-
it "
|
124
|
+
it "sets path in config" do
|
125
125
|
R18n::Filters.add(String) do |i, config|
|
126
126
|
config[:path]
|
127
127
|
end
|
@@ -129,7 +129,7 @@ describe R18n::Filters do
|
|
129
129
|
@i18n.in.another.level.should == 'in.another.level'
|
130
130
|
end
|
131
131
|
|
132
|
-
it "
|
132
|
+
it "returns translated string after filters" do
|
133
133
|
R18n::Filters.add(String) { |i, config| i + '1' }
|
134
134
|
|
135
135
|
@i18n.one.should be_a(R18n::TranslatedString)
|
@@ -137,7 +137,7 @@ describe R18n::Filters do
|
|
137
137
|
@i18n.one.locale.should == R18n.locale('en')
|
138
138
|
end
|
139
139
|
|
140
|
-
it "
|
140
|
+
it "uses one config for cascade filters" do
|
141
141
|
R18n::Filters.add('my') { |content, config| config[:new_secret] ? 2 : 1 }
|
142
142
|
@i18n.my_filter.should == 1
|
143
143
|
|
@@ -148,17 +148,17 @@ describe R18n::Filters do
|
|
148
148
|
@i18n.my_filter.should == 2
|
149
149
|
end
|
150
150
|
|
151
|
-
it "
|
151
|
+
it "sends parameters to filter" do
|
152
152
|
R18n::Filters.add('my') { |i, config, a, b| "#{i}#{a}#{b}" }
|
153
153
|
@i18n['my_filter', 1, 2].should == 'value12'
|
154
154
|
@i18n.my_filter(1, 2).should == 'value12'
|
155
155
|
end
|
156
156
|
|
157
|
-
it "
|
157
|
+
it "calls proc from translation" do
|
158
158
|
@i18n.sum(2, 3).should == 5
|
159
159
|
end
|
160
160
|
|
161
|
-
it "
|
161
|
+
it "pluralizes translation" do
|
162
162
|
@i18n.comments(0, 'article').should == 'no comments for article'
|
163
163
|
@i18n.comments(1, 'article').should == 'one comment for article'
|
164
164
|
@i18n.comments(5, 'article').should == '5 comments for article'
|
@@ -168,32 +168,33 @@ describe R18n::Filters do
|
|
168
168
|
@i18n.files(5000).should == '5,000 files'
|
169
169
|
end
|
170
170
|
|
171
|
-
it "
|
171
|
+
it "doesn't pluralize without first numeric parameter" do
|
172
172
|
@i18n.files.should be_a(R18n::UnpluralizetedTranslation)
|
173
173
|
@i18n.files('').should be_a(R18n::UnpluralizetedTranslation)
|
174
174
|
@i18n.files[1].should == '1 file'
|
175
175
|
@i18n.files.n(5).should == '5 files'
|
176
176
|
end
|
177
177
|
|
178
|
-
it "
|
178
|
+
it "converts first float parameter to number" do
|
179
179
|
@i18n.files(1.2).should == '1 file'
|
180
180
|
end
|
181
181
|
|
182
|
-
it "
|
182
|
+
it "pluralizes translation without locale" do
|
183
183
|
i18n = R18n::I18n.new('nolocale', DIR)
|
184
184
|
i18n.entries(1).should == 'ONE'
|
185
185
|
i18n.entries(5).should == 'N'
|
186
186
|
end
|
187
187
|
|
188
|
-
it "
|
188
|
+
it "cans use params in translation" do
|
189
189
|
@i18n.params(-1, 2).should == 'Is −1 between −1 and 2?'
|
190
190
|
end
|
191
191
|
|
192
|
-
it "
|
193
|
-
@i18n.params('%2 FIRST', 'SECOND').should ==
|
192
|
+
it "substitutes '%2' as param but not value of second param" do
|
193
|
+
@i18n.params('%2 FIRST', 'SECOND').should ==
|
194
|
+
'Is %2 FIRST between %2 FIRST and SECOND?'
|
194
195
|
end
|
195
196
|
|
196
|
-
it "
|
197
|
+
it "formats untranslated" do
|
197
198
|
@i18n.in.not.to_s.should == 'in.[not]'
|
198
199
|
@i18n.in.not.to_str.should == 'in.[not]'
|
199
200
|
|
@@ -206,7 +207,7 @@ describe R18n::Filters do
|
|
206
207
|
@i18n.in.not.to_s.should == 'in.not in.[not]'
|
207
208
|
end
|
208
209
|
|
209
|
-
it "
|
210
|
+
it "formats translation path" do
|
210
211
|
@i18n.in.another.to_s.should == 'in.another[]'
|
211
212
|
|
212
213
|
R18n::Filters.off(:untranslated)
|
@@ -218,14 +219,14 @@ describe R18n::Filters do
|
|
218
219
|
@i18n.in.another.to_s.should == 'in.another in.another[]'
|
219
220
|
end
|
220
221
|
|
221
|
-
it "
|
222
|
+
it "formats untranslated for web" do
|
222
223
|
R18n::Filters.off(:untranslated)
|
223
224
|
R18n::Filters.on(:untranslated_html)
|
224
225
|
@i18n.in.not.to_s.should == 'in.<span style="color: red">[not]</span>'
|
225
226
|
@i18n['<b>'].to_s.should == '<span style="color: red">[<b>]</span>'
|
226
227
|
end
|
227
228
|
|
228
|
-
it "
|
229
|
+
it "allows to set custom filters" do
|
229
230
|
R18n::Filters.add(R18n::Untranslated, :a) { |v, c| "a #{v}" }
|
230
231
|
R18n::Filters.off(:a)
|
231
232
|
|
@@ -234,11 +235,11 @@ describe R18n::Filters do
|
|
234
235
|
html.in.not.to_s.should == 'a in.<span style="color: red">[not]</span>'
|
235
236
|
end
|
236
237
|
|
237
|
-
it "
|
238
|
+
it "has filter for escape HTML" do
|
238
239
|
@i18n.html.should == '<script>true && false</script>'
|
239
240
|
end
|
240
241
|
|
241
|
-
it "
|
242
|
+
it "has disabled global filter for escape HTML" do
|
242
243
|
@i18n.greater('true').should == '1 < 2 is true'
|
243
244
|
|
244
245
|
R18n::Filters.on(:global_escape_html)
|
@@ -247,7 +248,7 @@ describe R18n::Filters do
|
|
247
248
|
@i18n.html.should == '<script>true && false</script>'
|
248
249
|
end
|
249
250
|
|
250
|
-
it "
|
251
|
+
it "has filter to disable global HTML escape" do
|
251
252
|
@i18n.no_escape.should == '<b>Warning</b>'
|
252
253
|
|
253
254
|
R18n::Filters.on(:global_escape_html)
|
@@ -255,15 +256,15 @@ describe R18n::Filters do
|
|
255
256
|
@i18n.no_escape.should == '<b>Warning</b>'
|
256
257
|
end
|
257
258
|
|
258
|
-
it "
|
259
|
+
it "has Markdown filter" do
|
259
260
|
@i18n.markdown.simple.should == "<p><strong>Hi!</strong></p>\n"
|
260
261
|
end
|
261
262
|
|
262
|
-
it "
|
263
|
+
it "has Textile filter" do
|
263
264
|
@i18n.textile.simple.should == '<p><em>Hi!</em></p>'
|
264
265
|
end
|
265
266
|
|
266
|
-
it "
|
267
|
+
it "HTML escapes before Markdown and Textile filters" do
|
267
268
|
@i18n.markdown.html.should == "<p><strong>Hi!</strong> <br /></p>\n"
|
268
269
|
@i18n.textile.html.should == '<p><em>Hi!</em><br /></p>'
|
269
270
|
|
@@ -273,19 +274,19 @@ describe R18n::Filters do
|
|
273
274
|
@i18n.textile.html.should == '<p><em>Hi!</em><br /></p>'
|
274
275
|
end
|
275
276
|
|
276
|
-
it "
|
277
|
+
it "allows to listen filters adding" do
|
277
278
|
R18n::Filters.listen {
|
278
279
|
R18n::Filters.add(String, :a) { }
|
279
280
|
}.should == [R18n::Filters.defined[:a]]
|
280
281
|
end
|
281
282
|
|
282
|
-
it "
|
283
|
+
it "escapes variables if ActiveSupport is loaded" do
|
283
284
|
@i18n.escape_params('<br>').should == '<b><br></b>'
|
284
285
|
require 'active_support'
|
285
286
|
@i18n.escape_params('<br>').should == '<b><br></b>'
|
286
287
|
end
|
287
288
|
|
288
|
-
it "
|
289
|
+
it "uses SafeBuffer if it is loaded" do
|
289
290
|
require 'active_support'
|
290
291
|
|
291
292
|
R18n::Filters.on(:global_escape_html)
|
data/spec/i18n_spec.rb
CHANGED
@@ -12,19 +12,19 @@ describe R18n::I18n do
|
|
12
12
|
R18n.extension_places = @extension_places
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "parses HTTP_ACCEPT_LANGUAGE" do
|
16
16
|
R18n::I18n.parse_http(nil).should == []
|
17
17
|
R18n::I18n.parse_http('').should == []
|
18
18
|
R18n::I18n.parse_http('ru,en;q=0.9').should == ['ru', 'en']
|
19
19
|
R18n::I18n.parse_http('ru;q=0.8,en;q=0.9').should == ['en', 'ru']
|
20
20
|
end
|
21
21
|
|
22
|
-
it "
|
22
|
+
it "has default locale" do
|
23
23
|
R18n::I18n.default = 'ru'
|
24
24
|
R18n::I18n.default.should == 'ru'
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "loads locales" do
|
28
28
|
i18n = R18n::I18n.new('en', DIR)
|
29
29
|
i18n.locales.should == [R18n.locale('en')]
|
30
30
|
|
@@ -35,12 +35,12 @@ describe R18n::I18n do
|
|
35
35
|
R18n.locale('en')]
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
38
|
+
it "returns translations loaders" do
|
39
39
|
i18n = R18n::I18n.new('en', DIR)
|
40
40
|
i18n.translation_places.should == [R18n::Loader::YAML.new(DIR)]
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
43
|
+
it "loads translations by loader" do
|
44
44
|
loader = Class.new do
|
45
45
|
def available; [R18n.locale('en')]; end
|
46
46
|
def load(locale); { 'custom' => 'Custom' }; end
|
@@ -48,7 +48,7 @@ describe R18n::I18n do
|
|
48
48
|
R18n::I18n.new('en', loader.new).custom.should == 'Custom'
|
49
49
|
end
|
50
50
|
|
51
|
-
it "
|
51
|
+
it "passes parameters to default loader" do
|
52
52
|
loader = Class.new do
|
53
53
|
def initialize(param); @param = param; end
|
54
54
|
def available; [R18n.locale('en')]; end
|
@@ -58,7 +58,7 @@ describe R18n::I18n do
|
|
58
58
|
R18n::I18n.new('en', 'default').custom.should == 'default'
|
59
59
|
end
|
60
60
|
|
61
|
-
it "
|
61
|
+
it "loads translations" do
|
62
62
|
i18n = R18n::I18n.new(['ru', 'en'], DIR)
|
63
63
|
i18n.one.should == 'Один'
|
64
64
|
i18n[:one].should == 'Один'
|
@@ -66,13 +66,13 @@ describe R18n::I18n do
|
|
66
66
|
i18n.only.english.should == 'Only in English'
|
67
67
|
end
|
68
68
|
|
69
|
-
it "
|
69
|
+
it "loads translations from several dirs" do
|
70
70
|
i18n = R18n::I18n.new(['nolocale', 'en'], [TWO, DIR])
|
71
71
|
i18n.in.two.should == 'Two'
|
72
72
|
i18n.in.another.level.should == 'Hierarchical'
|
73
73
|
end
|
74
74
|
|
75
|
-
it "
|
75
|
+
it "uses extension places" do
|
76
76
|
R18n.extension_places << EXT
|
77
77
|
|
78
78
|
i18n = R18n::I18n.new('en', DIR)
|
@@ -80,14 +80,14 @@ describe R18n::I18n do
|
|
80
80
|
i18n.one.should == 'One'
|
81
81
|
end
|
82
82
|
|
83
|
-
it "
|
83
|
+
it "doesn't use extension without app translations with same locale" do
|
84
84
|
R18n.extension_places << EXT
|
85
85
|
|
86
86
|
i18n = R18n::I18n.new(['notransl', 'en'], DIR)
|
87
87
|
i18n.ext.should == 'Extension'
|
88
88
|
end
|
89
89
|
|
90
|
-
it "
|
90
|
+
it "ignores case on loading" do
|
91
91
|
i18n = R18n::I18n.new('nolocale', [DIR])
|
92
92
|
i18n.one.should == 'ONE'
|
93
93
|
|
@@ -95,13 +95,13 @@ describe R18n::I18n do
|
|
95
95
|
i18n.one.should == 'ONE'
|
96
96
|
end
|
97
97
|
|
98
|
-
it "
|
98
|
+
it "loads default translation" do
|
99
99
|
i18n = R18n::I18n.new('nolocale', DIR)
|
100
100
|
i18n.one.should == 'ONE'
|
101
101
|
i18n.two.should == 'Two'
|
102
102
|
end
|
103
103
|
|
104
|
-
it "
|
104
|
+
it "loads sublocales for first locale" do
|
105
105
|
R18n::I18n.default = 'notransl'
|
106
106
|
|
107
107
|
i18n = R18n::I18n.new('ru', DIR)
|
@@ -109,14 +109,14 @@ describe R18n::I18n do
|
|
109
109
|
i18n.two.should == 'Two'
|
110
110
|
end
|
111
111
|
|
112
|
-
it "
|
112
|
+
it "returns available translations" do
|
113
113
|
i18n = R18n::I18n.new('en', DIR)
|
114
114
|
i18n.available_locales.should =~ [R18n.locale('nolocale'),
|
115
115
|
R18n.locale('ru'),
|
116
116
|
R18n.locale('en')]
|
117
117
|
end
|
118
118
|
|
119
|
-
it "
|
119
|
+
it "caches translations" do
|
120
120
|
counter = CounterLoader.new('en')
|
121
121
|
|
122
122
|
R18n::I18n.new('en', counter)
|
@@ -130,7 +130,7 @@ describe R18n::I18n do
|
|
130
130
|
counter.loaded.should == 2
|
131
131
|
end
|
132
132
|
|
133
|
-
it "
|
133
|
+
it "doesn't clear cache when custom filters are specified" do
|
134
134
|
counter = CounterLoader.new('en')
|
135
135
|
|
136
136
|
R18n::I18n.new('en', counter, :off_filters => :untranslated,
|
@@ -142,7 +142,7 @@ describe R18n::I18n do
|
|
142
142
|
counter.loaded.should == 1
|
143
143
|
end
|
144
144
|
|
145
|
-
it "
|
145
|
+
it "caches translations by used locales" do
|
146
146
|
counter = CounterLoader.new('en', 'ru')
|
147
147
|
|
148
148
|
R18n::I18n.new('en', counter)
|
@@ -158,7 +158,7 @@ describe R18n::I18n do
|
|
158
158
|
counter.loaded.should == 5
|
159
159
|
end
|
160
160
|
|
161
|
-
it "
|
161
|
+
it "caches translations by places" do
|
162
162
|
counter = CounterLoader.new('en', 'ru')
|
163
163
|
|
164
164
|
R18n::I18n.new('en', counter)
|
@@ -180,7 +180,7 @@ describe R18n::I18n do
|
|
180
180
|
different.loaded.should == 1
|
181
181
|
end
|
182
182
|
|
183
|
-
it "
|
183
|
+
it "reloads translations" do
|
184
184
|
loader = Class.new do
|
185
185
|
def available; [R18n.locale('en')]; end
|
186
186
|
def load(locale);
|
@@ -197,19 +197,19 @@ describe R18n::I18n do
|
|
197
197
|
i18n.one.should == 2
|
198
198
|
end
|
199
199
|
|
200
|
-
it "
|
200
|
+
it "returns translations" do
|
201
201
|
i18n = R18n::I18n.new('en', DIR)
|
202
202
|
i18n.t.should be_a(R18n::Translation)
|
203
203
|
i18n.t.one.should == 'One'
|
204
204
|
end
|
205
205
|
|
206
|
-
it "
|
206
|
+
it "returns first locale with locale file" do
|
207
207
|
i18n = R18n::I18n.new(['notransl', 'nolocale', 'ru', 'en'], DIR)
|
208
208
|
i18n.locale.should == R18n.locale('nolocale')
|
209
209
|
i18n.locale.base.should == R18n.locale('ru')
|
210
210
|
end
|
211
211
|
|
212
|
-
it "
|
212
|
+
it "localizes objects" do
|
213
213
|
i18n = R18n::I18n.new('ru')
|
214
214
|
|
215
215
|
i18n.l(-123456789).should == '−123 456 789'
|
@@ -224,7 +224,7 @@ describe R18n::I18n do
|
|
224
224
|
i18n.l(Date.new(0)).should == '01.01.0000'
|
225
225
|
end
|
226
226
|
|
227
|
-
it "
|
227
|
+
it "returns marshalizable values", :not_ruby => 1.8 do
|
228
228
|
i18n = R18n::I18n.new('en', DIR, :off_filters => :untranslated,
|
229
229
|
:on_filters => :untranslated_html)
|
230
230
|
demarsh = Marshal.load(Marshal.dump(i18n.t.one))
|