r18n-core 2.2.0 → 3.0.0

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