pagy 2.1.5 → 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.
@@ -1,20 +1,20 @@
1
+ # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
1
3
  ja:
2
4
  pagy:
5
+
6
+ item_name: "結果"
7
+
3
8
  nav:
4
9
  prev: "‹ 前へ"
5
10
  next: "次へ ›"
6
11
  gap: "…"
12
+
7
13
  info:
8
- single_page:
9
- zero: "見つかりませんでした"
10
- one: "<b>1</b> 件の%{item_name}"
11
- other: "<b>%{count}</b> 件の%{item_name}"
14
+ no_items: "見つかりませんでした"
15
+ single_page: "<b>%{count}</b> 件の%{item_name}"
12
16
  multiple_pages: "<b>%{count}</b> 件中 <b>%{from}-%{to}</b> 件目の%{item_name}を表示中"
13
- item_name:
14
- zero: "結果"
15
- one: "結果"
16
- other: "結果"
17
- compact: "%{page_input} / %{pages} ページ"
18
- items:
19
- one: "%{items_input} 件ずつ表示"
20
- other: "%{items_input} 件ずつ表示"
17
+
18
+ combo_nav_js: "%{page_input} / %{pages} ページ"
19
+
20
+ items_selector_js: "%{items_input} 件ずつ表示"
@@ -1,20 +1,22 @@
1
+ # :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
1
3
  nb:
2
4
  pagy:
5
+
6
+ item_name:
7
+ one: "resultat"
8
+ other: "resultater"
9
+
3
10
  nav:
4
11
  prev: "&lsaquo;&nbsp;Forrige"
5
12
  next: "Neste&nbsp;&rsaquo;"
6
13
  gap: "&hellip;"
14
+
7
15
  info:
8
- single_page:
9
- zero: "Ingen %{item_name} funnet"
10
- one: "Viser <b>1</b> %{item_name}"
11
- other: "Viser <b>alle %{count}</b> %{item_name}"
16
+ no_items: "Ingen %{item_name} funnet"
17
+ single_page: "Viser <b>%{count}</b> %{item_name}"
12
18
  multiple_pages: "Viser %{item_name} <b>%{from}-%{to}</b> av totalt <b>%{count}</b>"
13
- item_name:
14
- zero: "resultater"
15
- one: "resultat"
16
- other: "resultater"
17
- compact: "Side %{page_input} av %{pages}"
18
- items:
19
- one: "Vis %{items_input} resultat per side"
20
- other: "Vis %{items_input} resultater per side"
19
+
20
+ combo_nav_js: "Side %{page_input} av %{pages}"
21
+
22
+ items_selector_js: "Vis %{items_input} %{item_name} per side"
@@ -1,20 +1,22 @@
1
+ # :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
1
3
  nl:
2
4
  pagy:
5
+
6
+ item_name:
7
+ one: "stuk"
8
+ other: "stuks"
9
+
3
10
  nav:
4
11
  prev: "&lsaquo;&nbsp;Vorige"
5
12
  next: "Volgende&nbsp;&rsaquo;"
6
13
  gap: "&hellip;"
14
+
7
15
  info:
8
- single_page:
9
- zero: "Geen %{item_name} gevonden"
10
- one: "Toont <b>1</b> %{item_name}"
11
- other: "Toont <b>alle %{count}</b> %{item_name}"
16
+ no_items: "Geen %{item_name} gevonden"
17
+ single_page: "Toont <b>%{count}</b> %{item_name}"
12
18
  multiple_pages: "Toont <b>%{from}-%{to}</b> %{item_name} van <b>%{count}</b> in totaal"
13
- item_name:
14
- zero: "stuks"
15
- one: "stuk"
16
- other: "stuks"
17
- compact: "Pagina %{page_input} van %{pages}"
18
- items:
19
- one: "Toont %{items_input} item per pagina"
20
- other: "Toont %{items_input} items per pagina"
19
+
20
+ combo_nav_js: "Pagina %{page_input} van %{pages}"
21
+
22
+ items_selector_js: "Toont %{items_input} %{item_name} per pagina"
@@ -0,0 +1,24 @@
1
+ # :polish pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
3
+ pl:
4
+ pagy:
5
+
6
+ item_name:
7
+ one: "element"
8
+ few: "elementy"
9
+ many: "elementów"
10
+ other: "elementów"
11
+
12
+ nav:
13
+ prev: "&lsaquo;&nbsp;Poprzednia"
14
+ next: "Następna&nbsp;&rsaquo;"
15
+ gap: "&hellip;"
16
+
17
+ info:
18
+ no_items: "Nie znaleziono %{item_name}"
19
+ single_page: "Wyświetlono <b>%{count}</b> %{item_name}"
20
+ multiple_pages: "Wyświetlono %{item_name} <b>%{from}-%{to}</b> z wszystkich <b>%{count}</b>"
21
+
22
+ combo_nav_js: "Strona %{page_input} z %{pages}"
23
+
24
+ items_selector_js: "Pokaż %{items_input} %{item_name} na stronie"
@@ -1,20 +1,22 @@
1
+ # :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
1
3
  pt-br:
2
4
  pagy:
5
+
6
+ item_name:
7
+ one: "item"
8
+ other: "itens"
9
+
3
10
  nav:
4
11
  prev: "&lsaquo;&nbsp;Anterior"
5
12
  next: "Próximo&nbsp;&rsaquo;"
6
13
  gap: "&hellip;"
14
+
7
15
  info:
8
- single_page:
9
- zero: "Sem resultados"
10
- one: "Mostrando 1 %{item_name}"
11
- other: "Mostrando %{count} %{item_name}"
16
+ no_items: "Sem resultados"
17
+ single_page: "Mostrando %{count} %{item_name}"
12
18
  multiple_pages: "Mostrando %{item_name} %{from}-%{to} do total de %{count}"
13
- item_name:
14
- zero: "itens"
15
- one: "item"
16
- other: "itens"
17
- compact: "Página %{page_input} de %{pages}"
18
- items:
19
- one: "Mostrar %{items_input} item por página"
20
- other: "Mostrar %{items_input} itens por página"
19
+
20
+ combo_nav_js: "Página %{page_input} de %{pages}"
21
+
22
+ items_selector_js: "Mostrar %{items_input} %{item_name} por página"
@@ -1,25 +1,24 @@
1
+ # :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
1
3
  ru:
2
4
  pagy:
5
+
6
+ item_name:
7
+ one: "запись"
8
+ few: "записи"
9
+ many: "записей"
10
+ other: "записей"
11
+
3
12
  nav:
4
13
  prev: "&lsaquo;&nbsp;Назад"
5
14
  next: "Вперёд&nbsp;&rsaquo;"
6
15
  gap: "&hellip;"
16
+
7
17
  info:
8
- single_page:
9
- zero: "Пока %{item_name} нет"
10
- one: "<b>1</b> %{item_name}"
11
- few: "<b>%{count}</b> %{item_name}"
12
- many: "Всего <b>%{count}</b> %{item_name}"
13
- other: "Всего <b>%{count}</b> %{item_name}"
18
+ no_items: "Пока %{item_name} нет"
19
+ single_page: "<b>%{count}</b> %{item_name}"
14
20
  multiple_pages: "Всего <b>%{count}</b> %{item_name}, показаны с <b>%{from}</b> по <b>%{to}</b>"
15
- item_name:
16
- one: "запись"
17
- few: "записи"
18
- many: "записей"
19
- other: "записей"
20
- compact: "Страница %{page_input} из %{pages}"
21
- items:
22
- one: "Показать %{items_input} записей на странице"
23
- few: "Показать %{items_input} записей на странице"
24
- many: "Показать %{items_input} записей на странице"
25
- other: "Показать %{items_input} записей на странице"
21
+
22
+ combo_nav_js: "Страница %{page_input} из %{pages}"
23
+
24
+ items_selector_js: "Показать %{items_input} %{item_name} на странице"
@@ -1,20 +1,23 @@
1
+ # :one_two_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
1
3
  se:
2
4
  pagy:
5
+
6
+ item_name:
7
+ one: "resultat"
8
+ two: "resultat"
9
+ other: "resultat"
10
+
3
11
  nav:
4
12
  prev: "&lsaquo;&nbsp;Föregående"
5
13
  next: "Nästa&nbsp;&rsaquo;"
6
14
  gap: "&hellip;"
15
+
7
16
  info:
8
- single_page:
9
- zero: "Inga %{item_name} hittade"
10
- one: "Visar <b>1</b> %{item_name}"
11
- other: "Visar <b>alla %{count}</b> %{item_name}"
17
+ no_items: "Inga %{item_name} hittade"
18
+ single_page: "Visar <b>%{count}</b> %{item_name}"
12
19
  multiple_pages: "Visar %{item_name} <b>%{from}-%{to}</b> av <b>%{count}</b> totalt"
13
- item_name:
14
- zero: "resultat"
15
- one: "resultat"
16
- other: "resultat"
17
- compact: "Sida %{page_input} av %{pages}"
18
- items:
19
- one: "Visa %{items_input} resultat per sida"
20
- other: "Visa %{items_input} resultat per sida"
20
+
21
+ combo_nav_js: "Sida %{page_input} av %{pages}"
22
+
23
+ items_selector_js: "Visa %{items_input} %{item_name} per sida"
@@ -1,20 +1,20 @@
1
+ # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
1
3
  tr:
2
4
  pagy:
5
+
6
+ item_name: "kayıt"
7
+
3
8
  nav:
4
9
  prev: "&lsaquo;&nbsp;Önceki"
5
10
  next: "Sonraki&nbsp;&rsaquo;"
6
11
  gap: "&hellip;"
12
+
7
13
  info:
8
- single_page:
9
- zero: "Hiç %{item_name} bulunamadı."
10
- one: "<b>1</b> %{item_name} gösteriliyor."
11
- other: "Toplam <b>%{count}</b> %{item_name} gösteriliyor."
12
- multiple_pages: "<b>%{count}</b> %{item_name} içerisinden <b>%{from}-%{to}</b> kadarı gösteriliyor."
13
- item_name:
14
- zero: "kayıt"
15
- one: "kayıt"
16
- other: "kayıt"
17
- compact: "Sayfa %{page_input} / %{pages}"
18
- items:
19
- one: "Sayfada %{items_input} kayıt göster"
20
- other: "Sayfada %{items_input} kayıt göster"
14
+ no_items: "Hiç %{item_name} bulunamadı"
15
+ single_page: "Toplam <b>%{count}</b> %{item_name} gösteriliyor"
16
+ multiple_pages: "<b>%{count}</b> %{item_name} içerisinden <b>%{from}-%{to}</b> kadarı gösteriliyor"
17
+
18
+ combo_nav_js: "Sayfa %{page_input} / %{pages}"
19
+
20
+ items_selector_js: "Sayfada %{items_input} %{item_name} göster"
@@ -4,7 +4,7 @@
4
4
  # the whole file will be eval'ed/executed and gc-collected after returning/executing the loader proc
5
5
 
6
6
  # eval: no need for the whole file in memory
7
- p11n = eval(Pagy.root.join('locales', 'utils', 'p11n.rb').read) #rubocop:disable Security/Eval
7
+ plurals, _ = eval(Pagy.root.join('locales', 'utils', 'p11n.rb').read) #rubocop:disable Security/Eval
8
8
 
9
9
  # flatten the dictionary file nested keys
10
10
  # convert each value to a simple ruby interpolation proc
@@ -16,19 +16,12 @@ flatten = lambda do |hash, key=''|
16
16
  end
17
17
  end
18
18
 
19
- normalized_locales = {'zh-cn'=>'zh-CN', 'zh-hk'=>'zh-HK'}
20
-
21
19
  # loader proc
22
20
  lambda do |i18n, *args|
23
21
  i18n.clear
24
22
  args.each do |arg|
25
- if normalized_locales.key?(arg[:locale])
26
- right_locale = normalized_locales[arg[:locale]]
27
- Warning.warn("\n*** WARNING *** [Pagy::I18n.load] The '#{arg[:locale]}' locale is incorrect and deprecated, please use '#{right_locale}'\n\n")
28
- arg[:locale] = right_locale
29
- end
30
23
  arg[:filepath] ||= Pagy.root.join('locales', "#{arg[:locale]}.yml")
31
- arg[:pluralize] ||= p11n[arg[:locale]]
24
+ arg[:pluralize] ||= plurals[arg[:locale]]
32
25
  hash = YAML.load(File.read(arg[:filepath], encoding: 'UTF-8')) #rubocop:disable Security/YAMLLoad
33
26
  hash.key?(arg[:locale]) or raise ArgumentError, %(Pagy::I18n.load: :locale "#{arg[:locale]}" not found in :filepath "#{arg[:filepath].inspect}")
34
27
  i18n[arg[:locale]] = [flatten.call(hash[arg[:locale]]), arg[:pluralize]]
@@ -6,46 +6,72 @@
6
6
  # It defines the pluralization procs and gets eval(ed) and gc-collected at Pagy::I18n.load time.
7
7
 
8
8
  # utility variables
9
- zero_one = ['zero', 'one'].freeze
10
- from2to4 = (2..4).freeze
11
- from5to9 = (5..9).freeze
12
- from11to14 = (11..14).freeze
13
- from12to14 = (12..14).freeze
9
+ from0to1 = [0,1].freeze
10
+ from2to4 = [2,3,4].freeze
11
+ from5to9 = [5,6,7,8,9].freeze
12
+ from11to14 = [11,12,13,14].freeze
13
+ from12to14 = [12,13,14].freeze
14
14
 
15
15
  # Pluralization (p11n)
16
+ # Compliant with the I18n gem
16
17
  # A pluralization proc returns a plural type string based on the passed count
17
- # Each proc may apply to one or more locales below
18
+ # Each proc may apply to one or more locales below.
19
+ # Pluralization logic adapted from https://github.com/svenfuchs/rails-i18n
18
20
  p11n = {
19
- zero_one_other: lambda {|count| zero_one[count] || 'other'},
20
-
21
- zero_one_few_many_other: lambda do |count|
22
- mod10, mod100 = count % 10, count % 100
23
- if count == 0 ; 'zero'
24
- elsif mod10 == 1 && mod100 != 11 ; 'one'
25
- elsif from2to4.cover?(mod10) && !from12to14.cover?(mod100) ; 'few'
26
- elsif mod10 == 0 || from5to9.cover?(mod10) || from11to14.cover?(mod100) ; 'many'
27
- else 'other'
21
+ one_other: lambda {|n| n == 1 ? 'one' : 'other'}, # default
22
+
23
+ east_slavic: lambda do |n|
24
+ n ||= 0
25
+ mod10 = n % 10
26
+ mod100 = n % 100
27
+
28
+ if mod10 == 1 && mod100 != 11 ; 'one'
29
+ elsif from2to4.include?(mod10) && !from12to14.include?(mod100) ; 'few'
30
+ elsif mod10 == 0 || from5to9.include?(mod10) || from11to14.include?(mod100) ; 'many'
31
+ else 'other'
32
+ end
33
+ end,
34
+
35
+ one_two_other: lambda do |n|
36
+ if n == 1 ; 'one'
37
+ elsif n == 2 ; 'two'
38
+ else 'other'
28
39
  end
29
40
  end,
30
41
 
31
- pl: lambda do |count|
32
- mod10, mod100 = count % 10, count % 100
33
- if count == 0 ; 'zero'
34
- elsif count == 1 ; 'one'
35
- elsif from2to4.cover?(mod10) && !from12to14.cover?(mod100) ; 'few'
36
- elsif [0, 1].include?(mod10) || from5to9.cover?(mod10) || from12to14.cover?(mod100) ; 'many'
37
- else 'other'
42
+ one_upto_two_other: lambda {|n| n && n >= 0 && n < 2 ? 'one' : 'other'},
43
+
44
+ other: Proc.new { 'other' },
45
+
46
+ polish: lambda do |n|
47
+ n ||= 0
48
+ mod10 = n % 10
49
+ mod100 = n % 100
50
+ if n == 1 ; 'one'
51
+ elsif from2to4.include?(mod10) && !from12to14.include?(mod100) ; 'few'
52
+ elsif (from0to1 + from5to9).include?(mod10) || from12to14.include?(mod100) ; 'many'
53
+ else 'other'
38
54
  end
39
55
  end
40
56
  }
41
57
 
42
58
  # Hash of locale/pluralization pairs
43
- # Contain all the entries for all the locales defined as dictionaries.
59
+ # It contains all the entries for all the locales defined as dictionaries.
44
60
  # The default pluralization for locales not explicitly listed here
45
- # is the :zero_one_other pluralization proc (used for English)
46
- Hash.new(p11n[:zero_one_other]).tap do |hash|
47
- hash['ru'] = p11n[:zero_one_few_many_other]
48
- hash['pl'] = p11n[:pl]
61
+ # is the :one_other pluralization proc (used for English)
62
+ plurals = Hash.new(p11n[:one_other]).tap do |hash|
63
+ hash['id'] = p11n[:other]
64
+ hash['fr'] = p11n[:one_upto_two_other]
65
+ hash['ja'] = p11n[:other]
66
+ hash['pl'] = p11n[:polish]
67
+ hash['ru'] = p11n[:east_slavic]
68
+ hash['se'] = p11n[:one_two_other]
69
+ hash['tr'] = p11n[:other]
70
+ hash['zh-CN'] = p11n[:other]
71
+ hash['zh-HK'] = p11n[:other]
72
+ hash['zh-TW'] = p11n[:other]
49
73
  end
50
74
 
75
+ [ plurals, p11n ]
76
+
51
77
  # PR for other locales and pluralizations are very welcome. Thanks!
@@ -1,20 +1,20 @@
1
+ # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
1
3
  zh-CN:
2
4
  pagy:
5
+
6
+ item_name: ""
7
+
3
8
  nav:
4
9
  prev: "&lsaquo;&nbsp;上一页"
5
10
  next: "下一页&nbsp;&rsaquo;"
6
11
  gap: "&hellip;"
12
+
7
13
  info:
8
- single_page:
9
- zero: "%{item_name}未找到"
10
- one: "显示 <b>1</b> 项%{item_name}"
11
- other: "显示<b>所有 %{count}</b> 项%{item_name}"
14
+ no_items: "项目未找到"
15
+ single_page: "显示<b>%{count}</b> 项%{item_name}"
12
16
  multiple_pages: "共 <b>%{count}</b> 项%{item_name},显示 <b>%{from}-%{to}</b>"
13
- item_name:
14
- zero: "项目"
15
- one: ""
16
- other: ""
17
- compact: "第 %{page_input} / %{pages} 页"
18
- items:
19
- one: "每页显示 %{items_input} 条"
20
- other: "每页显示 %{items_input} 条"
17
+
18
+ combo_nav_js: "第 %{page_input} / %{pages} 页"
19
+
20
+ items_selector_js: "每页显示 %{items_input} 条%"
@@ -1,20 +1,20 @@
1
+ # :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
1
3
  zh-HK:
2
4
  pagy:
5
+
6
+ item_name: ""
7
+
3
8
  nav:
4
9
  prev: "&lsaquo;&nbsp;上一頁"
5
10
  next: "下一頁&nbsp;&rsaquo;"
6
11
  gap: "&hellip;"
12
+
7
13
  info:
8
- single_page:
9
- zero: "%{item_name}未搵到"
10
- one: "顯示 <b>1</b> %{item_name}"
11
- other: "顯示<b>所有 %{count}</b> %{item_name}"
12
- multiple_pages: " <b>%{count}</b> %{item_name},顯示 <b>%{from}-%{to}</b>"
13
- item_name:
14
- zero: "記錄"
15
- one: ""
16
- other: ""
17
- compact: "第 %{page_input} / %{pages} 頁"
18
- items:
19
- one: "每頁顯示 %{items_input} 記錄"
20
- other: "每頁顯示 %{items_input} 記錄"
14
+ no_items: "記錄未搵到"
15
+ single_page: "顯示 <b>%{count}</b> %{item_name}"
16
+ multiple_pages: " <b>%{count}</b> %{item_name},顯示 <b>%{from}-%{to}</b>"
17
+
18
+ combo_nav_js: " %{page_input} / %{pages} "
19
+
20
+ items_selector_js: "每頁顯示 %{items_input} 記錄"