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/ChangeLog +13 -5
- data/base/bg.yml +31 -0
- data/base/ca.yml +20 -20
- data/base/cs.yml +26 -26
- data/base/da.yml +21 -21
- data/base/de.yml +23 -23
- data/base/en.yml +21 -21
- data/base/eo.yml +23 -23
- data/base/es.yml +22 -22
- data/base/fi.yml +23 -23
- data/base/fr.yml +22 -22
- data/base/hu.yml +15 -15
- data/base/it.yml +22 -22
- data/base/ja.yml +15 -15
- data/base/kk.yml +7 -7
- data/base/lv.yml +21 -21
- data/base/pl.yml +23 -23
- data/base/pt_br.yml +23 -23
- data/base/ru.yml +29 -29
- data/base/sk.yml +26 -26
- data/base/th.yml +17 -17
- data/base/zh.yml +17 -17
- data/lib/r18n-core/filters.rb +1 -1
- data/lib/r18n-core/locale.rb +8 -12
- data/lib/r18n-core/translated.rb +20 -10
- data/lib/r18n-core/utils.rb +13 -0
- data/lib/r18n-core/version.rb +1 -1
- data/lib/r18n-core/yaml_loader.rb +18 -1
- data/locales/bg.rb +20 -0
- data/locales/en-au.rb +9 -0
- data/spec/filters_spec.rb +3 -0
- data/spec/locale_spec.rb +25 -24
- data/spec/spec_helper.rb +4 -0
- data/spec/translated_spec.rb +28 -0
- data/spec/translations/general/en.yml +9 -9
- metadata +82 -79
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('
|
88
|
+
i18n = R18n::I18n.new('en')
|
89
89
|
|
90
|
-
@
|
91
|
-
@
|
92
|
-
@
|
93
|
-
@
|
94
|
-
@
|
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
|
-
|
97
|
-
@
|
98
|
-
@
|
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
|
-
|
106
|
+
p = [:human, R18n::I18n.new('en'), zero]
|
107
107
|
|
108
|
-
@
|
109
|
-
@
|
110
|
-
@
|
111
|
-
@
|
112
|
-
@
|
113
|
-
@
|
114
|
-
@
|
115
|
-
@
|
116
|
-
@
|
117
|
-
@
|
118
|
-
@
|
119
|
-
@
|
120
|
-
@
|
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
|
-
@
|
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
data/spec/translated_spec.rb
CHANGED
@@ -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
|
-
|
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:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
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:
|
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/
|
49
|
-
- base/
|
46
|
+
- base/fi.yml
|
47
|
+
- base/zh.yml
|
48
|
+
- base/th.yml
|
49
|
+
- base/es.yml
|
50
50
|
- base/ja.yml
|
51
|
-
- base/
|
52
|
-
- base/
|
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/
|
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/
|
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/
|
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/
|
69
|
-
- locales/
|
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/
|
80
|
+
- locales/sk.rb
|
72
81
|
- locales/th.rb
|
73
|
-
- locales/
|
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/
|
85
|
+
- locales/ru.rb
|
82
86
|
- locales/da.rb
|
83
|
-
- locales/
|
84
|
-
- locales/
|
85
|
-
- locales/
|
86
|
-
- locales/
|
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/
|
92
|
-
- spec/
|
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/
|
114
|
-
- spec/
|
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/
|
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/
|
153
|
-
- spec/
|
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/
|
175
|
-
- spec/
|
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/
|
179
|
+
- spec/yaml_loader_spec.rb
|
180
|
+
- spec/translated_spec.rb
|