Skip to content

Commit c2c4626

Browse files
dgilperezgreysteil
authored andcommitted
change strftime into I18n.l accross the code and add spanish ES locale and test
1 parent c16470b commit c2c4626

File tree

6 files changed

+242
-59
lines changed

6 files changed

+242
-59
lines changed

config/locales/es.yml

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
es:
2+
ice_cube:
3+
pieces_connector: ', '
4+
not: 'excepto %{target}'
5+
not_on: 'excepto el %{target}'
6+
date:
7+
formats:
8+
default: '%-d de %B de %Y'
9+
month_names:
10+
-
11+
- Enero
12+
- Febrero
13+
- Marzo
14+
- Abril
15+
- Mayo
16+
- Junio
17+
- Julio
18+
- Agosto
19+
- Septiembre
20+
- Octubre
21+
- Noviembre
22+
- Diciembre
23+
day_names:
24+
- Domingo
25+
- Lunes
26+
- Martes
27+
- Miércoles
28+
- Jueves
29+
- Viernes
30+
- Sábado
31+
times:
32+
other: '%{count} veces'
33+
one: '%{count} vez'
34+
until: 'hasta el %{date}'
35+
days_of_week: '%{segments} %{day}'
36+
days_of_month:
37+
other: 'los días %{segments} del mes'
38+
one: 'el día %{segments} del mes'
39+
days_of_year:
40+
one: 'el día %{segments}'
41+
other: 'los días %{segments}'
42+
at_hours_of_the_day:
43+
one: 'en la hora %{segments}'
44+
other: 'en las horas %{segments}'
45+
on_minutes_of_hour:
46+
one: 'en el minuto %{segments}'
47+
other: 'en los minutos %{segments}'
48+
at_seconds_of_minute:
49+
one: 'en el segundo %{segments}'
50+
other: 'en los segundos %{segments}'
51+
on_seconds_of_minute:
52+
one: 'en el segundo %{segments} del minuto'
53+
other: 'en los segundos %{segments} del minuto'
54+
on_days: '%{days}'
55+
each_second:
56+
one: Cada segundo
57+
other: 'Cada %{count} segundos'
58+
each_minute:
59+
one: Cada minuto
60+
other: 'Cada %{count} minutos'
61+
each_hour:
62+
one: Cada hora
63+
other: 'Cada %{count} horas'
64+
each_day:
65+
one: Diariamente
66+
other: 'Cada %{count} días'
67+
each_week:
68+
one: Semanalmente
69+
other: 'Cada %{count} semanas'
70+
each_month:
71+
one: Mensualmente
72+
other: 'Cada %{count} meses'
73+
each_year:
74+
one: Anualmente
75+
other: 'Cada %{count} años'
76+
'on': 'en %{sentence}'
77+
in: 'en %{target}'
78+
integer:
79+
negative: '%{ordinal} por la cola'
80+
literal_ordinals:
81+
-1: el último
82+
-2: el penúltimo
83+
ordinal: '%{number}%{ordinal}'
84+
ordinals:
85+
default: º
86+
1: º
87+
2: º
88+
3: º
89+
11: º
90+
12: º
91+
13: º
92+
on_weekends: en fin de semana
93+
on_weekdays: en días laborables
94+
days_on:
95+
- los domingos
96+
- los lunes
97+
- los martes
98+
- los miércoles
99+
- los jueves
100+
- los viernes
101+
- los sábados
102+
on_days: '%{days}'
103+
array:
104+
last_word_connector: ' y '
105+
two_words_connector: ' y '
106+
words_connector: ', '
107+
string:
108+
format:
109+
day: '%{rest} %{current}'
110+
day_of_week: '%{rest} %{current}'
111+
day_of_month: '%{rest} %{current}'
112+
day_of_year: '%{rest} %{current}'
113+
hour_of_day: '%{rest} %{current}'
114+
minute_of_hour: '%{rest} %{current}'
115+
until: '%{rest} %{current}'
116+
count: '%{rest} %{current}'
117+
default: '%{rest} %{current}'
118+
119+
date:
120+
day_names:
121+
- Domingo
122+
- Lunes
123+
- Martes
124+
- Miércoles
125+
- Jueves
126+
- Viernes
127+
- Sábado
128+
abbr_day_names:
129+
- Dom
130+
- Lun
131+
- Mar
132+
- Mie
133+
- Jue
134+
- Vie
135+
- Sab
136+
# Don't forget the nil at the beginning; there's no such thing as a 0th month
137+
month_names:
138+
-
139+
- Enero
140+
- Febrero
141+
- Marzo
142+
- Abril
143+
- Mayo
144+
- Junio
145+
- Julio
146+
- Agosto
147+
- Septiembre
148+
- Octubre
149+
- Noviembre
150+
- Diciembre
151+
abbr_month_names:
152+
-
153+
- Ene
154+
- Feb
155+
- Mar
156+
- Abr
157+
- May
158+
- Jun
159+
- Jul
160+
- Ago
161+
- Sep
162+
- Oct
163+
- Nov
164+
- Dic
165+
formats:
166+
default: '%d/%m/%Y'
167+
long: '%d de %B de %Y'
168+
short: '%d de %B'
169+
170+
time:
171+
formats:
172+
default: "%A, %d de %B de %Y %H:%M:%S %z"
173+
short: "%d de %b %H:%M"
174+
long: "%d de %B de %Y a las %H:%M"
175+
am: "am"
176+
pm: "pm"

lib/ice_cube/builders/ical_builder.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ def to_s
3232

3333
def self.ical_utc_format(time)
3434
time = time.dup.utc
35-
"#{time.strftime('%Y%m%dT%H%M%SZ')}" # utc time
35+
I18n.l(time, format: '%Y%m%dT%H%M%SZ') # utc time
3636
end
3737

3838
def self.ical_format(time, force_utc)
3939
time = time.dup.utc if force_utc
4040
if time.utc?
41-
":#{time.strftime('%Y%m%dT%H%M%SZ')}" # utc time
41+
":#{I18n.l(time, format: '%Y%m%dT%H%M%SZ')}" # utc time
4242
else
43-
";TZID=#{time.strftime('%Z:%Y%m%dT%H%M%S')}" # local time specified
43+
";TZID=#{I18n.l(time, format: '%Z:%Y%m%dT%H%M%S')}" # local time specified
4444
end
4545
end
4646

lib/ice_cube/schedule.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,12 @@ def last(n = nil)
313313
def to_s
314314
pieces = []
315315
rd = recurrence_times_with_start_time - extimes
316-
pieces.concat rd.sort.map { |t| t.strftime(IceCube.to_s_time_format) }
316+
pieces.concat rd.sort.map { |t| I18n.l(t, format: IceCube.to_s_time_format) }
317317
pieces.concat rrules.map { |t| t.to_s }
318318
pieces.concat exrules.map { |t| I18n.t('ice_cube.not', target: t.to_s) }
319319
pieces.concat extimes.sort.map { |t|
320-
I18n.t('ice_cube.not_on', target: t.strftime(IceCube.to_s_time_format))
320+
target = I18n.l(t, format: IceCube.to_s_time_format)
321+
I18n.t('ice_cube.not_on', target: target)
321322
}
322323
pieces.join(I18n.t('ice_cube.pieces_connector'))
323324
end

lib/ice_cube/validations/until.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def validate(step_time, schedule)
3838
end
3939

4040
def build_s(builder)
41-
date = time.strftime(IceCube.to_s_time_format)
41+
date = I18n.l(time, format: IceCube.to_s_time_format)
4242
builder.piece(:until) << I18n.t('ice_cube.until', date: date)
4343
end
4444

spec/examples/to_s_en_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
end
101101

102102
it 'should order dates that are out of order' do
103-
schedule = IceCube::Schedule.new(t0 = Time.local(2010, 3, 20))
104-
schedule.add_recurrence_time t1 = Time.local(2010, 3, 19)
103+
schedule = IceCube::Schedule.new Time.local(2010, 3, 20)
104+
schedule.add_recurrence_time Time.local(2010, 3, 19)
105105
schedule.to_s.should == 'March 19, 2010 / March 20, 2010'
106106
end
107107

@@ -112,7 +112,7 @@
112112
end
113113

114114
it 'should remove duplicate rtimes' do
115-
schedule = IceCube::Schedule.new t0 = Time.local(2010, 3, 19)
115+
schedule = IceCube::Schedule.new Time.local(2010, 3, 19)
116116
schedule.add_recurrence_time Time.local(2010, 3, 20)
117117
schedule.add_recurrence_time Time.local(2010, 3, 20)
118118
schedule.to_s.should == 'March 19, 2010 / March 20, 2010'

0 commit comments

Comments
 (0)