r18n-core 0.4.8 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
data/spec/filters_spec.rb CHANGED
@@ -28,12 +28,15 @@ describe R18n::Filters do
28
28
  filter.should be_enabled
29
29
 
30
30
  R18n::Filters.defined.should have_key(:my_filter)
31
+
32
+ @i18n.reload!
31
33
  @i18n.my_filter.should == 'value'
32
34
  @i18n.my_tree_filter.should == {'name' => 'value'}
33
35
  end
34
36
 
35
37
  it "should add filter for several types" do
36
38
  filter = R18n::Filters.add(['my', 'your']) { |i, config| i + '1' }
39
+ @i18n.reload!
37
40
  @i18n.my_filter.should == 'value1'
38
41
  @i18n.your_filter.should == 'another1'
39
42
  end
data/spec/locale_spec.rb CHANGED
@@ -85,17 +85,17 @@ describe R18n::Locale do
85
85
  end
86
86
 
87
87
  it "should localize date for human" do
88
- i18n = R18n::I18n.new('ru')
88
+ i18n = R18n::I18n.new('en')
89
89
 
90
- @ru.localize(Date.today + 2, :human, i18n).should == 'через 2 дня'
91
- @ru.localize(Date.today + 1, :human, i18n).should == 'завтра'
92
- @ru.localize(Date.today, :human, i18n).should == 'сегодня'
93
- @ru.localize(Date.today - 1, :human, i18n).should == 'вчера'
94
- @ru.localize(Date.today - 3, :human, i18n).should == '3 дня назад'
90
+ @en.localize(Date.today + 2, :human, i18n).should == 'after 2 days'
91
+ @en.localize(Date.today + 1, :human, i18n).should == 'tomorrow'
92
+ @en.localize(Date.today, :human, i18n).should == 'today'
93
+ @en.localize(Date.today - 1, :human, i18n).should == 'yesterday'
94
+ @en.localize(Date.today - 3, :human, i18n).should == '3 days ago'
95
95
 
96
- y2000 = Date.parse('2000-01-08')
97
- @ru.localize(y2000, :human, i18n, y2000 + 8 ).should == ' 8 января'
98
- @ru.localize(y2000, :human, i18n, y2000 - 365).should == ' 8 января 2000'
96
+ y2k = Date.parse('2000-01-08')
97
+ @en.localize(y2k, :human, i18n, y2k + 8 ).should == '8th of January'
98
+ @en.localize(y2k, :human, i18n, y2k - 365).should == '8th of January, 2000'
99
99
  end
100
100
 
101
101
  it "should localize times for human" do
@@ -103,23 +103,24 @@ describe R18n::Locale do
103
103
  hour = 60 * minute
104
104
  day = 24 * hour
105
105
  zero = Time.at(0).utc
106
- params = [:human, R18n::I18n.new('ru'), zero]
106
+ p = [:human, R18n::I18n.new('en'), zero]
107
107
 
108
- @ru.localize( zero + 7 * day, *params).should == ' 8 января 00:00'
109
- @ru.localize( zero + 50 * hour, *params).should == 'через 2 дня 02:00'
110
- @ru.localize( zero + 25 * hour, *params).should == 'завтра 01:00'
111
- @ru.localize( zero + 70 * minute, *params).should == 'через 1 час'
112
- @ru.localize( zero + hour, *params).should == 'через 1 час'
113
- @ru.localize( zero + 38 * minute, *params).should == 'через 38 минут'
114
- @ru.localize( zero + 5, *params).should == 'сейчас'
115
- @ru.localize( zero - 15, *params).should == 'сейчас'
116
- @ru.localize( zero - minute, *params).should == '1 минуту назад'
117
- @ru.localize( zero - 2 * hour, *params).should == '2 часа назад'
118
- @ru.localize( zero - 13 * hour, *params).should == 'вчера 11:00'
119
- @ru.localize( zero - 50 * hour, *params).should == '3 дня назад 22:00'
120
- @ru.localize( zero - 9 * day, *params).should == '23 декабря 1969 00:00'
108
+ @en.localize( zero + 7 * day, *p).should == '8th of January 00:00'
109
+ @en.localize( zero + 50 * hour, *p).should == 'after 2 days 02:00'
110
+ @en.localize( zero + 25 * hour, *p).should == 'tomorrow 01:00'
111
+ @en.localize( zero + 70 * minute, *p).should == 'after 1 hour'
112
+ @en.localize( zero + hour, *p).should == 'after 1 hour'
113
+ @en.localize( zero + 38 * minute, *p).should == 'after 38 minutes'
114
+ @en.localize( zero + 5, *p).should == 'now'
115
+ @en.localize( zero - 15, *p).should == 'now'
116
+ @en.localize( zero - minute, *p).should == '1 minute ago'
117
+ @en.localize( zero - hour + 59, *p).should == '59 minutes ago'
118
+ @en.localize( zero - 2 * hour, *p).should == '2 hours ago'
119
+ @en.localize( zero - 13 * hour, *p).should == 'yesterday 11:00'
120
+ @en.localize( zero - 50 * hour, *p).should == '3 days ago 22:00'
121
121
 
122
- @ru.localize( zero - 365 * day, *params).should == ' 1 января 1969 00:00'
122
+ @en.localize( zero - 9 * day, *p).should == '23rd of December, 1969 00:00'
123
+ @en.localize( zero - 365 * day, *p).should == '1st of January, 1969 00:00'
123
124
  end
124
125
 
125
126
  it "should use standard formatter by default" do
data/spec/spec_helper.rb CHANGED
@@ -37,3 +37,7 @@ class CounterLoader
37
37
  @available.hash
38
38
  end
39
39
  end
40
+
41
+ if not ENV['test_syck'] and '1.8.' != RUBY_VERSION[0..3]
42
+ YAML::ENGINE.yamler = 'psych'
43
+ end
@@ -7,6 +7,9 @@ describe R18n::Translated do
7
7
  @user_class = Class.new do
8
8
  include R18n::Translated
9
9
  attr_accessor :name_ru, :name_en
10
+
11
+ def name_ru?; end
12
+ def name_ru!; end
10
13
  end
11
14
  R18n.set(R18n::I18n.new('en'))
12
15
  end
@@ -105,4 +108,29 @@ describe R18n::Translated do
105
108
  obj.no.untranslated_path.should == 'no'
106
109
  end
107
110
 
111
+ it "should translate virtual methods" do
112
+ @virtual_class = Class.new do
113
+ include R18n::Translated
114
+ translation :no_method, :methods => { :en => :no_method_en }
115
+ def method_missing(name, *params)
116
+ name.to_s
117
+ end
118
+ end
119
+ virtual = @virtual_class.new
120
+
121
+ virtual.no_method.should == 'no_method_en'
122
+ end
123
+
124
+ it "should return original type of result" do
125
+ @user_class.class_eval do
126
+ translation :name
127
+ def name_en
128
+ :ivan
129
+ end
130
+ end
131
+ user = @user_class.new
132
+
133
+ user.name.should == :ivan
134
+ end
135
+
108
136
  end
@@ -10,21 +10,21 @@ in:
10
10
  only:
11
11
  english: Only in English
12
12
 
13
- sum: !!proc |x, y| x + y
13
+ sum: !!proc "|x, y| x + y"
14
14
 
15
15
  comments: !!pl
16
- 0: no comments for %2
17
- 1: one comment for %2
18
- n: %1 comments for %2
16
+ 0: "no comments for %2"
17
+ 1: "one comment for %2"
18
+ n: "%1 comments for %2"
19
19
 
20
20
  files: !!pl
21
- 1: 1 file
22
- n: %1 files
21
+ 1: "1 file"
22
+ n: "%1 files"
23
23
 
24
24
  your_filter: !!your another
25
25
  my_filter: !!my value
26
26
  my_tree_filter: !!my
27
- name: value
27
+ name: value
28
28
 
29
29
  html: !!escape
30
30
  <script>true && false</script>
@@ -33,8 +33,8 @@ no_escape: !!html
33
33
  <b>Warning</b>
34
34
 
35
35
  markdown:
36
- simple: !!markdown **Hi!**
37
- html: !!markdown **Hi!** <br />
36
+ simple: !!markdown "**Hi!**"
37
+ html: !!markdown "**Hi!** <br />"
38
38
 
39
39
  textile:
40
40
  simple: !!textile _Hi!_
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r18n-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 8
10
- version: 0.4.8
9
+ - 9
10
+ version: 0.4.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrey "A.I." Sitnik
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-22 00:00:00 +04:00
18
+ date: 2011-02-06 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -30,90 +30,93 @@ extra_rdoc_files:
30
30
  - LICENSE
31
31
  - ChangeLog
32
32
  files:
33
- - base/th.yml
34
- - base/zh.yml
35
33
  - base/eo.yml
34
+ - base/lv.yml
36
35
  - base/hu.yml
36
+ - base/pt_br.yml
37
+ - base/en.yml
38
+ - base/da.yml
37
39
  - base/pl.yml
38
- - base/sk.yml
39
40
  - base/kk.yml
40
- - base/es.yml
41
- - base/da.yml
42
- - base/fi.yml
43
- - base/lv.yml
44
- - base/de.yml
45
- - base/en.yml
46
41
  - base/ca.yml
42
+ - base/de.yml
43
+ - base/cs.yml
44
+ - base/fr.yml
47
45
  - base/it.yml
48
- - base/ru.yml
49
- - base/pt_br.yml
46
+ - base/fi.yml
47
+ - base/zh.yml
48
+ - base/th.yml
49
+ - base/es.yml
50
50
  - base/ja.yml
51
- - base/fr.yml
52
- - base/cs.yml
51
+ - base/ru.yml
52
+ - base/sk.yml
53
+ - base/bg.yml
54
+ - lib/r18n-core.rb
55
+ - lib/r18n-core/locale.rb
56
+ - lib/r18n-core/translation.rb
57
+ - lib/r18n-core/translated_string.rb
53
58
  - lib/r18n-core/version.rb
54
59
  - lib/r18n-core/i18n.rb
60
+ - lib/r18n-core/untranslated.rb
55
61
  - lib/r18n-core/translated.rb
56
- - lib/r18n-core/translation.rb
57
- - lib/r18n-core/unsupported_locale.rb
62
+ - lib/r18n-core/utils.rb
58
63
  - lib/r18n-core/yaml_loader.rb
59
- - lib/r18n-core/untranslated.rb
60
- - lib/r18n-core/translated_string.rb
61
- - lib/r18n-core/filters.rb
64
+ - lib/r18n-core/unsupported_locale.rb
62
65
  - lib/r18n-core/helpers.rb
63
- - lib/r18n-core/utils.rb
64
- - lib/r18n-core/locale.rb
65
- - lib/r18n-core.rb
66
- - locales/pl.rb
66
+ - lib/r18n-core/filters.rb
67
67
  - locales/es.rb
68
- - locales/fi.rb
69
- - locales/sk.rb
68
+ - locales/lv.rb
69
+ - locales/de.rb
70
+ - locales/kk.rb
71
+ - locales/ca.rb
72
+ - locales/zh.rb
73
+ - locales/bg.rb
74
+ - locales/en-au.rb
75
+ - locales/pt-br.rb
76
+ - locales/pl.rb
77
+ - locales/en.rb
78
+ - locales/hu.rb
70
79
  - locales/eo.rb
71
- - locales/cs.rb
80
+ - locales/sk.rb
72
81
  - locales/th.rb
73
- - locales/it.rb
74
- - locales/en.rb
75
- - locales/zh.rb
82
+ - locales/en-gb.rb
76
83
  - locales/fr.rb
77
- - locales/kk.rb
78
- - locales/lv.rb
79
- - locales/ru.rb
80
84
  - locales/en-us.rb
81
- - locales/ja.rb
85
+ - locales/ru.rb
82
86
  - locales/da.rb
83
- - locales/en-gb.rb
84
- - locales/de.rb
85
- - locales/hu.rb
86
- - locales/pt-br.rb
87
- - locales/ca.rb
87
+ - locales/fi.rb
88
+ - locales/it.rb
89
+ - locales/ja.rb
90
+ - locales/cs.rb
88
91
  - LICENSE
89
92
  - ChangeLog
90
93
  - README.rdoc
91
- - spec/yaml_loader_spec.rb
92
- - spec/translations/general/no-lc.yml
93
- - spec/translations/general/en.yml
94
- - spec/translations/general/ru.yml
95
- - spec/translations/two/en.yml
96
- - spec/translations/two/fr.yml
97
- - spec/translations/extension/no-tr.yml
98
- - spec/translations/extension/en.yml
99
- - spec/translations/extension/deep/en.yml
94
+ - spec/translation_spec.rb
95
+ - spec/r18n_spec.rb
100
96
  - spec/spec_helper.rb
97
+ - spec/locale_spec.rb
101
98
  - spec/i18n_spec.rb
102
- - spec/translation_spec.rb
103
- - spec/locales/hu_spec.rb
104
- - spec/locales/en-us_spec.rb
105
- - spec/locales/cs_spec.rb
106
- - spec/locales/sk_spec.rb
107
- - spec/locales/ru_spec.rb
108
- - spec/locales/fr_spec.rb
109
99
  - spec/locales/th_spec.rb
110
100
  - spec/locales/en_spec.rb
101
+ - spec/locales/cs_spec.rb
102
+ - spec/locales/sk_spec.rb
111
103
  - spec/locales/it_spec.rb
104
+ - spec/locales/fr_spec.rb
105
+ - spec/locales/en-us_spec.rb
112
106
  - spec/locales/pl_spec.rb
113
- - spec/translated_spec.rb
114
- - spec/r18n_spec.rb
107
+ - spec/locales/hu_spec.rb
108
+ - spec/locales/ru_spec.rb
109
+ - spec/translations/two/en.yml
110
+ - spec/translations/two/fr.yml
111
+ - spec/translations/general/en.yml
112
+ - spec/translations/general/no-lc.yml
113
+ - spec/translations/general/ru.yml
114
+ - spec/translations/extension/en.yml
115
+ - spec/translations/extension/no-tr.yml
116
+ - spec/translations/extension/deep/en.yml
115
117
  - spec/filters_spec.rb
116
- - spec/locale_spec.rb
118
+ - spec/yaml_loader_spec.rb
119
+ - spec/translated_spec.rb
117
120
  has_rdoc: true
118
121
  homepage: http://r18n.rubyforge.org/
119
122
  licenses: []
@@ -149,29 +152,29 @@ signing_key:
149
152
  specification_version: 3
150
153
  summary: I18n tool to translate your Ruby application.
151
154
  test_files:
152
- - spec/yaml_loader_spec.rb
153
- - spec/translations/general/no-lc.yml
154
- - spec/translations/general/en.yml
155
- - spec/translations/general/ru.yml
156
- - spec/translations/two/en.yml
157
- - spec/translations/two/fr.yml
158
- - spec/translations/extension/no-tr.yml
159
- - spec/translations/extension/en.yml
160
- - spec/translations/extension/deep/en.yml
155
+ - spec/translation_spec.rb
156
+ - spec/r18n_spec.rb
161
157
  - spec/spec_helper.rb
158
+ - spec/locale_spec.rb
162
159
  - spec/i18n_spec.rb
163
- - spec/translation_spec.rb
164
- - spec/locales/hu_spec.rb
165
- - spec/locales/en-us_spec.rb
166
- - spec/locales/cs_spec.rb
167
- - spec/locales/sk_spec.rb
168
- - spec/locales/ru_spec.rb
169
- - spec/locales/fr_spec.rb
170
160
  - spec/locales/th_spec.rb
171
161
  - spec/locales/en_spec.rb
162
+ - spec/locales/cs_spec.rb
163
+ - spec/locales/sk_spec.rb
172
164
  - spec/locales/it_spec.rb
165
+ - spec/locales/fr_spec.rb
166
+ - spec/locales/en-us_spec.rb
173
167
  - spec/locales/pl_spec.rb
174
- - spec/translated_spec.rb
175
- - spec/r18n_spec.rb
168
+ - spec/locales/hu_spec.rb
169
+ - spec/locales/ru_spec.rb
170
+ - spec/translations/two/en.yml
171
+ - spec/translations/two/fr.yml
172
+ - spec/translations/general/en.yml
173
+ - spec/translations/general/no-lc.yml
174
+ - spec/translations/general/ru.yml
175
+ - spec/translations/extension/en.yml
176
+ - spec/translations/extension/no-tr.yml
177
+ - spec/translations/extension/deep/en.yml
176
178
  - spec/filters_spec.rb
177
- - spec/locale_spec.rb
179
+ - spec/yaml_loader_spec.rb
180
+ - spec/translated_spec.rb