r18n-core 3.1.1 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +398 -0
  3. data/README.md +63 -47
  4. data/base/cy.yml +34 -0
  5. data/lib/r18n-core.rb +37 -38
  6. data/lib/r18n-core/filter_list.rb +21 -13
  7. data/lib/r18n-core/filters.rb +43 -48
  8. data/lib/r18n-core/helpers.rb +2 -2
  9. data/lib/r18n-core/i18n.rb +70 -78
  10. data/lib/r18n-core/locale.rb +137 -107
  11. data/lib/r18n-core/locales/af.rb +36 -0
  12. data/lib/r18n-core/locales/az.rb +38 -0
  13. data/lib/r18n-core/locales/bg.rb +29 -0
  14. data/{locales → lib/r18n-core/locales}/ca.rb +9 -6
  15. data/{locales → lib/r18n-core/locales}/cs.rb +15 -11
  16. data/lib/r18n-core/locales/cy.rb +50 -0
  17. data/{locales → lib/r18n-core/locales}/da.rb +10 -7
  18. data/lib/r18n-core/locales/de.rb +33 -0
  19. data/{locales → lib/r18n-core/locales}/en-au.rb +2 -2
  20. data/{locales → lib/r18n-core/locales}/en-gb.rb +2 -2
  21. data/{locales → lib/r18n-core/locales}/en-us.rb +4 -3
  22. data/lib/r18n-core/locales/en.rb +51 -0
  23. data/{locales → lib/r18n-core/locales}/eo.rb +6 -4
  24. data/lib/r18n-core/locales/es-cl.rb +16 -0
  25. data/{locales → lib/r18n-core/locales}/es-us.rb +5 -4
  26. data/{locales → lib/r18n-core/locales}/es.rb +7 -3
  27. data/{locales → lib/r18n-core/locales}/fa.rb +2 -2
  28. data/lib/r18n-core/locales/fi.rb +39 -0
  29. data/lib/r18n-core/locales/fr.rb +39 -0
  30. data/{locales → lib/r18n-core/locales}/gl.rb +5 -3
  31. data/{locales → lib/r18n-core/locales}/hr.rb +13 -10
  32. data/{locales → lib/r18n-core/locales}/hu.rb +10 -7
  33. data/{locales → lib/r18n-core/locales}/id.rb +8 -4
  34. data/lib/r18n-core/locales/it.rb +37 -0
  35. data/{locales → lib/r18n-core/locales}/ja.rb +5 -4
  36. data/{locales → lib/r18n-core/locales}/kk.rb +12 -8
  37. data/{locales → lib/r18n-core/locales}/ko.rb +0 -0
  38. data/lib/r18n-core/locales/lv.rb +46 -0
  39. data/lib/r18n-core/locales/mn.rb +30 -0
  40. data/{locales → lib/r18n-core/locales}/nb.rb +6 -4
  41. data/lib/r18n-core/locales/nl.rb +31 -0
  42. data/{locales → lib/r18n-core/locales}/no.rb +0 -0
  43. data/lib/r18n-core/locales/pl.rb +45 -0
  44. data/{locales → lib/r18n-core/locales}/pt-br.rb +1 -1
  45. data/lib/r18n-core/locales/pt.rb +37 -0
  46. data/lib/r18n-core/locales/ru.rb +46 -0
  47. data/{locales → lib/r18n-core/locales}/sk.rb +13 -9
  48. data/{locales → lib/r18n-core/locales}/sr-latn.rb +10 -8
  49. data/{locales → lib/r18n-core/locales}/sv-se.rb +7 -5
  50. data/lib/r18n-core/locales/th.rb +41 -0
  51. data/{locales → lib/r18n-core/locales}/tr.rb +7 -6
  52. data/lib/r18n-core/locales/uk.rb +31 -0
  53. data/lib/r18n-core/locales/vi.rb +37 -0
  54. data/{locales → lib/r18n-core/locales}/zh-cn.rb +2 -2
  55. data/{locales → lib/r18n-core/locales}/zh-tw.rb +4 -4
  56. data/{locales → lib/r18n-core/locales}/zh.rb +7 -4
  57. data/lib/r18n-core/translated.rb +38 -37
  58. data/lib/r18n-core/translated_string.rb +19 -8
  59. data/lib/r18n-core/translation.rb +24 -19
  60. data/lib/r18n-core/unsupported_locale.rb +14 -6
  61. data/lib/r18n-core/untranslated.rb +23 -7
  62. data/lib/r18n-core/utils.rb +19 -23
  63. data/lib/r18n-core/version.rb +1 -1
  64. data/lib/r18n-core/yaml_loader.rb +17 -13
  65. data/lib/r18n-core/yaml_methods.rb +3 -1
  66. metadata +245 -118
  67. data/.rspec +0 -1
  68. data/Rakefile +0 -13
  69. data/locales/af.rb +0 -32
  70. data/locales/az.rb +0 -34
  71. data/locales/bg.rb +0 -25
  72. data/locales/de.rb +0 -29
  73. data/locales/en.rb +0 -48
  74. data/locales/fi.rb +0 -35
  75. data/locales/fr.rb +0 -35
  76. data/locales/it.rb +0 -34
  77. data/locales/lv.rb +0 -41
  78. data/locales/mn.rb +0 -27
  79. data/locales/nl.rb +0 -28
  80. data/locales/pl.rb +0 -40
  81. data/locales/pt.rb +0 -29
  82. data/locales/ru.rb +0 -41
  83. data/locales/th.rb +0 -37
  84. data/locales/uk.rb +0 -27
  85. data/locales/vi.rb +0 -33
  86. data/r18n-core.gemspec +0 -29
  87. data/spec/filters_spec.rb +0 -324
  88. data/spec/i18n_spec.rb +0 -260
  89. data/spec/locale_spec.rb +0 -216
  90. data/spec/locales/cs_spec.rb +0 -23
  91. data/spec/locales/en-us_spec.rb +0 -13
  92. data/spec/locales/en_spec.rb +0 -13
  93. data/spec/locales/fa_spec.rb +0 -10
  94. data/spec/locales/fr_spec.rb +0 -9
  95. data/spec/locales/hu_spec.rb +0 -17
  96. data/spec/locales/it_spec.rb +0 -10
  97. data/spec/locales/no_spec.rb +0 -9
  98. data/spec/locales/pl_spec.rb +0 -23
  99. data/spec/locales/ru_spec.rb +0 -23
  100. data/spec/locales/sk_spec.rb +0 -23
  101. data/spec/locales/th_spec.rb +0 -9
  102. data/spec/locales/vi_spec.rb +0 -8
  103. data/spec/r18n_spec.rb +0 -172
  104. data/spec/spec_helper.rb +0 -41
  105. data/spec/translated_spec.rb +0 -163
  106. data/spec/translation_spec.rb +0 -164
  107. data/spec/translations/extension/deep/en.yml +0 -1
  108. data/spec/translations/extension/en.yml +0 -2
  109. data/spec/translations/extension/notransl.yml +0 -1
  110. data/spec/translations/general/en.yml +0 -47
  111. data/spec/translations/general/nolocale.yml +0 -6
  112. data/spec/translations/general/ru.yml +0 -7
  113. data/spec/translations/two/en.yml +0 -2
  114. data/spec/translations/two/fr.yml +0 -0
  115. data/spec/yaml_loader_spec.rb +0 -61
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module R18n
4
+ module Locales
5
+ # Afrikaans locale
6
+ class Af < Locale
7
+ set(
8
+ title: 'Afrikaans',
9
+
10
+ week_start: :sondag,
11
+ wday_names: %w[
12
+ Sondag Maandag Dinsdag Woensdag Donderdag Vrydag Saterdag
13
+ ],
14
+ wday_abbrs: %w[So Ma Di Wo Do Vr Sa],
15
+
16
+ month_names: %w[
17
+ Januarie Februarie Maart April Mei Junie Julie Augustus September
18
+ Oktober November Desember
19
+ ],
20
+ month_abbrs: %w[Jan Feb Mrt Apr Mei Jun Jul Aug Sep Okt Nov Des],
21
+
22
+ time_am: "'s voormiddag",
23
+ time_pm: "'s namiddag",
24
+
25
+ date_format: '%d/%m/%Y',
26
+ full_format: '%-d %B',
27
+ year_format: '_, %Y',
28
+ time_format: '_, %R',
29
+ time_with_seconds_format: '_, %T',
30
+
31
+ number_decimal: '.',
32
+ number_group: ','
33
+ )
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module R18n
4
+ module Locales
5
+ # Azerbaijani locale
6
+ class Az < Locale
7
+ set(
8
+ title: 'Azərbaycanca',
9
+
10
+ wday_names: %w[
11
+ Bazar BazarErtəsi ÇərşənbəAxşamı Çərşənbə CüməAxşamı Cümə Şənbə
12
+ ],
13
+ wday_abbrs: %w[B. B.e Ç.a Ç. C.a C. Ş.],
14
+
15
+ month_names: %w[
16
+ yanvar fevral mart aprel may iyun iyul avqust sentyabr oktyabr noyabr
17
+ dekabr
18
+ ],
19
+ month_abbrs: %w[yan fev mar apr may iyn iyl avq sen okt noy dek],
20
+ month_standalone: %w[
21
+ Yanvar Fevral Mart Aprel May İyun İyul Avqust Sentyabr Oktyabr Noyabr
22
+ Dekabr
23
+ ],
24
+
25
+ time_am: ' gündüz',
26
+ time_pm: ' axşam',
27
+ date_format: '%d.%m.%Y',
28
+
29
+ number_decimal: ',',
30
+ number_group: ' '
31
+ )
32
+
33
+ def pluralize(_number)
34
+ 'n'
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module R18n
4
+ module Locales
5
+ # Bulgarian locale
6
+ class Bg < Locale
7
+ set(
8
+ title: 'Български',
9
+
10
+ wday_names: %w[Неделя Понеделник Вторник Сряда Четвъртък Петък Събота],
11
+ wday_abbrs: %w[Нед Пон Вто Сря Чет Пет Съб],
12
+
13
+ month_names: %w[
14
+ Януари Февруари Март Април Май Юни Юли Август Септември Октомври
15
+ Ноември Декември
16
+ ],
17
+ month_abbrs: %w[Яну Фев Мар Апр Май Юни Юли Авг Сеп Окт Ное Дек],
18
+ month_standalone: %w[
19
+ Януари Февруари Март Април Май Юни Юли Август Септември Октомври
20
+ Ноември Декември
21
+ ],
22
+ date_format: '%d.%m.%Y',
23
+
24
+ number_decimal: ',',
25
+ number_group: ' '
26
+ )
27
+ end
28
+ end
29
+ end
@@ -5,15 +5,18 @@ module R18n
5
5
  # Catalan locale
6
6
  class Ca < Locale
7
7
  set(
8
- title: 'Català',
8
+ title: 'Català',
9
9
  sublocales: %w[es en],
10
10
 
11
- wday_names: %w[diumenge dilluns dimarts dimecres dijous divendres
12
- dissabte],
11
+ wday_names: %w[
12
+ diumenge dilluns dimarts dimecres dijous divendres dissabte
13
+ ],
13
14
  wday_abbrs: %w[dg dl dm dc dj dv ds],
14
15
 
15
- month_names: %w[Gener Febrer Març Abril Maig Juny Juliol Agost
16
- Setembre Octubre Novembre Desembre],
16
+ month_names: %w[
17
+ Gener Febrer Març Abril Maig Juny Juliol Agost Setembre Octubre
18
+ Novembre Desembre
19
+ ],
17
20
  month_abbrs: %w[gen feb mar abr mai jun jul ago set oct nov des],
18
21
 
19
22
  date_format: '%d/%m/%Y',
@@ -21,7 +24,7 @@ module R18n
21
24
  year_format: '_ de %Y',
22
25
 
23
26
  number_decimal: ',',
24
- number_group: '.'
27
+ number_group: '.'
25
28
  )
26
29
  end
27
30
  end
@@ -11,23 +11,27 @@ module R18n
11
11
  wday_names: %w[Neděle Pondělí Úterý Středa Čtvrtek Pátek Sobota],
12
12
  wday_abbrs: %w[Ne Po Út St Čt Pá So],
13
13
 
14
- month_names: %w[ledna února března dubna května června července srpna
15
- září října listopadu prosince],
14
+ month_names: %w[
15
+ ledna února března dubna května června července srpna září října
16
+ listopadu prosince
17
+ ],
16
18
  month_abbrs: %w[led úno bře dub kvě čer čvc srp zář říj lis pro],
17
- month_standalone: %w[Leden Únor Březen Duben Květen Červen Červenec
18
- Srpen Září Říjen Listopad Prosinec],
19
+ month_standalone: %w[
20
+ Leden Únor Březen Duben Květen Červen Červenec Srpen Září Říjen
21
+ Listopad Prosinec
22
+ ],
19
23
 
20
- time_am: 'dop.',
21
- time_pm: 'odp.',
22
- date_format: '%e. %m. %Y',
23
- full_format: '%e. %B',
24
+ time_am: 'dop.',
25
+ time_pm: 'odp.',
26
+ date_format: '%-d. %m. %Y',
27
+ full_format: '%-d. %B',
24
28
 
25
29
  number_decimal: ',',
26
- number_group: ' '
30
+ number_group: ' '
27
31
  )
28
32
 
29
- def pluralize(n)
30
- case n
33
+ def pluralize(number)
34
+ case number
31
35
  when 0
32
36
  0
33
37
  when 1
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module R18n
4
+ module Locales
5
+ # Welsh locale
6
+ class Cy < Locale
7
+ set(
8
+ title: 'Welsh',
9
+ sublocales: [],
10
+
11
+ week_start: :sunday,
12
+ wday_names: [
13
+ 'Dydd Sul', 'Dydd Llun', 'Dydd Mawrth', 'Dydd Mercher', 'Dydd Iau',
14
+ 'Dydd Gwener', 'Dydd Sadwrn'
15
+ ],
16
+ wday_abbrs: %w[Sul Llu Maw Mer Iau Gwe Sad],
17
+
18
+ month_names: %w[
19
+ Ionawr Chwefror Mawrth Ebrill Mai Mehefin Gorffennaf Awst Medi Hydref
20
+ Tachwedd Rhagfyr
21
+ ],
22
+ month_abbrs: %w[Ion Chw Maw Ebr Mai Meh Gor Aws Med Hyd Tac Rha],
23
+
24
+ date_format: '%Y-%m-%d',
25
+ full_format: '%e o %B',
26
+ year_format: '_, %Y',
27
+
28
+ number_decimal: '.',
29
+ number_group: ','
30
+ )
31
+
32
+ def ordinalize(number)
33
+ case number % 10
34
+ when 1 then "#{number}af"
35
+ when 2 then "#{number}il"
36
+ when 3, 4 then "#{number}ydd"
37
+ when 11, 13, 14, 16, 17, 19 then "#{number}eg"
38
+ when 21..31 then "#{number}ain"
39
+ else "#{number}ed"
40
+ end
41
+ end
42
+
43
+ def format_date_full(date, year: true, **_kwargs)
44
+ format = full_format
45
+ format = year_format.sub('_', format) if year
46
+ strftime(date, format.sub('%e', ordinalize(date.mday)))
47
+ end
48
+ end
49
+ end
50
+ end
@@ -10,18 +10,21 @@ module R18n
10
10
  wday_names: %w[søndag mandag tirsdag onsdag torsdag fredag lørdag],
11
11
  wday_abbrs: %w[søn man tir ons tor fre lør],
12
12
 
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.],
13
+ month_names: %w[
14
+ januar februar marts april Maj juni juli august september oktober
15
+ november december
16
+ ],
17
+ month_abbrs: %w[
18
+ jan. feb. mar. apr. maj jun. jul. aug. sep. okt. nov. dec.
19
+ ],
17
20
 
18
- time_am: 'om formiddagen',
19
- time_pm: 'om eftermiddagen',
21
+ time_am: 'om formiddagen',
22
+ time_pm: 'om eftermiddagen',
20
23
  date_format: '%d.%m.%Y',
21
24
  full_format: '%d. %B %Y',
22
25
 
23
26
  number_decimal: ',',
24
- number_group: '.'
27
+ number_group: '.'
25
28
  )
26
29
  end
27
30
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module R18n
4
+ module Locales
5
+ # German locale
6
+ class De < Locale
7
+ set(
8
+ title: 'Deutsch',
9
+
10
+ wday_names: %w[
11
+ Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag
12
+ ],
13
+ wday_abbrs: %w[So Mo Di Mi Do Fr Sa],
14
+
15
+ month_names: %w[
16
+ Januar Februar März April Mai Juni Juli August September Oktober
17
+ November Dezember
18
+ ],
19
+ month_abbrs: %w[
20
+ Jan. Feb. Mär. Apr. Mai. Jun. Jul. Aug. Sep. Okt. Nov. Dez.
21
+ ],
22
+
23
+ time_am: 'vormittags',
24
+ time_pm: 'nachmittags',
25
+ date_format: '%d.%m.%Y',
26
+ full_format: '%-d. %B',
27
+
28
+ number_decimal: ',',
29
+ number_group: '.'
30
+ )
31
+ end
32
+ end
33
+ end
@@ -5,9 +5,9 @@ require_relative 'en'
5
5
  module R18n
6
6
  module Locales
7
7
  # Australian English locale
8
- class EnAu < En
8
+ class EnAU < En
9
9
  set title: 'Australian English',
10
- sublocales: %w[en]
10
+ sublocales: %w[en en-US en-GB]
11
11
  end
12
12
  end
13
13
  end
@@ -5,10 +5,10 @@ require_relative 'en'
5
5
  module R18n
6
6
  module Locales
7
7
  # British English locale
8
- class EnGb < En
8
+ class EnGB < En
9
9
  set(
10
10
  title: 'British English',
11
- sublocales: %w[en],
11
+ sublocales: %w[en en-US en-AU],
12
12
 
13
13
  date_format: '%d/%m/%Y'
14
14
  )
@@ -5,14 +5,15 @@ require_relative 'en'
5
5
  module R18n
6
6
  module Locales
7
7
  # American English locale
8
- class EnUs < En
8
+ class EnUS < En
9
9
  set(
10
10
  title: 'American English',
11
- sublocales: %w[en],
11
+ sublocales: %w[en en-GB en-AU],
12
12
 
13
13
  time_format: '_ %I:%M %p',
14
+ time_with_seconds_format: '_ %r',
14
15
  date_format: '%m/%d/%Y',
15
- full_format: '%B %e'
16
+ full_format: '%B %-d'
16
17
  )
17
18
  end
18
19
  end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module R18n
4
+ module Locales
5
+ # English locale
6
+ class En < Locale
7
+ set(
8
+ title: 'English',
9
+ sublocales: %w[en-US en-GB en-AU],
10
+
11
+ week_start: :sunday,
12
+ wday_names: %w[
13
+ Sunday Monday Tuesday Wednesday Thursday Friday Saturday
14
+ ],
15
+ wday_abbrs: %w[Sun Mon Tue Wed Thu Fri Sat],
16
+
17
+ month_names: %w[
18
+ January February March April May June July August September October
19
+ November December
20
+ ],
21
+ month_abbrs: %w[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec],
22
+
23
+ date_format: '%Y-%m-%d',
24
+ full_format: '%-d of %B',
25
+ year_format: '_, %Y',
26
+
27
+ number_decimal: '.',
28
+ number_group: ','
29
+ )
30
+
31
+ def ordinalize(number)
32
+ if (11..13).cover?(number % 100)
33
+ "#{number}th"
34
+ else
35
+ case number % 10
36
+ when 1 then "#{number}st"
37
+ when 2 then "#{number}nd"
38
+ when 3 then "#{number}rd"
39
+ else "#{number}th"
40
+ end
41
+ end
42
+ end
43
+
44
+ def format_date_full(date, year: true, **_kwargs)
45
+ format = full_format
46
+ format = year_format.sub('_', format) if year
47
+ strftime(date, format.sub('%-d', ordinalize(date.mday)))
48
+ end
49
+ end
50
+ end
51
+ end
@@ -10,16 +10,18 @@ module R18n
10
10
  wday_names: %w[dimanĉo lundo mardo merkredo ĵaŭdo vendredo sabato],
11
11
  wday_abbrs: %w[dim lun mar mer ĵaŭ ven sab],
12
12
 
13
- month_names: %w[januaro februaro marto aprilo majo junio julio
14
- aŭgusto septembro oktobro novembro decembro],
13
+ month_names: %w[
14
+ januaro februaro marto aprilo majo junio julio aŭgusto septembro
15
+ oktobro novembro decembro
16
+ ],
15
17
  month_abbrs: %w[jan feb mar apr maj jun jul aŭg sep okt nov dec],
16
18
 
17
19
  date_format: '%Y-%m-%d',
18
- full_format: 'la %e-a de %B',
20
+ full_format: 'la %-d-a de %B',
19
21
  year_format: '_ de %Y',
20
22
 
21
23
  number_decimal: '.',
22
- number_group: ' '
24
+ number_group: ' '
23
25
  )
24
26
  end
25
27
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'es'
4
+
5
+ module R18n
6
+ module Locales
7
+ # Chile Spanish locale
8
+ class EsCL < Es
9
+ set(
10
+ title: 'Español Chile',
11
+ sublocales: %w[es es-US],
12
+ date_format: '%d-%m-%Y'
13
+ )
14
+ end
15
+ end
16
+ end
@@ -5,16 +5,17 @@ require_relative 'es'
5
5
  module R18n
6
6
  module Locales
7
7
  # American Spanish locale
8
- class EsUs < Es
8
+ class EsUS < Es
9
9
  set(
10
10
  title: 'Español Estadounidense',
11
- sublocales: %w[es en],
11
+ sublocales: %w[es es-CL en],
12
12
 
13
- time_format: ' %I:%M %p',
13
+ time_format: '_ %I:%M %p',
14
+ time_with_seconds_format: '_ %r',
14
15
  date_format: '%m/%d/%Y',
15
16
 
16
17
  number_decimal: '.',
17
- number_group: ','
18
+ number_group: ','
18
19
  )
19
20
  end
20
21
  end