r18n-core 3.2.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +39 -33
  3. data/lib/r18n-core.rb +29 -15
  4. data/lib/r18n-core/filter_list.rb +15 -10
  5. data/lib/r18n-core/filters.rb +22 -26
  6. data/lib/r18n-core/helpers.rb +2 -2
  7. data/lib/r18n-core/i18n.rb +61 -59
  8. data/lib/r18n-core/locale.rb +120 -97
  9. data/{locales → lib/r18n-core/locales}/af.rb +12 -8
  10. data/lib/r18n-core/locales/az.rb +38 -0
  11. data/lib/r18n-core/locales/bg.rb +29 -0
  12. data/{locales → lib/r18n-core/locales}/ca.rb +9 -6
  13. data/{locales → lib/r18n-core/locales}/cs.rb +11 -7
  14. data/lib/r18n-core/locales/cy.rb +50 -0
  15. data/{locales → lib/r18n-core/locales}/da.rb +10 -7
  16. data/lib/r18n-core/locales/de.rb +33 -0
  17. data/{locales → lib/r18n-core/locales}/en-au.rb +1 -1
  18. data/{locales → lib/r18n-core/locales}/en-gb.rb +1 -1
  19. data/{locales → lib/r18n-core/locales}/en-us.rb +2 -1
  20. data/{locales → lib/r18n-core/locales}/en.rb +8 -5
  21. data/{locales → lib/r18n-core/locales}/eo.rb +5 -3
  22. data/lib/r18n-core/locales/es-cl.rb +16 -0
  23. data/{locales → lib/r18n-core/locales}/es-us.rb +4 -3
  24. data/{locales → lib/r18n-core/locales}/es.rb +5 -3
  25. data/{locales → lib/r18n-core/locales}/fa.rb +1 -1
  26. data/lib/r18n-core/locales/fi.rb +39 -0
  27. data/{locales → lib/r18n-core/locales}/fr.rb +10 -6
  28. data/{locales → lib/r18n-core/locales}/gl.rb +5 -3
  29. data/{locales → lib/r18n-core/locales}/hr.rb +8 -5
  30. data/{locales → lib/r18n-core/locales}/hu.rb +8 -5
  31. data/{locales → lib/r18n-core/locales}/id.rb +8 -4
  32. data/{locales → lib/r18n-core/locales}/it.rb +8 -5
  33. data/{locales → lib/r18n-core/locales}/ja.rb +4 -3
  34. data/{locales → lib/r18n-core/locales}/kk.rb +11 -7
  35. data/{locales → lib/r18n-core/locales}/ko.rb +0 -0
  36. data/lib/r18n-core/locales/lv.rb +46 -0
  37. data/lib/r18n-core/locales/mn.rb +30 -0
  38. data/{locales → lib/r18n-core/locales}/nb.rb +5 -3
  39. data/{locales → lib/r18n-core/locales}/nl.rb +10 -7
  40. data/{locales → lib/r18n-core/locales}/no.rb +0 -0
  41. data/lib/r18n-core/locales/pl.rb +45 -0
  42. data/{locales → lib/r18n-core/locales}/pt-br.rb +1 -1
  43. data/lib/r18n-core/locales/pt.rb +35 -0
  44. data/lib/r18n-core/locales/ru.rb +46 -0
  45. data/{locales → lib/r18n-core/locales}/sk.rb +10 -6
  46. data/{locales → lib/r18n-core/locales}/sr-latn.rb +5 -3
  47. data/{locales → lib/r18n-core/locales}/sv-se.rb +6 -4
  48. data/lib/r18n-core/locales/th.rb +41 -0
  49. data/{locales → lib/r18n-core/locales}/tr.rb +5 -4
  50. data/lib/r18n-core/locales/uk.rb +31 -0
  51. data/{locales → lib/r18n-core/locales}/vi.rb +11 -7
  52. data/{locales → lib/r18n-core/locales}/zh-cn.rb +1 -1
  53. data/{locales → lib/r18n-core/locales}/zh-tw.rb +3 -3
  54. data/{locales → lib/r18n-core/locales}/zh.rb +4 -3
  55. data/lib/r18n-core/translated.rb +35 -34
  56. data/lib/r18n-core/translated_string.rb +4 -2
  57. data/lib/r18n-core/translation.rb +16 -17
  58. data/lib/r18n-core/unsupported_locale.rb +6 -5
  59. data/lib/r18n-core/untranslated.rb +10 -4
  60. data/lib/r18n-core/utils.rb +1 -14
  61. data/lib/r18n-core/version.rb +1 -1
  62. data/lib/r18n-core/yaml_loader.rb +13 -13
  63. data/lib/r18n-core/yaml_methods.rb +3 -1
  64. data/r18n-core.gemspec +1 -1
  65. data/spec/filters_spec.rb +3 -0
  66. data/spec/i18n_spec.rb +22 -8
  67. data/spec/locale_spec.rb +4 -5
  68. data/spec/locales/af_spec.rb +9 -0
  69. data/spec/locales/en-us_spec.rb +16 -1
  70. data/spec/locales/es-us_spec.rb +11 -0
  71. data/spec/locales/fi_spec.rb +9 -0
  72. data/spec/locales/hu_spec.rb +2 -0
  73. data/spec/locales/id_spec.rb +23 -0
  74. data/spec/locales/vi_spec.rb +4 -3
  75. data/spec/r18n_spec.rb +21 -7
  76. data/spec/spec_helper.rb +0 -7
  77. data/spec/translated_spec.rb +121 -65
  78. data/spec/translation_spec.rb +5 -2
  79. data/spec/translations/with_regions/en-US.yml +0 -0
  80. data/spec/translations/yaml/en-GB.yml +1 -0
  81. data/spec/translations/yaml/en-us.yml +1 -0
  82. data/spec/yaml_loader_spec.rb +4 -2
  83. metadata +64 -50
  84. data/locales/az.rb +0 -34
  85. data/locales/bg.rb +0 -25
  86. data/locales/cy.rb +0 -50
  87. data/locales/de.rb +0 -29
  88. data/locales/fi.rb +0 -35
  89. data/locales/lv.rb +0 -41
  90. data/locales/mn.rb +0 -27
  91. data/locales/pl.rb +0 -40
  92. data/locales/pt.rb +0 -29
  93. data/locales/ru.rb +0 -41
  94. data/locales/th.rb +0 -37
  95. data/locales/uk.rb +0 -27
@@ -8,24 +8,28 @@ module R18n
8
8
  title: 'Afrikaans',
9
9
 
10
10
  week_start: :sondag,
11
- wday_names: %w[Sondag Maandag Dinsdag Woensdag Donderdag Vrydag
12
- Saterdag],
11
+ wday_names: %w[
12
+ Sondag Maandag Dinsdag Woensdag Donderdag Vrydag Saterdag
13
+ ],
13
14
  wday_abbrs: %w[So Ma Di Wo Do Vr Sa],
14
15
 
15
- month_names: %w[Januarie Februarie Maart April Mei Junie Julie Augustus
16
- September Oktober November Desember],
16
+ month_names: %w[
17
+ Januarie Februarie Maart April Mei Junie Julie Augustus September
18
+ Oktober November Desember
19
+ ],
17
20
  month_abbrs: %w[Jan Feb Mrt Apr Mei Jun Jul Aug Sep Okt Nov Des],
18
21
 
19
- time_am: "'s voormiddag",
20
- time_pm: "'s namiddag",
22
+ time_am: "'s voormiddag",
23
+ time_pm: "'s namiddag",
21
24
 
22
25
  date_format: '%d/%m/%Y',
23
26
  full_format: '%-d %B',
24
27
  year_format: '_, %Y',
25
- time_format: '_, %H:%M',
28
+ time_format: '_, %R',
29
+ time_with_seconds_format: '_, %T',
26
30
 
27
31
  number_decimal: '.',
28
- number_group: ','
32
+ number_group: ','
29
33
  )
30
34
  end
31
35
  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,19 +11,23 @@ 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.',
24
+ time_am: 'dop.',
25
+ time_pm: 'odp.',
22
26
  date_format: '%-d. %m. %Y',
23
27
  full_format: '%-d. %B',
24
28
 
25
29
  number_decimal: ',',
26
- number_group: ' '
30
+ number_group: ' '
27
31
  )
28
32
 
29
33
  def pluralize(number)
@@ -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, *_params)
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,7 +5,7 @@ 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
10
  sublocales: %w[en]
11
11
  end
@@ -5,7 +5,7 @@ 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
11
  sublocales: %w[en],
@@ -5,12 +5,13 @@ 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
11
  sublocales: %w[en],
12
12
 
13
13
  time_format: '_ %I:%M %p',
14
+ time_with_seconds_format: '_ %r',
14
15
  date_format: '%m/%d/%Y',
15
16
  full_format: '%B %-d'
16
17
  )
@@ -9,12 +9,15 @@ module R18n
9
9
  sublocales: [],
10
10
 
11
11
  week_start: :sunday,
12
- wday_names: %w[Sunday Monday Tuesday Wednesday Thursday Friday
13
- Saturday],
12
+ wday_names: %w[
13
+ Sunday Monday Tuesday Wednesday Thursday Friday Saturday
14
+ ],
14
15
  wday_abbrs: %w[Sun Mon Tue Wed Thu Fri Sat],
15
16
 
16
- month_names: %w[January February March April May June July August
17
- September October November December],
17
+ month_names: %w[
18
+ January February March April May June July August September October
19
+ November December
20
+ ],
18
21
  month_abbrs: %w[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec],
19
22
 
20
23
  date_format: '%Y-%m-%d',
@@ -22,7 +25,7 @@ module R18n
22
25
  year_format: '_, %Y',
23
26
 
24
27
  number_decimal: '.',
25
- number_group: ','
28
+ number_group: ','
26
29
  )
27
30
 
28
31
  def ordinalize(number)
@@ -10,8 +10,10 @@ 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',
@@ -19,7 +21,7 @@ module R18n
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],
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
11
  sublocales: %w[es 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
@@ -10,8 +10,10 @@ module R18n
10
10
  wday_names: %w[domingo lunes martes miércoles jueves viernes sábado],
11
11
  wday_abbrs: %w[dom lun mar mie jue vie sab],
12
12
 
13
- month_names: %w[Enero Febrero Marzo Abril Mayo Junio Julio Agosto
14
- Septiembre Octubre Noviembre Diciembre],
13
+ month_names: %w[
14
+ Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre
15
+ Noviembre Diciembre
16
+ ],
15
17
  month_abbrs: %w[ene feb mar abr may jun jul ago sep oct nov dic],
16
18
 
17
19
  date_format: '%d/%m/%Y',
@@ -19,7 +21,7 @@ module R18n
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
@@ -24,7 +24,7 @@ module R18n
24
24
  year_format: '_ %Y',
25
25
 
26
26
  number_decimal: '٫',
27
- number_group: '٬'
27
+ number_group: '٬'
28
28
  )
29
29
 
30
30
  # Change direction
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module R18n
4
+ module Locales
5
+ # Finnish locale
6
+ class Fi < Locale
7
+ set(
8
+ title: 'Suomi',
9
+
10
+ wday_names: %w[
11
+ sunnuntai maanantai tiistai keskiviikko torstai terjantai lauantai
12
+ ],
13
+ wday_abbrs: %w[su ma ti ke to te la],
14
+
15
+ month_names: %w[
16
+ tammikuuta helmikuuta maaliskuuta huhtikuuta toukokuuta kesäkuuta
17
+ heinäkuuta elokuuta syyskuuta lokakuuta marraskuuta joulukuuta
18
+ ],
19
+ month_abbrs: %w[tam hel maa huh tou kes hei elo syy lok mar jou],
20
+ month_standalone: %w[
21
+ tammikuu helmikuu maaliskuu huhtikuu toukokuu kesäkuu heinäkuu elokuu
22
+ syyskuu lokakuu marraskuu joulukuu
23
+ ],
24
+
25
+ date_format: '%d.%m.%Y',
26
+ full_format: '%-d. %B',
27
+ time_format: '_ %H.%M',
28
+ time_with_seconds_format: '_ %H.%M.%S',
29
+
30
+ number_decimal: ',',
31
+ number_group: ''
32
+ )
33
+
34
+ def format_time_full(time, *_params)
35
+ format_time(format_date_full(time) + ' kello', time)
36
+ end
37
+ end
38
+ end
39
+ end