twitter_cldr 1.3.0 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +58 -10
- data/Rakefile +25 -0
- data/lib/twitter_cldr.rb +16 -1
- data/lib/twitter_cldr/core_ext.rb +1 -0
- data/lib/twitter_cldr/core_ext/calendars/datetime.rb +14 -0
- data/lib/twitter_cldr/core_ext/calendars/timespan.rb +26 -0
- data/lib/twitter_cldr/formatters.rb +1 -0
- data/lib/twitter_cldr/formatters/calendars/datetime_formatter.rb +1 -6
- data/lib/twitter_cldr/formatters/calendars/timespan_formatter.rb +67 -0
- data/lib/twitter_cldr/formatters/numbers/number_formatter.rb +1 -1
- data/lib/twitter_cldr/tokenizers.rb +1 -0
- data/lib/twitter_cldr/tokenizers/base.rb +23 -9
- data/lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb +14 -8
- data/lib/twitter_cldr/tokenizers/calendars/datetime_tokenizer.rb +13 -9
- data/lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb +13 -7
- data/lib/twitter_cldr/tokenizers/calendars/timespan_tokenizer.rb +82 -0
- data/lib/twitter_cldr/tokenizers/numbers/number_tokenizer.rb +21 -14
- data/lib/twitter_cldr/tokenizers/token.rb +4 -0
- data/lib/twitter_cldr/version.rb +1 -1
- data/resources/locales/ar/units.yml +149 -0
- data/resources/locales/da/units.yml +79 -0
- data/resources/locales/de/units.yml +93 -0
- data/resources/locales/en/units.yml +65 -0
- data/resources/locales/es/units.yml +93 -0
- data/resources/locales/fa/units.yml +86 -0
- data/resources/locales/fi/units.yml +93 -0
- data/resources/locales/fil/units.yml +79 -0
- data/resources/locales/fr/units.yml +93 -0
- data/resources/locales/he/units.yml +79 -0
- data/resources/locales/hi/units.yml +79 -0
- data/resources/locales/hu/units.yml +72 -0
- data/resources/locales/id/units.yml +72 -0
- data/resources/locales/it/units.yml +79 -0
- data/resources/locales/ja/units.yml +72 -0
- data/resources/locales/ko/units.yml +72 -0
- data/resources/locales/ms/units.yml +86 -0
- data/resources/locales/nl/units.yml +79 -0
- data/resources/locales/pl/units.yml +135 -0
- data/resources/locales/pt/units.yml +93 -0
- data/resources/locales/ru/units.yml +135 -0
- data/resources/locales/sv/units.yml +93 -0
- data/resources/locales/th/units.yml +72 -0
- data/resources/locales/tr/units.yml +72 -0
- data/resources/locales/ur/units.yml +86 -0
- data/resources/locales/zh-Hant/units.yml +72 -0
- data/resources/locales/zh/units.yml +72 -0
- data/spec/core_ext/calendars/date_spec.rb +83 -9
- data/spec/core_ext/calendars/datetime_spec.rb +1 -3
- data/spec/core_ext/calendars/time_spec.rb +12 -3
- data/spec/formatters/calendars/timespan_formatter_spec.rb +39 -0
- data/spec/tokenizers/base_spec.rb +10 -10
- data/spec/tokenizers/calendars/timespan_tokenizer_spec.rb +24 -0
- data/spec/tokenizers/numbers/number_tokenizer_spec.rb +1 -1
- data/spec/twitter_cldr_spec.rb +16 -0
- metadata +126 -14
- data/lib/twitter_cldr/tokenizers/key_path.rb +0 -35
- data/spec/tokenizers/key_path_spec.rb +0 -49
@@ -0,0 +1,72 @@
|
|
1
|
+
zh-Hant:
|
2
|
+
units:
|
3
|
+
day:
|
4
|
+
other: "{0}日"
|
5
|
+
day-future:
|
6
|
+
0: "0 天後"
|
7
|
+
1: "1 天後"
|
8
|
+
other: "{0} 天後"
|
9
|
+
day-past:
|
10
|
+
0: "0 天前"
|
11
|
+
1: "1 天前"
|
12
|
+
other: "{0} 天前"
|
13
|
+
hour:
|
14
|
+
other: "{0}小時"
|
15
|
+
hour-future:
|
16
|
+
0: "0 小時後"
|
17
|
+
1: "1 小時後"
|
18
|
+
other: "{0} 小時後"
|
19
|
+
hour-past:
|
20
|
+
0: "0 小時前"
|
21
|
+
1: "1 小時前"
|
22
|
+
other: "{0} 小時前"
|
23
|
+
minute:
|
24
|
+
other: "{0}分"
|
25
|
+
minute-future:
|
26
|
+
0: "0 分鐘後"
|
27
|
+
1: "1 分鐘後"
|
28
|
+
other: "{0} 分鐘後"
|
29
|
+
minute-past:
|
30
|
+
0: "0 分鐘前"
|
31
|
+
1: "1 分鐘前"
|
32
|
+
other: "{0} 分鐘前"
|
33
|
+
month:
|
34
|
+
other: "{0}月"
|
35
|
+
month-future:
|
36
|
+
0: "0 個月後"
|
37
|
+
1: "1 個月後"
|
38
|
+
other: "{0} 個月後"
|
39
|
+
month-past:
|
40
|
+
0: "0 個月前"
|
41
|
+
1: "1 個月前"
|
42
|
+
other: "{0} 個月前"
|
43
|
+
second:
|
44
|
+
other: "{0}秒"
|
45
|
+
second-future:
|
46
|
+
0: "0 秒後"
|
47
|
+
1: "1 秒後"
|
48
|
+
other: "{0} 秒後"
|
49
|
+
second-past:
|
50
|
+
0: "0 秒前"
|
51
|
+
1: "1 秒前"
|
52
|
+
other: "{0} 秒前"
|
53
|
+
week:
|
54
|
+
other: "{0}週"
|
55
|
+
week-future:
|
56
|
+
0: "0 週後"
|
57
|
+
1: "1 週後"
|
58
|
+
other: "{0} 週後"
|
59
|
+
week-past:
|
60
|
+
0: "0 週前"
|
61
|
+
1: "1 週前"
|
62
|
+
other: "{0} 週前"
|
63
|
+
year:
|
64
|
+
other: "{0}年"
|
65
|
+
year-future:
|
66
|
+
0: "0 年後"
|
67
|
+
1: "1 年後"
|
68
|
+
other: "{0} 年後"
|
69
|
+
year-past:
|
70
|
+
0: "0 年前"
|
71
|
+
1: "1 年前"
|
72
|
+
other: "{0} 年前"
|
@@ -0,0 +1,72 @@
|
|
1
|
+
zh:
|
2
|
+
units:
|
3
|
+
day:
|
4
|
+
other: "{0}日"
|
5
|
+
day-future:
|
6
|
+
0: 0天后
|
7
|
+
1: 1天后
|
8
|
+
other: "{0}天后"
|
9
|
+
day-past:
|
10
|
+
0: 0天前
|
11
|
+
1: 1天前
|
12
|
+
other: "{0}天前"
|
13
|
+
hour:
|
14
|
+
other: "{0}小时"
|
15
|
+
hour-future:
|
16
|
+
0: 0小时后
|
17
|
+
1: 1小时后
|
18
|
+
other: "{0}小时后"
|
19
|
+
hour-past:
|
20
|
+
0: 0小时前
|
21
|
+
1: 1小时前
|
22
|
+
other: "{0}小时前"
|
23
|
+
minute:
|
24
|
+
other: "{0}分"
|
25
|
+
minute-future:
|
26
|
+
0: 0分钟后
|
27
|
+
1: 1分钟后
|
28
|
+
other: "{0}分钟后"
|
29
|
+
minute-past:
|
30
|
+
0: 0分钟前
|
31
|
+
1: 1分钟前
|
32
|
+
other: "{0}分钟前"
|
33
|
+
month:
|
34
|
+
other: "{0}月"
|
35
|
+
month-future:
|
36
|
+
0: 0个月后
|
37
|
+
1: 1个月后
|
38
|
+
other: "{0}个月后"
|
39
|
+
month-past:
|
40
|
+
0: 0个月前
|
41
|
+
1: 1个月前
|
42
|
+
other: "{0}个月前"
|
43
|
+
second:
|
44
|
+
other: "{0}秒"
|
45
|
+
second-future:
|
46
|
+
0: 0秒钟后
|
47
|
+
1: 1秒钟后
|
48
|
+
other: "{0}秒钟后"
|
49
|
+
second-past:
|
50
|
+
0: 0秒钟前
|
51
|
+
1: 1秒钟前
|
52
|
+
other: "{0}秒钟前"
|
53
|
+
week:
|
54
|
+
other: "{0}周"
|
55
|
+
week-future:
|
56
|
+
0: 0周后
|
57
|
+
1: 1周后
|
58
|
+
other: "{0}周后"
|
59
|
+
week-past:
|
60
|
+
0: 0周前
|
61
|
+
1: 1周前
|
62
|
+
other: "{0}周前"
|
63
|
+
year:
|
64
|
+
other: "{0}年"
|
65
|
+
year-future:
|
66
|
+
0: 0年后
|
67
|
+
1: 1年后
|
68
|
+
other: "{0}年后"
|
69
|
+
year-past:
|
70
|
+
0: 0年前
|
71
|
+
1: 1年前
|
72
|
+
other: "{0}年前"
|
@@ -9,33 +9,107 @@ include TwitterCldr
|
|
9
9
|
|
10
10
|
describe Date do
|
11
11
|
describe "#localize" do
|
12
|
+
before(:all) do
|
13
|
+
@date = Date.today
|
14
|
+
end
|
15
|
+
|
12
16
|
it "should localize with the given locale, English by default" do
|
13
|
-
|
14
|
-
loc_date = date.localize
|
17
|
+
loc_date = @date.localize
|
15
18
|
loc_date.should be_a(LocalizedDate)
|
16
19
|
loc_date.locale.should == :en
|
17
20
|
loc_date.calendar_type.should == :gregorian
|
18
|
-
loc_date.base_obj.should == date
|
21
|
+
loc_date.base_obj.should == @date
|
19
22
|
|
20
|
-
loc_date =
|
23
|
+
loc_date = @date.localize(:it)
|
21
24
|
loc_date.should be_a(LocalizedDate)
|
22
25
|
loc_date.locale.should == :it
|
23
26
|
end
|
24
27
|
|
25
28
|
it "should localize with the given calendar" do
|
26
|
-
|
27
|
-
loc_date = date.localize(:th, :calendar_type => :buddhist)
|
29
|
+
loc_date = @date.localize(:th, :calendar_type => :buddhist)
|
28
30
|
loc_date.should be_a(LocalizedDate)
|
29
31
|
loc_date.locale.should == :th
|
30
32
|
loc_date.calendar_type.should == :buddhist
|
31
|
-
loc_date.base_obj.should == date
|
33
|
+
loc_date.base_obj.should == @date
|
32
34
|
end
|
33
35
|
|
34
36
|
it "should forward calendar_type" do
|
35
|
-
|
36
|
-
loc_date = date.localize(:th, :calendar_type => :buddhist)
|
37
|
+
loc_date = @date.localize(:th, :calendar_type => :buddhist)
|
37
38
|
loc_date.to_datetime(Time.now).calendar_type.should == :buddhist
|
38
39
|
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "ago" do
|
44
|
+
let(:date) { Date.new(2010,7,6) }
|
45
|
+
let(:base_time) { Time.gm(2010,8,6,12,12,30) }
|
46
|
+
|
47
|
+
it "should ago-ify from now when no base_time given" do
|
48
|
+
stub(Time).now { Time.gm(2010,8,6,12,12,30) }
|
49
|
+
loc_date = date.localize(:ko)
|
50
|
+
loc_date.ago(:unit => :hour).should == "756시간 전"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should ago-ify with appropriate unit when no unit given" do
|
54
|
+
loc_date = date.localize(:en)
|
55
|
+
loc_date.ago(:base_time => base_time).should == "1 month ago"
|
56
|
+
loc_date.ago(:base_time => Time.gm(2010,12,6,12,12,30)).should == "5 months ago"
|
57
|
+
loc_date.ago(:base_time => Time.gm(2010,7,7,12,12,30)).should == "1 day ago"
|
58
|
+
loc_date.ago(:base_time => Time.gm(2010,7,6,12,12,30)).should == "12 hours ago"
|
59
|
+
loc_date.ago(:base_time => Time.gm(2010,7,6,0,39,0)).should == "39 minutes ago"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should ago-ify with strings regardless of variable's placement or existence" do
|
63
|
+
loc_date = date.localize(:ar)
|
64
|
+
loc_date.ago(:base_time => base_time, :unit => :hour).should == "قبل 756 ساعة"
|
65
|
+
loc_date.ago(:base_time => base_time, :unit => :day).should == "قبل 31 يومًا"
|
66
|
+
loc_date.ago(:base_time => base_time, :unit => :month).should == "قبل شهر واحد"
|
67
|
+
loc_date.ago(:base_time => base_time, :unit => :year).should == "قبل 0 سنة"
|
68
|
+
|
69
|
+
loc_date = date.localize(:fa)
|
70
|
+
loc_date.ago(:base_time => base_time, :unit => :day).should == "31 روز پیش"
|
71
|
+
|
72
|
+
loc_date = date.localize(:en)
|
73
|
+
loc_date.ago(:base_time => base_time, :unit => :day).should == "31 days ago"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should ago-ify a date with a number of different units" do
|
77
|
+
date = Date.new(2010,6,6)
|
78
|
+
loc_date = date.localize(:de)
|
79
|
+
loc_date.ago(:base_time => base_time, :unit => :second).should == "Vor 5314350 Sekunden"
|
80
|
+
loc_date.ago(:base_time => base_time, :unit => :minute).should == "Vor 88572 Minuten"
|
81
|
+
loc_date.ago(:base_time => base_time, :unit => :hour).should == "Vor 1476 Stunden"
|
82
|
+
loc_date.ago(:base_time => base_time, :unit => :day).should == "Vor 61 Tagen"
|
83
|
+
loc_date.ago(:base_time => base_time, :unit => :month).should == "Vor 2 Monaten"
|
84
|
+
loc_date.ago(:base_time => base_time, :unit => :year).should == "Vor 0 Jahren"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should return an error if called on a date in the future" do
|
88
|
+
date = Date.new(2010,10,10)
|
89
|
+
loc_date = date.localize(:de)
|
90
|
+
lambda { loc_date.ago(base_time, :second)}.should raise_error(ArgumentError)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "until" do
|
95
|
+
let(:base_time) { Time.gm(2010,8,6,12,12,30) }
|
96
|
+
|
97
|
+
it "should until-ify with a number of different units" do
|
98
|
+
date = Date.new(2010,10,10)
|
99
|
+
loc_date = date.localize(:de)
|
100
|
+
loc_date.until(:base_time => base_time, :unit => :second).should == "In 5572050 Sekunden"
|
101
|
+
loc_date.until(:base_time => base_time, :unit => :minute).should == "In 92867 Minuten"
|
102
|
+
loc_date.until(:base_time => base_time, :unit => :hour).should == "In 1547 Stunden"
|
103
|
+
loc_date.until(:base_time => base_time, :unit => :day).should == "In 64 Tagen"
|
104
|
+
loc_date.until(:base_time => base_time, :unit => :month).should == "In 2 Monaten"
|
105
|
+
loc_date.until(:base_time => base_time, :unit => :year).should == "In 0 Jahren"
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should return an error if called on a date in the past" do
|
109
|
+
date = Date.new(2010,4,4)
|
110
|
+
loc_date = date.localize(:de)
|
111
|
+
lambda { loc_date.until(base_time, :second)}.should raise_error(ArgumentError)
|
112
|
+
end
|
39
113
|
end
|
40
114
|
|
41
115
|
describe "stringify" do
|
@@ -9,8 +9,8 @@ include TwitterCldr
|
|
9
9
|
|
10
10
|
describe DateTime do
|
11
11
|
describe "#localize" do
|
12
|
+
let(:date) { DateTime.now }
|
12
13
|
it "should localize with the given locale, English by default" do
|
13
|
-
date = DateTime.now
|
14
14
|
loc_date = date.localize
|
15
15
|
loc_date.should be_a(LocalizedDateTime)
|
16
16
|
loc_date.locale.should == :en
|
@@ -23,7 +23,6 @@ describe DateTime do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should localize with the given calendar" do
|
26
|
-
date = DateTime.now
|
27
26
|
loc_date = date.localize(:th, :calendar_type => :buddhist)
|
28
27
|
loc_date.should be_a(LocalizedDateTime)
|
29
28
|
loc_date.locale.should == :th
|
@@ -32,7 +31,6 @@ describe DateTime do
|
|
32
31
|
end
|
33
32
|
|
34
33
|
it "should forward calendar_type" do
|
35
|
-
date = DateTime.now
|
36
34
|
loc_date = date.localize(:th, :calendar_type => :buddhist)
|
37
35
|
loc_date.to_date.calendar_type.should == :buddhist
|
38
36
|
loc_date.to_time.calendar_type.should == :buddhist
|
@@ -9,8 +9,9 @@ include TwitterCldr
|
|
9
9
|
|
10
10
|
describe Time do
|
11
11
|
describe "#localize" do
|
12
|
+
let (:time) { Time.now }
|
13
|
+
|
12
14
|
it "should localize with the given locale, English by default" do
|
13
|
-
time = Time.now
|
14
15
|
loc_time = time.localize
|
15
16
|
loc_time.should be_a(LocalizedTime)
|
16
17
|
loc_time.locale.should == :en
|
@@ -23,7 +24,6 @@ describe Time do
|
|
23
24
|
end
|
24
25
|
|
25
26
|
it "should localize with the given calendar" do
|
26
|
-
time = Time.now
|
27
27
|
loc_time = time.localize(:th, :calendar_type => :buddhist)
|
28
28
|
loc_time.should be_a(LocalizedTime)
|
29
29
|
loc_time.locale.should == :th
|
@@ -32,7 +32,6 @@ describe Time do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should forward calendar_type" do
|
35
|
-
time = Time.now
|
36
35
|
loc_time = time.localize(:th, :calendar_type => :buddhist)
|
37
36
|
loc_time.to_datetime(Date.today).calendar_type.should == :buddhist
|
38
37
|
end
|
@@ -60,6 +59,16 @@ describe Time do
|
|
60
59
|
end
|
61
60
|
end
|
62
61
|
|
62
|
+
describe "#ago" do
|
63
|
+
it "should ago-ify a time with a number of different units" do
|
64
|
+
time = Time.now
|
65
|
+
base_time = time + 172800
|
66
|
+
loc_time = time.localize(:de)
|
67
|
+
loc_time.ago({:base_time => base_time, :unit => :hour}).should == "Vor 48 Stunden"
|
68
|
+
loc_time.ago({:base_time => base_time, :unit => :day}).should == "Vor 2 Tagen"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
63
72
|
describe LocalizedTime do
|
64
73
|
describe "#to_datetime" do
|
65
74
|
it "should combine a date and a time object into a datetime" do
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Copyright 2012 Twitter, Inc
|
4
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
include TwitterCldr::Formatters
|
9
|
+
|
10
|
+
describe TimespanFormatter do
|
11
|
+
|
12
|
+
describe "#format" do
|
13
|
+
let(:formatter) { TimespanFormatter.new(:locale => :de) }
|
14
|
+
|
15
|
+
describe "#ago" do
|
16
|
+
it "works for a variety of units" do
|
17
|
+
formatter.format(-3273932, :year).should == 'Vor 0 Jahren'
|
18
|
+
formatter.format(-3273932, :month).should == 'Vor 1 Monat'
|
19
|
+
formatter.format(-3273932, :week).should == 'Vor 5 Wochen'
|
20
|
+
formatter.format(-3273932, :day).should == 'Vor 37 Tagen'
|
21
|
+
formatter.format(-3273932, :hour).should == 'Vor 909 Stunden'
|
22
|
+
formatter.format(-3273932, :minute).should == 'Vor 54565 Minuten'
|
23
|
+
formatter.format(-3273932, :second).should == 'Vor 3273932 Sekunden'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#until" do
|
28
|
+
it "works for a variety of units" do
|
29
|
+
formatter.format(3273932, :year).should == 'In 0 Jahren'
|
30
|
+
formatter.format(3273932, :month).should == 'In 1 Monat'
|
31
|
+
formatter.format(3273932, :week).should == 'In 5 Wochen'
|
32
|
+
formatter.format(3273932, :day).should == 'In 37 Tagen'
|
33
|
+
formatter.format(3273932, :hour).should == 'In 909 Stunden'
|
34
|
+
formatter.format(3273932, :minute).should == 'In 54565 Minuten'
|
35
|
+
formatter.format(3273932, :second).should == 'In 3273932 Sekunden'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -86,7 +86,7 @@ describe Base do
|
|
86
86
|
|
87
87
|
describe "#expand_pattern" do
|
88
88
|
it "recursively calls expand_pattern if a symbol (keypath) is given" do
|
89
|
-
mock(@base).traverse(:
|
89
|
+
mock(@base).traverse([:another, :path]) { "found_me" }
|
90
90
|
mock(@base).pattern_for("found_me") { "pattern_text" }
|
91
91
|
mock.proxy(@base).expand_pattern("pattern_text", :fake_type)
|
92
92
|
mock.proxy(@base).expand_pattern(:'another.path', :fake_type)
|
@@ -111,36 +111,36 @@ describe Base do
|
|
111
111
|
let(:token2) { Token.new(:value => "token2", :type => :plaintext) }
|
112
112
|
|
113
113
|
before(:each) do
|
114
|
-
stub(@base).traverse(
|
114
|
+
stub(@base).traverse([:fake_key]) { "fake_pattern" }
|
115
115
|
stub(@base).pattern_for("fake_pattern") { "fake_expandable_pattern" }
|
116
116
|
stub(@base).expand_pattern("fake_expandable_pattern", "fake_type") { [token1, token2] }
|
117
117
|
end
|
118
118
|
|
119
119
|
it "caches tokens" do
|
120
|
-
result = @base.send(:tokens_for,
|
120
|
+
result = @base.send(:tokens_for, [:fake_key], "fake_type")
|
121
121
|
result[0].value.should == "token1"
|
122
122
|
result[1].value.should == "token2"
|
123
123
|
@base.class.send(:class_variable_get, :'@@token_cache')["en|fake_key|fake_type".hash].should == result
|
124
124
|
|
125
|
-
result_again = @base.send(:tokens_for,
|
125
|
+
result_again = @base.send(:tokens_for, [:fake_key], "fake_type")
|
126
126
|
result_again.object_id.should == result.object_id
|
127
127
|
end
|
128
128
|
|
129
129
|
it "caches tokens per language" do
|
130
|
-
result_en = @base.send(:tokens_for,
|
130
|
+
result_en = @base.send(:tokens_for, [:fake_key], "fake_type")
|
131
131
|
result_en[0].value.should == "token1"
|
132
132
|
result_en[1].value.should == "token2"
|
133
133
|
@base.class.send(:class_variable_get, :'@@token_cache')["en|fake_key|fake_type".hash].should == result_en
|
134
|
-
result_en2 = @base.send(:tokens_for,
|
134
|
+
result_en2 = @base.send(:tokens_for, [:fake_key], "fake_type")
|
135
135
|
result_en2.object_id.should == result_en.object_id
|
136
136
|
|
137
137
|
@base.instance_variable_set(:'@locale', :pt)
|
138
|
-
result_pt = @base.send(:tokens_for,
|
138
|
+
result_pt = @base.send(:tokens_for, [:fake_key], "fake_type")
|
139
139
|
result_pt[0].value.should == "token1"
|
140
140
|
result_pt[1].value.should == "token2"
|
141
141
|
@base.class.send(:class_variable_get, :'@@token_cache')["pt|fake_key|fake_type".hash].should == result_pt
|
142
142
|
result_pt.object_id.should_not == result_en.object_id
|
143
|
-
result_pt2 = @base.send(:tokens_for,
|
143
|
+
result_pt2 = @base.send(:tokens_for, [:fake_key], "fake_type")
|
144
144
|
result_pt2.object_id.should == result_pt.object_id
|
145
145
|
result_pt2.object_id.should_not == result_en.object_id
|
146
146
|
result_pt2.object_id.should_not == result_en2.object_id
|
@@ -163,11 +163,11 @@ describe Base do
|
|
163
163
|
end
|
164
164
|
|
165
165
|
it "should find the correct value in the hash" do
|
166
|
-
@base.send(:traverse, :
|
166
|
+
@base.send(:traverse, [:admiral, :captain, :commander, :lieutenant], @tree).should == "Found Me!"
|
167
167
|
end
|
168
168
|
|
169
169
|
it "shouldn't choke if the path doesn't exist" do
|
170
|
-
@base.send(:traverse, :
|
170
|
+
@base.send(:traverse, [:admiral, :captain, :commander, :lieutenant, :ensign], @tree).should == nil
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Copyright 2012 Twitter, Inc
|
4
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
include TwitterCldr::Tokenizers
|
9
|
+
|
10
|
+
describe TimespanTokenizer do
|
11
|
+
|
12
|
+
describe "#tokens" do
|
13
|
+
|
14
|
+
it "should return the correct list of tokens" do
|
15
|
+
tokenizer = TimespanTokenizer.new(:locale => :es)
|
16
|
+
got = tokenizer.tokens(:unit => :minute, :direction => :ago, :number => 7659)
|
17
|
+
|
18
|
+
got[0].should == { :value => "Hace ", :type => :plaintext }
|
19
|
+
got[1].should == { :value => "{0}", :type => :placeholder }
|
20
|
+
got[2].should == { :value => " minutos", :type => :plaintext }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|