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.
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,27 +1,34 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module R18n
2
- class Locales::Fr < Locale
3
- set title: 'Français',
4
+ module Locales
5
+ # French locale
6
+ class Fr < Locale
7
+ set(
8
+ title: 'Français',
4
9
 
5
- wday_names: %w{dimanche lundi mardi mercredi jeudi vendredi samedi},
6
- wday_abbrs: %w{dim lun mar mer jeu ven sam},
10
+ wday_names: %w[dimanche lundi mardi mercredi jeudi vendredi samedi],
11
+ wday_abbrs: %w[dim lun mar mer jeu ven sam],
7
12
 
8
- month_names: %w{janvier février mars avril mai juin juillet août
9
- septembre octobre novembre décembre},
10
- month_abbrs: %w{jan fév mar avr mai jun jui aoû sep oct nov déc},
11
- month_standalone: %w{Janvier Février Mars Avril Mai Juin Juillet Août
12
- Septembre Octobre Novembre Décembre},
13
+ month_names: %w[janvier février mars avril mai juin juillet août
14
+ septembre octobre novembre décembre],
15
+ month_abbrs: %w[jan fév mar avr mai jun jui aoû sep oct nov déc],
16
+ month_standalone: %w[Janvier Février Mars Avril Mai Juin Juillet Août
17
+ Septembre Octobre Novembre Décembre],
13
18
 
14
19
  date_format: '%d/%m/%Y',
15
20
 
16
21
  number_decimal: ',',
17
22
  number_group: ' '
23
+ )
18
24
 
19
- def format_date_full(date, year = true, *params)
20
- full = super(date, year)
21
- if ' 1' == full[0..1]
22
- '1er' + full[2..-1]
23
- else
24
- full
25
+ def format_date_full(date, year = true, *_params)
26
+ full = super(date, year)
27
+ if full[0..1] == ' 1'
28
+ '1er' + full[2..-1]
29
+ else
30
+ full
31
+ end
25
32
  end
26
33
  end
27
34
  end
@@ -1,14 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module R18n
2
- class Locales::Gl < Locale
3
- set title: 'Galego',
4
- sublocales: %w{es en},
4
+ module Locales
5
+ # Galician locale
6
+ class Gl < Locale
7
+ set(
8
+ title: 'Galego',
9
+ sublocales: %w[es en],
5
10
 
6
- wday_names: %w{domingo luns martes mércores xoves venres sábado},
7
- wday_abbrs: %w{dom lun mar mér xov ven sáb},
11
+ wday_names: %w[domingo luns martes mércores xoves venres sábado],
12
+ wday_abbrs: %w[dom lun mar mér xov ven sáb],
8
13
 
9
- month_names: %w{xaneiro febreiro marzo abril maio xuño xullo
10
- agosto setembro outubro novembro decembro},
11
- month_abbrs: %w{xan feb mar abr mai xuñ xul ago set out nov dec},
14
+ month_names: %w[xaneiro febreiro marzo abril maio xuño xullo
15
+ agosto setembro outubro novembro decembro],
16
+ month_abbrs: %w[xan feb mar abr mai xuñ xul ago set out nov dec],
12
17
 
13
18
  date_format: '%d/%m/%Y',
14
19
  full_format: '%d de %B',
@@ -16,5 +21,7 @@ module R18n
16
21
 
17
22
  number_decimal: ',',
18
23
  number_group: '.'
24
+ )
25
+ end
19
26
  end
20
27
  end
@@ -1,31 +1,38 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module R18n
2
- class Locales::Hr < Locale
3
- set title: 'Hrvatski',
4
+ module Locales
5
+ # Croatian locale
6
+ class Hr < Locale
7
+ set(
8
+ title: 'Hrvatski',
4
9
 
5
10
  week_start: :monday,
6
- wday_names: %w{Nedjelja Ponedjeljak Utorak Srijeda Četvrtak Petak
7
- Subota},
8
- wday_abbrs: %w{Ned Pon Uto Sri Čet Pet Sub},
11
+ wday_names: %w[Nedjelja Ponedjeljak Utorak Srijeda Četvrtak Petak
12
+ Subota],
13
+ wday_abbrs: %w[Ned Pon Uto Sri Čet Pet Sub],
9
14
 
10
- month_names: %w{Siječanj Veljača Ožujak Travanj Svibanj Lipanj Srpanj
11
- Kolovoz Rujan Listopad Studeni Prosinac},
12
- month_abbrs: %w{Sij Velj Ožu Tra Svi Lip Srp Kol Ruj Lis Stu Pro},
15
+ month_names: %w[Siječanj Veljača Ožujak Travanj Svibanj Lipanj Srpanj
16
+ Kolovoz Rujan Listopad Studeni Prosinac],
17
+ month_abbrs: %w[Sij Velj Ožu Tra Svi Lip Srp Kol Ruj Lis Stu Pro],
13
18
 
14
19
  date_format: '%d.%m.%Y',
15
20
  full_format: '%e. %B',
16
21
 
17
22
  number_decimal: ',',
18
23
  number_group: '.'
24
+ )
19
25
 
20
- def pluralize(n)
21
- if 0 == n
22
- 0
23
- elsif n == 1
24
- 1
25
- elsif n >= 2 and n <= 4
26
- 2
27
- else
28
- 'n'
26
+ def pluralize(n)
27
+ if n.zero?
28
+ 0
29
+ elsif n == 1
30
+ 1
31
+ elsif n >= 2 && n <= 4
32
+ 2
33
+ else
34
+ 'n'
35
+ end
29
36
  end
30
37
  end
31
38
  end
@@ -1,14 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module R18n
2
- class Locales::Hu < Locale
3
- set title: 'Magyar',
4
+ module Locales
5
+ # Hungarian locale
6
+ class Hu < Locale
7
+ set(
8
+ title: 'Magyar',
4
9
 
5
10
  week_start: :monday,
6
- wday_names: %w{vasárnap hétfő kedd szerda csütörtök péntek szombat},
7
- wday_abbrs: %w{vas hét ked sze csü pén szo},
11
+ wday_names: %w[vasárnap hétfő kedd szerda csütörtök péntek szombat],
12
+ wday_abbrs: %w[vas hét ked sze csü pén szo],
8
13
 
9
- month_names: %w{január február március április május június július
10
- augusztus szeptember október november december},
11
- month_abbrs: %w{jan feb már ápr máj jún júl aug sze okt nov dec},
14
+ month_names: %w[január február március április május június július
15
+ augusztus szeptember október november december],
16
+ month_abbrs: %w[jan feb már ápr máj jún júl aug sze okt nov dec],
12
17
 
13
18
  date_format: '%Y. %m. %d.',
14
19
  full_format: '%B %e.',
@@ -17,24 +22,26 @@ module R18n
17
22
 
18
23
  number_decimal: ',',
19
24
  number_group: ' '
25
+ )
20
26
 
21
- def pluralize(n)
22
- 'n'
23
- end
27
+ def pluralize(_n)
28
+ 'n'
29
+ end
24
30
 
25
- def format_integer(integer)
26
- str = integer.to_s
27
- str[0] = '−' if 0 > integer # Real typographic minus
28
- group = number_group
31
+ def format_integer(integer)
32
+ str = integer.to_s
33
+ str[0] = '−' if integer < 0 # Real typographic minus
34
+ group = number_group
29
35
 
30
- # only group numbers if it has at least 5 digits
31
- # http://hu.wikisource.org/wiki/A_magyar_helyes%C3%ADr%C3%A1s_szab%C3%A1lyai/Az_%C3%ADr%C3%A1sjelek#274.
32
- if integer.abs >= 10000
33
- str.gsub(/(\d)(?=(\d\d\d)+(?!\d))/) do |match|
34
- match + group
36
+ # only group numbers if it has at least 5 digits
37
+ # http://hu.wikisource.org/wiki/A_magyar_helyes%C3%ADr%C3%A1s_szab%C3%A1lyai/Az_%C3%ADr%C3%A1sjelek#274.
38
+ if integer.abs >= 10_000
39
+ str.gsub(/(\d)(?=(\d\d\d)+(?!\d))/) do |match|
40
+ match + group
41
+ end
42
+ else
43
+ str
35
44
  end
36
- else
37
- str
38
45
  end
39
46
  end
40
47
  end
@@ -1,17 +1,24 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module R18n
2
- class Locales::Id < Locale
3
- set title: 'Bahasa Indonesia',
4
+ module Locales
5
+ # Indonesian locale
6
+ class Id < Locale
7
+ set(
8
+ title: 'Bahasa Indonesia',
4
9
 
5
- wday_names: %w{Minggu Senin Selasa Rabu Kamis Jumat Sabtu},
6
- wday_abbrs: %w{Min Sen Sel Rab Kam Jum Sab},
10
+ wday_names: %w[Minggu Senin Selasa Rabu Kamis Jumat Sabtu],
11
+ wday_abbrs: %w[Min Sen Sel Rab Kam Jum Sab],
7
12
 
8
- month_names: %w{Januari Februari Maret April Mei Juni Juli Agustus
9
- September Oktober Nopember Desember},
10
- month_abbrs: %w{Jan Feb Mar Apr Mei Jun Jul Agu Sep Okt Nop Des},
13
+ month_names: %w[Januari Februari Maret April Mei Juni Juli Agustus
14
+ September Oktober Nopember Desember],
15
+ month_abbrs: %w[Jan Feb Mar Apr Mei Jun Jul Agu Sep Okt Nop Des],
11
16
 
12
17
  date_format: '%d/%m/%Y',
13
18
 
14
19
  number_decimal: ',',
15
20
  number_group: '.'
21
+ )
22
+ end
16
23
  end
17
24
  end
@@ -1,26 +1,33 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module R18n
2
- class Locales::It < Locale
3
- set title: 'Italiano',
4
+ module Locales
5
+ # Italian locale
6
+ class It < Locale
7
+ set(
8
+ title: 'Italiano',
4
9
 
5
- wday_names: %w{domenica lunedì martedì mercoledì giovedì venerdì
6
- sabato},
7
- wday_abbrs: %w{dom lun mar mer gio ven sab},
10
+ wday_names: %w[domenica lunedì martedì mercoledì giovedì venerdì
11
+ sabato],
12
+ wday_abbrs: %w[dom lun mar mer gio ven sab],
8
13
 
9
- month_names: %w{gennaio febbraio marzo aprile maggio giugno
10
- luglio agosto settembre ottobre novembre dicembre},
11
- month_abbrs: %w{gen feb mar apr mag giu lug ago set ott nov dic},
14
+ month_names: %w[gennaio febbraio marzo aprile maggio giugno
15
+ luglio agosto settembre ottobre novembre dicembre],
16
+ month_abbrs: %w[gen feb mar apr mag giu lug ago set ott nov dic],
12
17
 
13
18
  date_format: '%d/%m/%Y',
14
19
 
15
20
  number_decimal: ',',
16
21
  number_group: ' '
22
+ )
17
23
 
18
- def format_date_full(date, year = true, *params)
19
- full = super(date, year)
20
- if ' 1' == full[0..1]
21
- '1º' + full[2..-1]
22
- else
23
- full
24
+ def format_date_full(date, year = true, *_params)
25
+ full = super(date, year)
26
+ if full[0..1] == ' 1'
27
+ '1º' + full[2..-1]
28
+ else
29
+ full
30
+ end
24
31
  end
25
32
  end
26
33
  end
@@ -1,13 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module R18n
2
- class Locales::Ja < Locale
3
- set title: '日本語',
4
+ module Locales
5
+ # Japanese locale
6
+ class Ja < Locale
7
+ set(
8
+ title: '日本語',
4
9
 
5
10
  week_start: :sunday,
6
- wday_names: %w{日曜日 月曜日 火曜日 水曜日 木曜日 金曜日 土曜日},
7
- wday_abbrs: %w{日 月 火 水 木 金 土},
11
+ wday_names: %w[日曜日 月曜日 火曜日 水曜日 木曜日 金曜日 土曜日],
12
+ wday_abbrs: %w[日 月 火 水 木 金 土],
8
13
 
9
- month_names: %w{一月 二月 三月 四月 五月 六月 七月 八月 九月 十月 十一月
10
- 十二月},
14
+ month_names: %w[一月 二月 三月 四月 五月 六月 七月 八月 九月 十月 十一月
15
+ 十二月],
11
16
 
12
17
  date_format: '%Y年%m月%d日',
13
18
  full_format: '%m月%d日',
@@ -15,9 +20,11 @@ module R18n
15
20
 
16
21
  number_decimal: '.',
17
22
  number_group: ','
23
+ )
18
24
 
19
- def pluralize(n)
20
- 'n'
25
+ def pluralize(_n)
26
+ 'n'
27
+ end
21
28
  end
22
29
  end
23
30
  end
@@ -1,16 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module R18n
2
- class Locales::Kk < Locale
3
- set title: 'Қазақша',
4
- sublocales: %w{ru en},
4
+ module Locales
5
+ # Kazakh locale
6
+ class Kk < Locale
7
+ set(
8
+ title: 'Қазақша',
9
+ sublocales: %w[ru en],
5
10
 
6
- wday_names: %w{Жексенбі Дүйсенбі Сейсенбі Сәрсенбі Бейсенбі Жұма Сенбі},
7
- wday_abbrs: %w{Жк Дс Сс Ср Бс Жм Сн},
11
+ wday_names: %w[Жексенбі Дүйсенбі Сейсенбі Сәрсенбі Бейсенбі Жұма Сенбі],
12
+ wday_abbrs: %w[Жк Дс Сс Ср Бс Жм Сн],
8
13
 
9
- month_names: %w{қаңтар ақпан наурыз сәуір мамыр маусым шілде тамыз
10
- қырқүйек қазан қараша желтоқсан},
11
- month_abbrs: %w{қаң ақп нау сәу мам мау шіл там қыр қаз қар жел},
12
- month_standalone: %w{Қаңтар Ақпан Наурыз Сәуір Мамыр Маусым Шілде
13
- Тамыз Қыркүйек Қазан Қараша Желтоқсан},
14
+ month_names: %w[қаңтар ақпан наурыз сәуір мамыр маусым шілде тамыз
15
+ қырқүйек қазан қараша желтоқсан],
16
+ month_abbrs: %w[қаң ақп нау сәу мам мау шіл там қыр қаз қар жел],
17
+ month_standalone: %w[Қаңтар Ақпан Наурыз Сәуір Мамыр Маусым Шілде
18
+ Тамыз Қыркүйек Қазан Қараша Желтоқсан],
14
19
 
15
20
  time_am: ' ертеңің',
16
21
  time_pm: ' кештің',
@@ -20,5 +25,7 @@ module R18n
20
25
 
21
26
  number_decimal: ',',
22
27
  number_group: ' '
28
+ )
29
+ end
23
30
  end
24
31
  end
@@ -1,19 +1,25 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  module R18n
3
- class Locales::Ko < Locale
4
- set title: '한국어',
4
+ module Locales
5
+ # Korean locale
6
+ class Ko < Locale
7
+ set(
8
+ title: '한국어',
5
9
 
6
- wday_names: %w{일요일 월요일 화요일 수요일 목요일 금요일 토요일},
7
- wday_abbrs: %w{일 월 화 수 목 금 토},
10
+ wday_names: %w[일요일 월요일 화요일 수요일 목요일 금요일 토요일],
11
+ wday_abbrs: %w[일 월 화 수 목 금 토],
8
12
 
9
- month_names: %w{1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월},
10
- month_abbrs: %w{1 2 3 4 5 6 7 8 9 10 11 12},
13
+ month_names: %w[1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월],
14
+ month_abbrs: %w[1 2 3 4 5 6 7 8 9 10 11 12],
11
15
 
12
16
  date_format: '%Y/%m/%d',
13
17
  full_format: '%m월 %d일',
14
18
  year_format: '%Y년 _',
15
19
 
16
- number_decimal: ".",
17
- number_group: ","
20
+ number_decimal: '.',
21
+ number_group: ','
22
+ )
23
+ end
18
24
  end
19
25
  end
@@ -1,18 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module R18n
2
- class Locales::Lv < Locale
3
- set title: 'Latviešu',
4
+ module Locales
5
+ # Latvian locale
6
+ class Lv < Locale
7
+ set(
8
+ title: 'Latviešu',
4
9
 
5
10
  week_start: :monday,
6
- wday_names: %w{Svētdiena Pirmdiena Otrdiena Trešdiena Ceturtdiena
7
- Piektdiena Sestdiena},
8
- wday_abbrs: %w{Sv P O T C P S},
11
+ wday_names: %w[Svētdiena Pirmdiena Otrdiena Trešdiena Ceturtdiena
12
+ Piektdiena Sestdiena],
13
+ wday_abbrs: %w[Sv P O T C P S],
9
14
 
10
- month_names: %w{janvārī februārī martā aprīlī maijā jūnijā jūlijā
11
- augustā septembrī oktobrī novembrī decembrī},
12
- month_abbrs: %w{jan feb mar apr mai jūn jūl aug sep okt nov dec},
13
- month_standalone: %w{janvāris februāris marts aprīlis maijs jūnijs
15
+ month_names: %w[janvārī februārī martā aprīlī maijā jūnijā jūlijā
16
+ augustā septembrī oktobrī novembrī decembrī],
17
+ month_abbrs: %w[jan feb mar apr mai jūn jūl aug sep okt nov dec],
18
+ month_standalone: %w[janvāris februāris marts aprīlis maijs jūnijs
14
19
  jūlijs augusts septembris oktobris novembris
15
- decembris},
20
+ decembris],
16
21
 
17
22
  date_format: '%d.%m.%Y.',
18
23
  full_format: '%e.%B',
@@ -20,14 +25,16 @@ module R18n
20
25
 
21
26
  number_decimal: ',',
22
27
  number_group: ' '
28
+ )
23
29
 
24
- def pluralize(n)
25
- if 0 == n
26
- 0
27
- elsif 1 == n % 10 and 11 != n % 100
28
- 1
29
- else
30
- 'n'
30
+ def pluralize(n)
31
+ if n.zero?
32
+ 0
33
+ elsif n % 10 == 1 && n % 100 != 11
34
+ 1
35
+ else
36
+ 'n'
37
+ end
31
38
  end
32
39
  end
33
40
  end