r18n-core 2.2.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rspec +1 -1
- data/ChangeLog.md +6 -1
- data/README.md +1 -20
- data/Rakefile +5 -3
- data/lib/r18n-core.rb +55 -55
- data/lib/r18n-core/filter_list.rb +34 -36
- data/lib/r18n-core/filters.rb +68 -51
- data/lib/r18n-core/helpers.rb +17 -17
- data/lib/r18n-core/i18n.rb +46 -39
- data/lib/r18n-core/locale.rb +79 -70
- data/lib/r18n-core/translated.rb +65 -66
- data/lib/r18n-core/translated_string.rb +24 -24
- data/lib/r18n-core/translation.rb +31 -30
- data/lib/r18n-core/unsupported_locale.rb +22 -24
- data/lib/r18n-core/untranslated.rb +35 -33
- data/lib/r18n-core/utils.rb +26 -25
- data/lib/r18n-core/version.rb +4 -1
- data/lib/r18n-core/yaml_loader.rb +26 -25
- data/lib/r18n-core/yaml_methods.rb +25 -28
- data/locales/af.rb +15 -8
- data/locales/az.rb +19 -12
- data/locales/bg.rb +16 -9
- data/locales/ca.rb +16 -9
- data/locales/cs.rb +27 -20
- data/locales/da.rb +15 -8
- data/locales/de.rb +16 -9
- data/locales/en-au.rb +10 -5
- data/locales/en-gb.rb +12 -5
- data/locales/en-us.rb +12 -5
- data/locales/en.rb +29 -22
- data/locales/eo.rb +14 -7
- data/locales/es-us.rb +12 -5
- data/locales/es.rb +14 -7
- data/locales/fa.rb +48 -32
- data/locales/fi.rb +19 -12
- data/locales/fr.rb +22 -15
- data/locales/gl.rb +15 -8
- data/locales/hr.rb +24 -17
- data/locales/hu.rb +28 -21
- data/locales/id.rb +14 -7
- data/locales/it.rb +21 -14
- data/locales/ja.rb +15 -8
- data/locales/kk.rb +17 -10
- data/locales/ko.rb +15 -9
- data/locales/lv.rb +24 -17
- data/locales/mn.rb +10 -3
- data/locales/nb.rb +15 -8
- data/locales/nl.rb +15 -8
- data/locales/no.rb +11 -16
- data/locales/pl.rb +26 -19
- data/locales/pt-br.rb +12 -5
- data/locales/pt.rb +17 -10
- data/locales/ru.rb +26 -19
- data/locales/sk.rb +27 -20
- data/locales/sr-latn.rb +27 -22
- data/locales/sv-se.rb +15 -8
- data/locales/th.rb +27 -20
- data/locales/tr.rb +16 -9
- data/locales/uk.rb +19 -12
- data/locales/vi.rb +14 -7
- data/locales/zh-cn.rb +12 -5
- data/locales/zh-tw.rb +15 -8
- data/locales/zh.rb +14 -7
- data/r18n-core.gemspec +5 -3
- data/spec/filters_spec.rb +71 -67
- data/spec/i18n_spec.rb +73 -51
- data/spec/locale_spec.rb +73 -68
- data/spec/locales/cs_spec.rb +2 -2
- data/spec/locales/en-us_spec.rb +9 -9
- data/spec/locales/en_spec.rb +2 -2
- data/spec/locales/fa_spec.rb +3 -3
- data/spec/locales/fr_spec.rb +2 -2
- data/spec/locales/hu_spec.rb +7 -7
- data/spec/locales/it_spec.rb +3 -3
- data/spec/locales/no_spec.rb +9 -0
- data/spec/locales/pl_spec.rb +2 -2
- data/spec/locales/ru_spec.rb +2 -2
- data/spec/locales/sk_spec.rb +2 -2
- data/spec/locales/th_spec.rb +2 -2
- data/spec/locales/vi_spec.rb +2 -2
- data/spec/r18n_spec.rb +44 -38
- data/spec/spec_helper.rb +13 -9
- data/spec/translated_spec.rb +48 -31
- data/spec/translation_spec.rb +29 -27
- data/spec/translations/general/en.yml +0 -2
- data/spec/yaml_loader_spec.rb +22 -18
- metadata +5 -3
data/locales/da.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module R18n
|
2
|
-
|
3
|
-
|
4
|
+
module Locales
|
5
|
+
# Danish locale
|
6
|
+
class Da < Locale
|
7
|
+
set(
|
8
|
+
title: 'Dansk',
|
4
9
|
|
5
|
-
wday_names: %w
|
6
|
-
wday_abbrs: %w
|
10
|
+
wday_names: %w[søndag mandag tirsdag onsdag torsdag fredag lørdag],
|
11
|
+
wday_abbrs: %w[søn man tir ons tor fre lør],
|
7
12
|
|
8
|
-
month_names: %w
|
9
|
-
september oktober november december
|
10
|
-
month_abbrs: %w
|
11
|
-
nov. dec.
|
13
|
+
month_names: %w[januar februar marts april Maj juni juli august
|
14
|
+
september oktober november december],
|
15
|
+
month_abbrs: %w[jan. feb. mar. apr. maj jun. jul. aug. sep. okt.
|
16
|
+
nov. dec.],
|
12
17
|
|
13
18
|
time_am: 'om formiddagen',
|
14
19
|
time_pm: 'om eftermiddagen',
|
@@ -17,5 +22,7 @@ module R18n
|
|
17
22
|
|
18
23
|
number_decimal: ',',
|
19
24
|
number_group: '.'
|
25
|
+
)
|
26
|
+
end
|
20
27
|
end
|
21
28
|
end
|
data/locales/de.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module R18n
|
2
|
-
|
3
|
-
|
4
|
+
module Locales
|
5
|
+
# German locale
|
6
|
+
class De < Locale
|
7
|
+
set(
|
8
|
+
title: 'Deutsch',
|
4
9
|
|
5
|
-
wday_names: %w
|
6
|
-
Samstag
|
7
|
-
wday_abbrs: %w
|
10
|
+
wday_names: %w[Sonntag Montag Dienstag Mittwoch Donnerstag Freitag
|
11
|
+
Samstag],
|
12
|
+
wday_abbrs: %w[So Mo Di Mi Do Fr Sa],
|
8
13
|
|
9
|
-
month_names: %w
|
10
|
-
September Oktober November Dezember
|
11
|
-
month_abbrs: %w
|
12
|
-
Nov. Dez.
|
14
|
+
month_names: %w[Januar Februar März April Mai Juni Juli August
|
15
|
+
September Oktober November Dezember],
|
16
|
+
month_abbrs: %w[Jan. Feb. Mär. Apr. Mai. Jun. Jul. Aug. Sep. Okt.
|
17
|
+
Nov. Dez.],
|
13
18
|
|
14
19
|
time_am: 'vormittags',
|
15
20
|
time_pm: 'nachmittags',
|
@@ -18,5 +23,7 @@ module R18n
|
|
18
23
|
|
19
24
|
number_decimal: ',',
|
20
25
|
number_group: '.'
|
26
|
+
)
|
27
|
+
end
|
21
28
|
end
|
22
29
|
end
|
data/locales/en-au.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require_relative 'en'
|
4
|
+
|
5
|
+
module R18n
|
6
|
+
module Locales
|
7
|
+
# Australian English locale
|
8
|
+
class EnAu < En
|
9
|
+
set title: 'Australian English',
|
10
|
+
sublocales: %w[en]
|
11
|
+
end
|
7
12
|
end
|
8
13
|
end
|
data/locales/en-gb.rb
CHANGED
@@ -1,10 +1,17 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require_relative 'en'
|
4
|
+
|
5
|
+
module R18n
|
6
|
+
module Locales
|
7
|
+
# British English locale
|
8
|
+
class EnGb < En
|
9
|
+
set(
|
10
|
+
title: 'British English',
|
11
|
+
sublocales: %w[en],
|
7
12
|
|
8
13
|
date_format: '%d/%m/%Y'
|
14
|
+
)
|
15
|
+
end
|
9
16
|
end
|
10
17
|
end
|
data/locales/en-us.rb
CHANGED
@@ -1,12 +1,19 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require_relative 'en'
|
4
|
+
|
5
|
+
module R18n
|
6
|
+
module Locales
|
7
|
+
# American English locale
|
8
|
+
class EnUs < En
|
9
|
+
set(
|
10
|
+
title: 'American English',
|
11
|
+
sublocales: %w[en],
|
7
12
|
|
8
13
|
time_format: '_ %I:%M %p',
|
9
14
|
date_format: '%m/%d/%Y',
|
10
15
|
full_format: '%B %e'
|
16
|
+
)
|
17
|
+
end
|
11
18
|
end
|
12
19
|
end
|
data/locales/en.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module R18n
|
2
|
-
|
3
|
-
|
4
|
+
module Locales
|
5
|
+
# English locale
|
6
|
+
class En < Locale
|
7
|
+
set(
|
8
|
+
title: 'English',
|
4
9
|
sublocales: [],
|
5
10
|
|
6
11
|
week_start: :sunday,
|
7
|
-
wday_names: %w
|
8
|
-
Saturday
|
9
|
-
wday_abbrs: %w
|
12
|
+
wday_names: %w[Sunday Monday Tuesday Wednesday Thursday Friday
|
13
|
+
Saturday],
|
14
|
+
wday_abbrs: %w[Sun Mon Tue Wed Thu Fri Sat],
|
10
15
|
|
11
|
-
month_names: %w
|
12
|
-
September October November December
|
13
|
-
month_abbrs: %w
|
16
|
+
month_names: %w[January February March April May June July August
|
17
|
+
September October November December],
|
18
|
+
month_abbrs: %w[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec],
|
14
19
|
|
15
20
|
date_format: '%Y-%m-%d',
|
16
21
|
full_format: '%e of %B',
|
@@ -18,24 +23,26 @@ module R18n
|
|
18
23
|
|
19
24
|
number_decimal: '.',
|
20
25
|
number_group: ','
|
26
|
+
)
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
def ordinalize(n)
|
29
|
+
if (11..13).cover?(n % 100)
|
30
|
+
"#{n}th"
|
31
|
+
else
|
32
|
+
case n % 10
|
33
|
+
when 1 then "#{n}st"
|
34
|
+
when 2 then "#{n}nd"
|
35
|
+
when 3 then "#{n}rd"
|
36
|
+
else "#{n}th"
|
37
|
+
end
|
31
38
|
end
|
32
39
|
end
|
33
|
-
end
|
34
40
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
41
|
+
def format_date_full(date, year = true, *_params)
|
42
|
+
format = full_format
|
43
|
+
format = year_format.sub('_', format) if year
|
44
|
+
strftime(date, format.sub('%e', ordinalize(date.mday)))
|
45
|
+
end
|
39
46
|
end
|
40
47
|
end
|
41
48
|
end
|
data/locales/eo.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module R18n
|
2
|
-
|
3
|
-
|
4
|
+
module Locales
|
5
|
+
# Esperanto locale
|
6
|
+
class Eo < Locale
|
7
|
+
set(
|
8
|
+
title: 'Esperanto',
|
4
9
|
|
5
|
-
wday_names: %w
|
6
|
-
wday_abbrs: %w
|
10
|
+
wday_names: %w[dimanĉo lundo mardo merkredo ĵaŭdo vendredo sabato],
|
11
|
+
wday_abbrs: %w[dim lun mar mer ĵaŭ ven sab],
|
7
12
|
|
8
|
-
month_names: %w
|
9
|
-
aŭgusto septembro oktobro novembro decembro
|
10
|
-
month_abbrs: %w
|
13
|
+
month_names: %w[januaro februaro marto aprilo majo junio julio
|
14
|
+
aŭgusto septembro oktobro novembro decembro],
|
15
|
+
month_abbrs: %w[jan feb mar apr maj jun jul aŭg sep okt nov dec],
|
11
16
|
|
12
17
|
date_format: '%Y-%m-%d',
|
13
18
|
full_format: 'la %e-a de %B',
|
@@ -15,5 +20,7 @@ module R18n
|
|
15
20
|
|
16
21
|
number_decimal: '.',
|
17
22
|
number_group: ' '
|
23
|
+
)
|
24
|
+
end
|
18
25
|
end
|
19
26
|
end
|
data/locales/es-us.rb
CHANGED
@@ -1,14 +1,21 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require_relative 'es'
|
4
|
+
|
5
|
+
module R18n
|
6
|
+
module Locales
|
7
|
+
# American Spanish locale
|
8
|
+
class EsUs < Es
|
9
|
+
set(
|
10
|
+
title: 'Español Estadounidense',
|
11
|
+
sublocales: %w[es en],
|
7
12
|
|
8
13
|
time_format: ' %I:%M %p',
|
9
14
|
date_format: '%m/%d/%Y',
|
10
15
|
|
11
16
|
number_decimal: '.',
|
12
17
|
number_group: ','
|
18
|
+
)
|
19
|
+
end
|
13
20
|
end
|
14
21
|
end
|
data/locales/es.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module R18n
|
2
|
-
|
3
|
-
|
4
|
+
module Locales
|
5
|
+
# Spanish locale
|
6
|
+
class Es < Locale
|
7
|
+
set(
|
8
|
+
title: 'Español',
|
4
9
|
|
5
|
-
wday_names: %w
|
6
|
-
wday_abbrs: %w
|
10
|
+
wday_names: %w[domingo lunes martes miércoles jueves viernes sábado],
|
11
|
+
wday_abbrs: %w[dom lun mar mie jue vie sab],
|
7
12
|
|
8
|
-
month_names: %w
|
9
|
-
Septiembre Octubre Noviembre Diciembre
|
10
|
-
month_abbrs: %w
|
13
|
+
month_names: %w[Enero Febrero Marzo Abril Mayo Junio Julio Agosto
|
14
|
+
Septiembre Octubre Noviembre Diciembre],
|
15
|
+
month_abbrs: %w[ene feb mar abr may jun jul ago sep oct nov dic],
|
11
16
|
|
12
17
|
date_format: '%d/%m/%Y',
|
13
18
|
full_format: '%d de %B',
|
@@ -15,5 +20,7 @@ module R18n
|
|
15
20
|
|
16
21
|
number_decimal: ',',
|
17
22
|
number_group: '.'
|
23
|
+
)
|
24
|
+
end
|
18
25
|
end
|
19
26
|
end
|
data/locales/fa.rb
CHANGED
@@ -1,12 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module R18n
|
2
|
-
|
3
|
-
|
4
|
+
module Locales
|
5
|
+
# Persian locale
|
6
|
+
class Fa < Locale
|
7
|
+
set(
|
8
|
+
title: 'فارْسِى',
|
4
9
|
|
5
|
-
|
6
|
-
|
10
|
+
wday_names: %w[
|
11
|
+
یکشنبه دوشنبه سهشنبه چهارشنبه پنجشنبه جمعه شنبه
|
12
|
+
],
|
13
|
+
wday_abbrs: %w[ی د س چ پ ج ش],
|
7
14
|
|
8
|
-
month_names: %w
|
9
|
-
|
15
|
+
month_names: %w[
|
16
|
+
ژانویه فوریه مارس آوریل مه ژوئن ژوئیه اوت سپتامبر اکتبر نوامبر دسامبر
|
17
|
+
],
|
18
|
+
month_abbrs: %w[
|
19
|
+
ژانویه فوریه مارس آوریل مه ژوئن ژوئیه اوت سپتامبر اکتبر نوامبر دسامبر
|
20
|
+
],
|
10
21
|
|
11
22
|
date_format: '%Y/%m/%d',
|
12
23
|
full_format: '%e %B',
|
@@ -14,37 +25,42 @@ module R18n
|
|
14
25
|
|
15
26
|
number_decimal: '٫',
|
16
27
|
number_group: '٬'
|
28
|
+
)
|
17
29
|
|
18
|
-
|
19
|
-
|
30
|
+
# Change direction
|
31
|
+
def ltr?
|
32
|
+
false
|
33
|
+
end
|
20
34
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
35
|
+
# Change numerals to Persian
|
36
|
+
def format_integer(integer)
|
37
|
+
persian_numerals super
|
38
|
+
end
|
25
39
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
40
|
+
# Change numerals to Persian
|
41
|
+
def format_float(integer)
|
42
|
+
persian_numerals super
|
43
|
+
end
|
30
44
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
45
|
+
# Change numerals to Persian
|
46
|
+
def strftime(time, format)
|
47
|
+
persian_numerals super
|
48
|
+
end
|
35
49
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
50
|
+
# Replace western numerals to Persian
|
51
|
+
def persian_numerals(str)
|
52
|
+
str
|
53
|
+
.tr('0', '۰')
|
54
|
+
.tr('1', '۱')
|
55
|
+
.tr('2', '۲')
|
56
|
+
.tr('3', '۳')
|
57
|
+
.tr('4', '۴')
|
58
|
+
.tr('5', '۵')
|
59
|
+
.tr('6', '۶')
|
60
|
+
.tr('7', '۷')
|
61
|
+
.tr('8', '۸')
|
62
|
+
.tr('9', '۹')
|
63
|
+
end
|
48
64
|
end
|
49
65
|
end
|
50
66
|
end
|
data/locales/fi.rb
CHANGED
@@ -1,18 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module R18n
|
2
|
-
|
3
|
-
|
4
|
+
module Locales
|
5
|
+
# Finnish locale
|
6
|
+
class Fi < Locale
|
7
|
+
set(
|
8
|
+
title: 'Suomi',
|
4
9
|
|
5
|
-
wday_names: %w
|
6
|
-
terjantai lauantai
|
7
|
-
wday_abbrs: %w
|
10
|
+
wday_names: %w[sunnuntai maanantai tiistai keskiviikko torstai
|
11
|
+
terjantai lauantai],
|
12
|
+
wday_abbrs: %w[su ma ti ke to te la],
|
8
13
|
|
9
|
-
month_names: %w
|
14
|
+
month_names: %w[tammikuuta helmikuuta maaliskuuta huhtikuuta
|
10
15
|
toukokuuta kesäkuuta heinäkuuta elokuuta syyskuuta
|
11
|
-
lokakuuta marraskuuta joulukuuta
|
12
|
-
month_abbrs: %w
|
13
|
-
month_standalone: %w
|
16
|
+
lokakuuta marraskuuta joulukuuta],
|
17
|
+
month_abbrs: %w[tam hel maa huh tou kes hei elo syy lok mar jou],
|
18
|
+
month_standalone: %w[tammikuu helmikuu maaliskuu huhtikuu toukokuu
|
14
19
|
kesäkuu heinäkuu elokuu syyskuu lokakuu
|
15
|
-
marraskuu joulukuu
|
20
|
+
marraskuu joulukuu],
|
16
21
|
|
17
22
|
date_format: '%d.%m.%Y',
|
18
23
|
full_format: '%e. %B',
|
@@ -20,9 +25,11 @@ module R18n
|
|
20
25
|
|
21
26
|
number_decimal: ',',
|
22
27
|
number_group: ''
|
28
|
+
)
|
23
29
|
|
24
|
-
|
25
|
-
|
30
|
+
def format_time_full(time, *_params)
|
31
|
+
format_time(format_date_full(time) + ' kello', time)
|
32
|
+
end
|
26
33
|
end
|
27
34
|
end
|
28
35
|
end
|