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/base/ja.yml
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
ok: 了解
|
2
|
-
save: 保存
|
3
|
-
cancel: キャンセル
|
1
|
+
ok: '了解'
|
2
|
+
save: '保存'
|
3
|
+
cancel: 'キャンセル'
|
4
4
|
'yes': 'はい'
|
5
5
|
'no': 'いいえ'
|
6
|
-
exit: 終了
|
7
|
-
delete: 削除
|
6
|
+
exit: '終了'
|
7
|
+
delete: '削除'
|
8
8
|
|
9
9
|
human_time:
|
10
|
-
after_days: %1日後
|
11
|
-
tomorrow: 明日
|
12
|
-
after_hours: %1時間後
|
13
|
-
after_minutes: %1分後
|
14
|
-
now: 今
|
15
|
-
today: 今日
|
16
|
-
minutes_ago: %1分前
|
17
|
-
hours_ago: %1時間前
|
18
|
-
yesterday: 昨日
|
19
|
-
days_ago: %1日前
|
10
|
+
after_days: '%1日後'
|
11
|
+
tomorrow: '明日'
|
12
|
+
after_hours: '%1時間後'
|
13
|
+
after_minutes: '%1分後'
|
14
|
+
now: '今'
|
15
|
+
today: '今日'
|
16
|
+
minutes_ago: '%1分前'
|
17
|
+
hours_ago: '%1時間前'
|
18
|
+
yesterday: '昨日'
|
19
|
+
days_ago: '%1日前'
|
data/base/kk.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
ok: OK
|
2
|
-
save: Сақтау
|
3
|
-
cancel: Болдырмау
|
4
|
-
'yes': Иә
|
5
|
-
'no': Жоқ
|
6
|
-
exit: Шығу
|
7
|
-
delete: Алыстату
|
1
|
+
ok: 'OK'
|
2
|
+
save: 'Сақтау'
|
3
|
+
cancel: 'Болдырмау'
|
4
|
+
'yes': 'Иә'
|
5
|
+
'no': 'Жоқ'
|
6
|
+
exit: 'Шығу'
|
7
|
+
delete: 'Алыстату'
|
data/base/lv.yml
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
ok: Ok
|
2
|
-
save: Saglabāt
|
3
|
-
cancel: Atcelt
|
1
|
+
ok: 'Ok'
|
2
|
+
save: 'Saglabāt'
|
3
|
+
cancel: 'Atcelt'
|
4
4
|
'yes': 'Jā'
|
5
5
|
'no': 'Nē'
|
6
|
-
exit: Iziet
|
7
|
-
delete: Dzēst
|
6
|
+
exit: 'Iziet'
|
7
|
+
delete: 'Dzēst'
|
8
8
|
|
9
9
|
human_time:
|
10
10
|
after_days: !!pl
|
11
|
-
1: nākamajā dienā
|
12
|
-
n: pēc %1 dienām
|
13
|
-
tomorrow: rīt
|
11
|
+
1: 'nākamajā dienā'
|
12
|
+
n: 'pēc %1 dienām'
|
13
|
+
tomorrow: 'rīt'
|
14
14
|
after_hours: !!pl
|
15
|
-
1: nākamajā stundā
|
16
|
-
n: pēc %1 stundas
|
15
|
+
1: 'nākamajā stundā'
|
16
|
+
n: 'pēc %1 stundas'
|
17
17
|
after_minutes: !!pl
|
18
|
-
1: nākamajā minūtē
|
19
|
-
n: pēc %1 minūtēm
|
20
|
-
now: tagad
|
21
|
-
today: šodien
|
18
|
+
1: 'nākamajā minūtē'
|
19
|
+
n: 'pēc %1 minūtēm'
|
20
|
+
now: 'tagad'
|
21
|
+
today: 'šodien'
|
22
22
|
minutes_ago: !!pl
|
23
|
-
1: pirms minūtes
|
24
|
-
n: pirms %1 minūtēm
|
23
|
+
1: 'pirms minūtes'
|
24
|
+
n: 'pirms %1 minūtēm'
|
25
25
|
hours_ago: !!pl
|
26
|
-
1: pirms stundas
|
27
|
-
n: pirms %1 stundām
|
28
|
-
yesterday: vakar
|
26
|
+
1: 'pirms stundas'
|
27
|
+
n: 'pirms %1 stundām'
|
28
|
+
yesterday: 'vakar'
|
29
29
|
days_ago: !!pl
|
30
|
-
1: pirms vienas dienas
|
31
|
-
n: pirms %1 stundām
|
30
|
+
1: 'pirms vienas dienas'
|
31
|
+
n: 'pirms %1 stundām'
|
data/base/pl.yml
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
ok: OK
|
2
|
-
save: Zapisz
|
3
|
-
cancel: Anuluj
|
4
|
-
'yes': Tak
|
5
|
-
'no': Nie
|
6
|
-
exit: Wyjście
|
7
|
-
delete: Usuń
|
1
|
+
ok: 'OK'
|
2
|
+
save: 'Zapisz'
|
3
|
+
cancel: 'Anuluj'
|
4
|
+
'yes': 'Tak'
|
5
|
+
'no': 'Nie'
|
6
|
+
exit: 'Wyjście'
|
7
|
+
delete: 'Usuń'
|
8
8
|
|
9
9
|
human_time:
|
10
10
|
after_days: !!pl
|
11
|
-
1: po %1 dniu
|
12
|
-
n: po %1 dniach
|
13
|
-
tomorrow: jutro
|
11
|
+
1: 'po %1 dniu'
|
12
|
+
n: 'po %1 dniach'
|
13
|
+
tomorrow: 'jutro'
|
14
14
|
after_hours: !!pl
|
15
|
-
1: po %1 godzinie
|
16
|
-
n: po %1 godzinach
|
15
|
+
1: 'po %1 godzinie'
|
16
|
+
n: 'po %1 godzinach'
|
17
17
|
after_minutes: !!pl
|
18
|
-
1: po %1 minucie
|
19
|
-
n: po %1 minutach
|
20
|
-
now: teraz
|
21
|
-
today: dzisiaj
|
18
|
+
1: 'po %1 minucie'
|
19
|
+
n: 'po %1 minutach'
|
20
|
+
now: 'teraz'
|
21
|
+
today: 'dzisiaj'
|
22
22
|
minutes_ago: !!pl
|
23
|
-
1: %1 minutę temu
|
24
|
-
n: %1 minut temu
|
23
|
+
1: '%1 minutę temu'
|
24
|
+
n: '%1 minut temu'
|
25
25
|
hours_ago: !!pl
|
26
|
-
1: %1 godzinę temu
|
27
|
-
n: %1 godzin temu
|
28
|
-
yesterday: wczoraj
|
26
|
+
1: '%1 godzinę temu'
|
27
|
+
n: '%1 godzin temu'
|
28
|
+
yesterday: 'wczoraj'
|
29
29
|
days_ago: !!pl
|
30
|
-
1: %1 dzień temu
|
31
|
-
n: %1 dni temu
|
30
|
+
1: '%1 dzień temu'
|
31
|
+
n: '%1 dni temu'
|
data/base/pt_br.yml
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
ok: OK
|
2
|
-
save: Salvar
|
3
|
-
cancel: Cancelar
|
4
|
-
'yes': Sim
|
5
|
-
'no': Não
|
6
|
-
exit: Sair
|
7
|
-
delete: Apagar
|
1
|
+
ok: 'OK'
|
2
|
+
save: 'Salvar'
|
3
|
+
cancel: 'Cancelar'
|
4
|
+
'yes': 'Sim'
|
5
|
+
'no': 'Não'
|
6
|
+
exit: 'Sair'
|
7
|
+
delete: 'Apagar'
|
8
8
|
|
9
9
|
human_time:
|
10
10
|
after_days: !!pl
|
11
|
-
1: após %1 dia
|
12
|
-
n: após %1 dias
|
13
|
-
tomorrow: amanhã
|
11
|
+
1: 'após %1 dia'
|
12
|
+
n: 'após %1 dias'
|
13
|
+
tomorrow: 'amanhã'
|
14
14
|
after_hours: !!pl
|
15
|
-
1: após %1 hora
|
16
|
-
n: após %1 horas
|
15
|
+
1: 'após %1 hora'
|
16
|
+
n: 'após %1 horas'
|
17
17
|
after_minutes: !!pl
|
18
|
-
1: após %1 minuto
|
19
|
-
n: após %1 minutos
|
20
|
-
now: agora
|
21
|
-
today: hoje
|
18
|
+
1: 'após %1 minuto'
|
19
|
+
n: 'após %1 minutos'
|
20
|
+
now: 'agora'
|
21
|
+
today: 'hoje'
|
22
22
|
minutes_ago: !!pl
|
23
|
-
1: %1 minuto atrás
|
24
|
-
n: %1 minutos atrás
|
23
|
+
1: '%1 minuto atrás'
|
24
|
+
n: '%1 minutos atrás'
|
25
25
|
hours_ago: !!pl
|
26
|
-
1: %1 hora atrás
|
27
|
-
n: %1 horas atrás
|
28
|
-
yesterday: ontem
|
26
|
+
1: '%1 hora atrás'
|
27
|
+
n: '%1 horas atrás'
|
28
|
+
yesterday: 'ontem'
|
29
29
|
days_ago: !!pl
|
30
|
-
1: %1 dia atrás
|
31
|
-
n: %1 dias atrás
|
30
|
+
1: '%1 dia atrás'
|
31
|
+
n: '%1 dias atrás'
|
data/base/ru.yml
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
ok: OK
|
2
|
-
save: Сохранить
|
3
|
-
cancel: Отмена
|
4
|
-
'yes': Да
|
5
|
-
'no': Нет
|
6
|
-
exit: Выход
|
7
|
-
delete: Удалить
|
1
|
+
ok: 'OK'
|
2
|
+
save: 'Сохранить'
|
3
|
+
cancel: 'Отмена'
|
4
|
+
'yes': 'Да'
|
5
|
+
'no': 'Нет'
|
6
|
+
exit: 'Выход'
|
7
|
+
delete: 'Удалить'
|
8
8
|
|
9
9
|
human_time:
|
10
10
|
after_days: !!pl
|
11
|
-
1: через %1 день
|
12
|
-
2: через %1 дня
|
13
|
-
n: через %1 дней
|
14
|
-
tomorrow: завтра
|
11
|
+
1: 'через %1 день'
|
12
|
+
2: 'через %1 дня'
|
13
|
+
n: 'через %1 дней'
|
14
|
+
tomorrow: 'завтра'
|
15
15
|
after_hours: !!pl
|
16
|
-
1: через %1 час
|
17
|
-
2: через %1 часа
|
18
|
-
n: через %1 часов
|
16
|
+
1: 'через %1 час'
|
17
|
+
2: 'через %1 часа'
|
18
|
+
n: 'через %1 часов'
|
19
19
|
after_minutes: !!pl
|
20
|
-
1: через %1 минуту
|
21
|
-
2: через %1 минуты
|
22
|
-
n: через %1 минут
|
23
|
-
now: сейчас
|
24
|
-
today: сегодня
|
20
|
+
1: 'через %1 минуту'
|
21
|
+
2: 'через %1 минуты'
|
22
|
+
n: 'через %1 минут'
|
23
|
+
now: 'сейчас'
|
24
|
+
today: 'сегодня'
|
25
25
|
minutes_ago: !!pl
|
26
|
-
1: %1 минуту назад
|
27
|
-
2: %1 минуты назад
|
28
|
-
n: %1 минут назад
|
26
|
+
1: '%1 минуту назад'
|
27
|
+
2: '%1 минуты назад'
|
28
|
+
n: '%1 минут назад'
|
29
29
|
hours_ago: !!pl
|
30
|
-
1: %1 час назад
|
31
|
-
2: %1 часа назад
|
32
|
-
n: %1 часов назад
|
33
|
-
yesterday: вчера
|
30
|
+
1: '%1 час назад'
|
31
|
+
2: '%1 часа назад'
|
32
|
+
n: '%1 часов назад'
|
33
|
+
yesterday: 'вчера'
|
34
34
|
days_ago: !!pl
|
35
|
-
1: %1 день назад
|
36
|
-
2: %1 дня назад
|
37
|
-
n: %1 дней назад
|
35
|
+
1: '%1 день назад'
|
36
|
+
2: '%1 дня назад'
|
37
|
+
n: '%1 дней назад'
|
data/base/sk.yml
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
ok: OK
|
2
|
-
save: Uložiť
|
3
|
-
cancel: Zrušiť
|
4
|
-
'yes': Áno
|
5
|
-
'no': Nie
|
6
|
-
exit: Koniec
|
7
|
-
delete: Zmazať
|
1
|
+
ok: 'OK'
|
2
|
+
save: 'Uložiť'
|
3
|
+
cancel: 'Zrušiť'
|
4
|
+
'yes': 'Áno'
|
5
|
+
'no': 'Nie'
|
6
|
+
exit: 'Koniec'
|
7
|
+
delete: 'Zmazať'
|
8
8
|
|
9
9
|
human_time:
|
10
10
|
after_days: !!pl
|
11
|
-
1: o %1 deň
|
12
|
-
2: o %1 dni
|
13
|
-
n: o %1 dní
|
14
|
-
tomorrow: zajtra
|
11
|
+
1: 'o %1 deň'
|
12
|
+
2: 'o %1 dni'
|
13
|
+
n: 'o %1 dní'
|
14
|
+
tomorrow: 'zajtra'
|
15
15
|
after_hours: !!pl
|
16
|
-
1: o %1 hodinu
|
17
|
-
2: o %1 hodiny
|
18
|
-
n: o %1 hodín
|
16
|
+
1: 'o %1 hodinu'
|
17
|
+
2: 'o %1 hodiny'
|
18
|
+
n: 'o %1 hodín'
|
19
19
|
after_minutes: !!pl
|
20
|
-
1: o %1 minútu
|
21
|
-
2: o %1 minúty
|
22
|
-
n: o %1 minút
|
23
|
-
now: teraz
|
24
|
-
today: dnes
|
20
|
+
1: 'o %1 minútu'
|
21
|
+
2: 'o %1 minúty'
|
22
|
+
n: 'o %1 minút'
|
23
|
+
now: 'teraz'
|
24
|
+
today: 'dnes'
|
25
25
|
minutes_ago: !!pl
|
26
|
-
1: pred %1 minútou
|
27
|
-
n: pred %1 minútami
|
26
|
+
1: 'pred %1 minútou'
|
27
|
+
n: 'pred %1 minútami'
|
28
28
|
hours_ago: !!pl
|
29
|
-
1: pred %1 hodinou
|
30
|
-
n: pred %1 hodinami
|
31
|
-
yesterday: včera
|
29
|
+
1: 'pred %1 hodinou'
|
30
|
+
n: 'pred %1 hodinami'
|
31
|
+
yesterday: 'včera'
|
32
32
|
days_ago: !!pl
|
33
|
-
1: pred %1 dňom
|
34
|
-
n: pred %1 dňami
|
33
|
+
1: 'pred %1 dňom'
|
34
|
+
n: 'pred %1 dňami'
|
data/base/th.yml
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
ok: OK
|
2
|
-
save: บันทึก
|
3
|
-
cancel: ยกเลิก
|
4
|
-
'yes': ใช่
|
5
|
-
'no': ไม่ใช่
|
6
|
-
exit: ออก จาก
|
7
|
-
delete: ลบ
|
1
|
+
ok: 'OK'
|
2
|
+
save: 'บันทึก'
|
3
|
+
cancel: 'ยกเลิก'
|
4
|
+
'yes': 'ใช่'
|
5
|
+
'no': 'ไม่ใช่'
|
6
|
+
exit: 'ออก จาก'
|
7
|
+
delete: 'ลบ'
|
8
8
|
|
9
9
|
human_time:
|
10
|
-
after_days: หลงจาก %1 วัน
|
11
|
-
tomorrow: พรุ่งนี้
|
12
|
-
after_hours: หลงจาก %1 ชั่วโมง
|
13
|
-
after_minutes: หลงจาก %1 นาที
|
14
|
-
now: ตอน นี้
|
15
|
-
today: วัน นี้
|
16
|
-
minutes_ago: %1 นาที ที่ ผ่าน มา
|
17
|
-
hours_ago: %1 ชั่วโมง ที่ ผ่าน มา
|
18
|
-
yesterday: เมื่อ วาน
|
19
|
-
days_ago: %1 วัน ที่ ผ่าน มา
|
10
|
+
after_days: 'หลงจาก %1 วัน'
|
11
|
+
tomorrow: 'พรุ่งนี้'
|
12
|
+
after_hours: 'หลงจาก %1 ชั่วโมง'
|
13
|
+
after_minutes: 'หลงจาก %1 นาที'
|
14
|
+
now: 'ตอน นี้'
|
15
|
+
today: 'วัน นี้'
|
16
|
+
minutes_ago: '%1 นาที ที่ ผ่าน มา'
|
17
|
+
hours_ago: '%1 ชั่วโมง ที่ ผ่าน มา'
|
18
|
+
yesterday: 'เมื่อ วาน'
|
19
|
+
days_ago: '%1 วัน ที่ ผ่าน มา'
|
data/base/zh.yml
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
ok: OK
|
2
|
-
save: 保存
|
3
|
-
cancel: 取消
|
4
|
-
'yes': 是
|
5
|
-
'no': 否
|
6
|
-
exit: 退出
|
7
|
-
delete: 删除
|
1
|
+
ok: 'OK'
|
2
|
+
save: '保存'
|
3
|
+
cancel: '取消'
|
4
|
+
'yes': '是'
|
5
|
+
'no': '否'
|
6
|
+
exit: '退出'
|
7
|
+
delete: '删除'
|
8
8
|
|
9
9
|
human_time:
|
10
|
-
after_days: 过%1天
|
11
|
-
tomorrow: 明天
|
12
|
-
after_hours: 过%1小时
|
13
|
-
after_minutes: 过%1分钟
|
14
|
-
now: 现在
|
15
|
-
today: 今天
|
16
|
-
minutes_ago: 前%1分钟
|
17
|
-
hours_ago: 前%1小时
|
18
|
-
yesterday: 昨天
|
19
|
-
days_ago: 前%1天
|
10
|
+
after_days: '过%1天'
|
11
|
+
tomorrow: '明天'
|
12
|
+
after_hours: '过%1小时'
|
13
|
+
after_minutes: '过%1分钟'
|
14
|
+
now: '现在'
|
15
|
+
today: '今天'
|
16
|
+
minutes_ago: '前%1分钟'
|
17
|
+
hours_ago: '前%1小时'
|
18
|
+
yesterday: '昨天'
|
19
|
+
days_ago: '前%1天'
|
data/lib/r18n-core/filters.rb
CHANGED
data/lib/r18n-core/locale.rb
CHANGED
@@ -227,20 +227,16 @@ module R18n
|
|
227
227
|
format_date_human(R18n::Utils.to_date(time), i18n,
|
228
228
|
R18n::Utils.to_date(now)) + format_time(time)
|
229
229
|
else
|
230
|
-
|
231
|
-
when -59..-1
|
232
|
-
i18n.human_time.minutes_ago(minutes.round.abs)
|
233
|
-
when 1..59
|
234
|
-
i18n.human_time.after_minutes(minutes.round)
|
235
|
-
when -1..1
|
230
|
+
if -1 < minutes and 1 > minutes
|
236
231
|
i18n.human_time.now
|
232
|
+
elsif 60 <= minutes
|
233
|
+
i18n.human_time.after_hours((diff / 60.0).floor)
|
234
|
+
elsif -60 >= minutes
|
235
|
+
i18n.human_time.hours_ago((diff / 60.0).floor)
|
236
|
+
elsif 0 < minutes
|
237
|
+
i18n.human_time.after_minutes(minutes.round)
|
237
238
|
else
|
238
|
-
|
239
|
-
if time > now
|
240
|
-
i18n.human_time.after_hours(hours)
|
241
|
-
else
|
242
|
-
i18n.human_time.hours_ago(hours)
|
243
|
-
end
|
239
|
+
i18n.human_time.minutes_ago(minutes.round.abs)
|
244
240
|
end
|
245
241
|
end
|
246
242
|
end
|
data/lib/r18n-core/translated.rb
CHANGED
@@ -110,14 +110,16 @@ module R18n
|
|
110
110
|
# translation :desciption, :type => 'markdown'
|
111
111
|
def translation(name, options = {})
|
112
112
|
if options[:methods]
|
113
|
-
@unlocalized_getters[name] = R18n::Utils.
|
113
|
+
@unlocalized_getters[name] = R18n::Utils.
|
114
|
+
hash_map(options[:methods]) { |l, i| [ l.to_s, i.to_s ] }
|
114
115
|
unless options[:no_write]
|
115
|
-
@unlocalized_setters[name] =R18n::Utils.
|
116
|
+
@unlocalized_setters[name] = R18n::Utils.
|
117
|
+
hash_map(options[:methods]) { |l, i| [ l.to_s, i.to_s + '=' ] }
|
116
118
|
end
|
117
119
|
end
|
118
120
|
|
119
121
|
@translation_types[name] = options[:type]
|
120
|
-
|
122
|
+
params = options[:no_params] ? '' : ', *params'
|
121
123
|
|
122
124
|
class_eval <<-EOS, __FILE__, __LINE__
|
123
125
|
def #{name}(*params)
|
@@ -125,7 +127,7 @@ module R18n
|
|
125
127
|
R18n.get.locales.each do |locale|
|
126
128
|
code = locale.code
|
127
129
|
next unless unlocalized.has_key? code
|
128
|
-
result =
|
130
|
+
result = send unlocalized[code]#{params}
|
129
131
|
next unless result
|
130
132
|
|
131
133
|
path = "\#{self.class.name}##{name}"
|
@@ -133,10 +135,12 @@ module R18n
|
|
133
135
|
if type
|
134
136
|
return R18n::Filters.process(R18n::Filters.enabled,
|
135
137
|
type, result, locale, path, params)
|
136
|
-
|
138
|
+
elsif result.is_a? String
|
137
139
|
result = TranslatedString.new(result, locale, path)
|
138
140
|
return R18n::Filters.process_string(R18n::Filters.enabled,
|
139
141
|
result, path, params)
|
142
|
+
else
|
143
|
+
return result
|
140
144
|
end
|
141
145
|
end
|
142
146
|
|
@@ -152,21 +156,27 @@ module R18n
|
|
152
156
|
R18n.get.locales.each do |locale|
|
153
157
|
code = locale.code
|
154
158
|
next unless unlocalized.has_key? code
|
155
|
-
return
|
159
|
+
return send unlocalized[code], *params
|
156
160
|
end
|
157
161
|
end
|
158
162
|
EOS
|
159
163
|
end
|
160
164
|
end
|
165
|
+
|
166
|
+
# Return array of methods to find +unlocalized_getters+ or
|
167
|
+
# +unlocalized_setters+.
|
168
|
+
def unlocalized_methods
|
169
|
+
self.instance_methods
|
170
|
+
end
|
161
171
|
|
162
172
|
# Return Hash of locale code to getter method for proxy +method+. If you
|
163
173
|
# didn’t set map in +translation+ option +methods+, it will be detect
|
164
174
|
# automatically.
|
165
175
|
def unlocalized_getters(method)
|
166
|
-
matcher = Regexp.new('^' + Regexp.escape(method.to_s) + '_(
|
176
|
+
matcher = Regexp.new('^' + Regexp.escape(method.to_s) + '_(\w+)$')
|
167
177
|
unless @unlocalized_getters.has_key? method
|
168
178
|
@unlocalized_getters[method] = {}
|
169
|
-
self.
|
179
|
+
self.unlocalized_methods.reject { |i| not i =~ matcher }.each do |i|
|
170
180
|
@unlocalized_getters[method][i.to_s.match(matcher)[1]] = i.to_s
|
171
181
|
end
|
172
182
|
end
|
@@ -177,10 +187,10 @@ module R18n
|
|
177
187
|
# didn’t set map in +translation+ option +methods+, it will be detect
|
178
188
|
# automatically.
|
179
189
|
def unlocalized_setters(method)
|
180
|
-
matcher = Regexp.new('^' + Regexp.escape(method.to_s) + '_(
|
190
|
+
matcher = Regexp.new('^' + Regexp.escape(method.to_s) + '_(\w+)=$')
|
181
191
|
unless @unlocalized_setters.has_key? method
|
182
192
|
@unlocalized_setters[method] = {}
|
183
|
-
self.
|
193
|
+
self.unlocalized_methods.reject { |i| not i =~ matcher }.each do |i|
|
184
194
|
@unlocalized_setters[method][i.to_s.match(matcher)[1]] = i.to_s
|
185
195
|
end
|
186
196
|
end
|
data/lib/r18n-core/utils.rb
CHANGED
@@ -57,5 +57,18 @@ module R18n
|
|
57
57
|
end
|
58
58
|
a
|
59
59
|
end
|
60
|
+
|
61
|
+
# Call +block+ with Syck yamler. It used to load RedCloth, which isn’t
|
62
|
+
# support Psych.
|
63
|
+
def self.use_syck(&block)
|
64
|
+
if '1.8.' == RUBY_VERSION[0..3]
|
65
|
+
yield
|
66
|
+
else
|
67
|
+
origin_yamler = YAML::ENGINE.yamler
|
68
|
+
YAML::ENGINE.yamler = 'syck'
|
69
|
+
yield
|
70
|
+
YAML::ENGINE.yamler = origin_yamler
|
71
|
+
end
|
72
|
+
end
|
60
73
|
end
|
61
74
|
end
|
data/lib/r18n-core/version.rb
CHANGED
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19
19
|
=end
|
20
20
|
|
21
21
|
require 'yaml'
|
22
|
+
require 'syck' if '1.8.' != RUBY_VERSION[0..3]
|
22
23
|
|
23
24
|
module R18n
|
24
25
|
module Loader
|
@@ -39,6 +40,11 @@ module R18n
|
|
39
40
|
# Create new loader for +dir+ with YAML translations.
|
40
41
|
def initialize(dir)
|
41
42
|
@dir = File.expand_path(dir)
|
43
|
+
@private_type_class = if '1.8.' == RUBY_VERSION[0..3]
|
44
|
+
::YAML::PrivateType
|
45
|
+
else
|
46
|
+
::Syck::PrivateType
|
47
|
+
end
|
42
48
|
end
|
43
49
|
|
44
50
|
# Array of locales, which has translations in +dir+.
|
@@ -50,6 +56,17 @@ module R18n
|
|
50
56
|
|
51
57
|
# Return Hash with translations for +locale+.
|
52
58
|
def load(locale)
|
59
|
+
if '1.8.' != RUBY_VERSION[0..3] and 'psych' == ::YAML::ENGINE.yamler
|
60
|
+
Filters.by_type.keys.each do |type|
|
61
|
+
next unless type.is_a? String
|
62
|
+
# Yeah, I add R18n’s types to global, send me patch if you really
|
63
|
+
# use YAML types too ;).
|
64
|
+
Psych.add_domain_type('yaml.org,2002', type) do |full_type, value|
|
65
|
+
Typed.new(type, value)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
53
70
|
translations = {}
|
54
71
|
Dir.glob(File.join(@dir, "**/#{locale.code.downcase}.yml")).each do |file_name|
|
55
72
|
Utils.deep_merge!(translations, ::YAML::load_file(file_name))
|
@@ -72,7 +89,7 @@ module R18n
|
|
72
89
|
R18n::Utils.hash_map(a_hash) do |key, value|
|
73
90
|
[key,
|
74
91
|
case value
|
75
|
-
when
|
92
|
+
when @private_type_class
|
76
93
|
Typed.new(value.type_id, value.value)
|
77
94
|
when Hash
|
78
95
|
transform(value)
|
data/locales/bg.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module R18n
|
3
|
+
class Locales::Bg < Locale
|
4
|
+
set :title => 'Български',
|
5
|
+
|
6
|
+
:wday_names => %w{Неделя Понеделник Вторник Сряда Четвъртък Петък
|
7
|
+
Събота},
|
8
|
+
:wday_abbrs => %w{Нед Пон Вто Сря Чет Пет Съб},
|
9
|
+
|
10
|
+
:month_names => %w{Януари Февруари Март Април Май Юни Юли Август
|
11
|
+
Септември Октомври Ноември Декември},
|
12
|
+
:month_abbrs => %w{Яну Фев Мар Апр Май Юни Юли Авг Сеп Окт Ное Дек},
|
13
|
+
:month_standalone => %w{Януари Февруари Март Април Май Юни Юли Август
|
14
|
+
Септември Октомври Ноември Декември},
|
15
|
+
:date_format => '%d.%m.%Y',
|
16
|
+
|
17
|
+
:number_decimal => ",",
|
18
|
+
:number_group => " "
|
19
|
+
end
|
20
|
+
end
|