pagy 3.7.0 → 3.7.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04bc8d434ab8fa91c3755122c9f04d0a3ab72e4e3f59a84234bfb2d7feb69e42
4
- data.tar.gz: 0a75675909e36c609f7d73b3a9ea3e7784097dd27cb34d265c1297b73fb96ff4
3
+ metadata.gz: f1294620f428cf3807db1ab558bebf4bc01cc43d1e5d1fce668eec802b8a3088
4
+ data.tar.gz: '094b895627f5bb472d952fbc8e078a23d9f830cc2f2b629945733853e83ef1ce'
5
5
  SHA512:
6
- metadata.gz: 96dd530c18f42cffcc2170f94967fd44f5c46568dbdba197d747aa39b00de8caec5478ed1c401ccd705636f14350553886bfeec95b36f583f499e66d3cf29cf6
7
- data.tar.gz: 987bbc4d012d1326e9540972bacd7a6b1df3081591bb4bbfc5337f20ba94bb6a9dfb2a90956ef2ac1b54076af39fa58f31e6f004c59998332fc4036f9f800df4
6
+ metadata.gz: 1a041ca4fad15e46930d178ff9f86c20d66f60408d0ca270d127e615fca4ea29529a04e376905b45742405240b8d55438fbb4be4b60fe9c400171cce222eac64
7
+ data.tar.gz: bd9f46987b98a2d83e8a03f3e16cf9f02272cbb9177d74e7a2b3e6eca30dcc20b1ed901d5d59a240a521decb0b359c9d5f5be21e10dbf1e970e67e5fc0499e21
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
- # Pagy initializer file (3.7.0)
4
+ # Pagy initializer file (3.7.5)
5
5
  # Customize only what you really need and notice that Pagy works also without any of the following lines.
6
6
  # Should you just cherry pick part of this file, please maintain the require-order of the extras
7
7
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  function Pagy(){}
4
4
 
5
- Pagy.version = '3.7.0';
5
+ Pagy.version = '3.7.5';
6
6
 
7
7
  Pagy.init = function(arg){
8
8
  var target = arg instanceof Event || arg === undefined ? document : arg,
@@ -11,13 +11,20 @@ You can create a Pull Request for your language, and get all the help you need t
11
11
  ### Check list for a new dictionary file:
12
12
 
13
13
  - [ ] Find the pluralization rule for your language
14
- - find the locale file you need in the [list of pluralizations](https://github.com/svenfuchs/rails-i18n/tree/master/rails/pluralization) and check the pluralization rule in it. For example for `en.rb` it is`::RailsI18n::Pluralization::OneOther.with_locale(:en)`. Note the rule part i.e. `OneOther`. In pagy that translates to the symbol `:one_other`.
14
+
15
+ - [ ] Find the locale file you need in the [list of pluralizations](https://github.com/svenfuchs/rails-i18n/tree/master/rails/pluralization) and check the pluralization rule in it. For example it is `::RailsI18n::Pluralization::OneOther.with_locale(:en)` for `en.rb`. Note the rule part i.e. `OneOther`. In pagy that translates to the symbol `:one_other`.
16
+
17
+ - [ ] If the pluralization rule of your language is not the `:one_other` default, confirm that the [p11n.rb](https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb) file already defines the pluralization rule of your dictionary file:
18
+
19
+ - [ ] If the rule is not defined, you can either: a) Add the rule as a new rule/lambda entry in the `p11n` variable hash and relative tests or b) Just create an issue requesting the addition to the rule/lambda entry and tests.
20
+
21
+ - [ ] Add your language to the `plurals` hash in the file.
15
22
 
16
23
  - [ ] add/edit the first line comment in the language rule in your dictionary file (e.g. `# :one_other pluralization ...`
17
24
 
18
25
  - [ ] The mandatory pluralized entry in the dictionary file is the `item_name`. Please, provide all the plurals needed by your language. E.g. if your language uses the `:east_slavic` you should provide the plurals for `one`, `few`, `many` and `other`, if it uses `:one_other`, you should provide `one` and `other` plurals. If it uses `:other` you should only provide a single value. Look into other dictionary files to get some example. Ask if in doubt.
19
26
 
20
- - [ ] The other entries in the dictionary file don't need any plural variant in most languages since the pluralization of the `item_name` in the sentence is enough. However, in some language, the whole sentence needs to be written in a different way for different plurals. In that case you should add the different plurals for the sentence and they will get triggered by the `count`.
27
+ - [ ] The other entries in the dictionary file don't need any plural variant in most languages since the pluralization of the `item_name` in the sentence is enough. However, in some language, a whole sentence might need to be written in different ways for different counts. In that case you should add the different plurals for the sentence and the `count` will trigger the one that applies.
21
28
 
22
29
  Feel free to ask for help in your Pull Request.
23
30
 
@@ -0,0 +1,22 @@
1
+ # :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
3
+ da:
4
+ pagy:
5
+
6
+ item_name:
7
+ one: "resultat"
8
+ other: "resultater"
9
+
10
+ nav:
11
+ prev: "‹ Forrige"
12
+ next: "Næste ›"
13
+ gap: "…"
14
+
15
+ info:
16
+ no_items: "Ingen %{item_name} fundet"
17
+ single_page: "Viser <b>%{count}</b> %{item_name}"
18
+ multiple_pages: "Viser %{item_name} <b>%{from}-%{to}</b> til <b>%{count}</b> totalt"
19
+
20
+ combo_nav_js: "Side %{page_input} of %{pages}"
21
+
22
+ items_selector_js: "Antal %{items_input} %{item_name} per side"
@@ -1,6 +1,6 @@
1
1
  # :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
2
 
3
- pt-br:
3
+ pt-BR:
4
4
  pagy:
5
5
 
6
6
  item_name:
@@ -0,0 +1,23 @@
1
+ # :one_two_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
3
+ sv-SE:
4
+ pagy:
5
+
6
+ item_name:
7
+ one: "resultat"
8
+ two: "resultat"
9
+ other: "resultat"
10
+
11
+ nav:
12
+ prev: "&lsaquo;&nbsp;Föregående"
13
+ next: "Nästa&nbsp;&rsaquo;"
14
+ gap: "&hellip;"
15
+
16
+ info:
17
+ no_items: "Inga %{item_name} hittade"
18
+ single_page: "Visar <b>%{count}</b> %{item_name}"
19
+ multiple_pages: "Visar %{item_name} <b>%{from}-%{to}</b> av <b>%{count}</b> totalt"
20
+
21
+ combo_nav_js: "Sida %{page_input} av %{pages}"
22
+
23
+ items_selector_js: "Visa %{items_input} %{item_name} per sida"
@@ -1,6 +1,6 @@
1
1
  # :one_two_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
2
 
3
- se:
3
+ sv:
4
4
  pagy:
5
5
 
6
6
  item_name:
@@ -4,15 +4,22 @@
4
4
 
5
5
  # this file returns the I18n hash used as default alternative to the i18n gem
6
6
 
7
- Hash.new{|h,_| h.first[1]}.tap do |i18n| # first loaded locale used as default
8
- i18n.define_singleton_method(:load) do |*args|
7
+ Pagy::DEPRECATED_LOCALES = {'pt-br' =>'pt-BR', 'se' => 'sv-SE'}
8
+
9
+ Hash.new{|h,_| h.first[1]}.tap do |i18n_hash| # first loaded locale used as default
10
+ i18n_hash.define_singleton_method(:load) do |*load_args|
9
11
  # eval: we don't need to keep the loader proc in memory
10
- eval(Pagy.root.join('locales', 'utils', 'loader.rb').read).call(i18n, *args) #rubocop:disable Security/Eval
12
+ eval(Pagy.root.join('locales', 'utils', 'loader.rb').read).call(i18n_hash, *load_args) #rubocop:disable Security/Eval
11
13
  end
12
- i18n.define_singleton_method(:t) do |locale, path, vars={}|
14
+ i18n_hash.define_singleton_method(:t) do |locale, path, vars={}|
15
+ if Pagy::DEPRECATED_LOCALES.key?(locale)
16
+ new_locale = Pagy::DEPRECATED_LOCALES[locale]
17
+ $stderr.puts("WARNING: the Pagy locale '#{locale}' is deprecated; use '#{new_locale}' instead")
18
+ locale = new_locale
19
+ end
13
20
  data, pluralize = self[locale]
14
21
  translate = data[path] || vars[:count] && data[path+=".#{pluralize.call(vars[:count])}"] or return %([translation missing: "#{path}"])
15
22
  translate.call(vars)
16
23
  end
17
- i18n.load(locale: 'en')
24
+ i18n_hash.load(locale: 'en')
18
25
  end
@@ -20,6 +20,11 @@ flatten = lambda do |hash, key=''|
20
20
  lambda do |i18n, *args|
21
21
  i18n.clear
22
22
  args.each do |arg|
23
+ if Pagy::DEPRECATED_LOCALES.key?(arg[:locale])
24
+ new_locale = Pagy::DEPRECATED_LOCALES[arg[:locale]]
25
+ $stderr.puts("WARNING: the Pagy locale '#{arg[:locale]}' is deprecated; use '#{new_locale}' instead")
26
+ arg[:locale] = new_locale
27
+ end
23
28
  arg[:filepath] ||= Pagy.root.join('locales', "#{arg[:locale]}.yml")
24
29
  arg[:pluralize] ||= plurals[arg[:locale]]
25
30
  hash = YAML.load(File.read(arg[:filepath], encoding: 'UTF-8')) #rubocop:disable Security/YAMLLoad
@@ -60,14 +60,15 @@ p11n = {
60
60
  # The default pluralization for locales not explicitly listed here
61
61
  # is the :one_other pluralization proc (used for English)
62
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['ko'] = p11n[:other]
67
- hash['pl'] = p11n[:polish]
68
- hash['ru'] = p11n[:east_slavic]
69
- hash['se'] = p11n[:one_two_other]
70
- hash['tr'] = p11n[:other]
63
+ hash['id'] = p11n[:other]
64
+ hash['fr'] = p11n[:one_upto_two_other]
65
+ hash['ja'] = p11n[:other]
66
+ hash['ko'] = p11n[:other]
67
+ hash['pl'] = p11n[:polish]
68
+ hash['ru'] = p11n[:east_slavic]
69
+ hash['sv'] = p11n[:one_two_other]
70
+ hash['sv-SE'] = p11n[:one_two_other]
71
+ hash['tr'] = p11n[:other]
71
72
  hash['zh-CN'] = p11n[:other]
72
73
  hash['zh-HK'] = p11n[:other]
73
74
  hash['zh-TW'] = p11n[:other]
@@ -4,7 +4,7 @@
4
4
 
5
5
  require 'pathname'
6
6
 
7
- class Pagy ; VERSION = '3.7.0'
7
+ class Pagy ; VERSION = '3.7.5'
8
8
 
9
9
  # Root pathname to get the path of Pagy files like templates or dictionaries
10
10
  def self.root; @root ||= Pathname.new(__FILE__).dirname.freeze end
@@ -23,7 +23,7 @@ class Pagy
23
23
  else
24
24
  # COUNT(*) OVER ()
25
25
  sql = Arel.star.count.over(Arel::Nodes::Grouping.new([]))
26
- collection.unscope(:order).limit(1).pluck(sql).first
26
+ collection.unscope(:order).limit(1).pluck(sql).first.to_i
27
27
  end
28
28
  end
29
29
 
@@ -21,7 +21,7 @@ class Pagy
21
21
  end
22
22
  html << (p_next ? %(<li class="page-item next">#{link.call p_next, pagy_t('pagy.nav.next'), 'aria-label="next"'}</li>)
23
23
  : %(<li class="page-item next disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.next')}</a></li>))
24
- %(<nav class="pagy-bootstrap-nav pagination" role="navigation" aria-label="pager"><ul class="pagination">#{html}</ul></nav>)
24
+ %(<nav class="pagy-bootstrap-nav" role="navigation" aria-label="pager"><ul class="pagination">#{html}</ul></nav>)
25
25
  end
26
26
 
27
27
  # Javascript pagination for bootstrap: it returns a nav and a JSON tag used by the Pagy.nav javascript
@@ -34,7 +34,7 @@ class Pagy
34
34
  'gap' => %(<li class="page-item gap disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.gap')}</a></li>),
35
35
  'after' => p_next ? %(<li class="page-item next">#{link.call p_next, pagy_t('pagy.nav.next'), 'aria-label="next"'}</li></ul>)
36
36
  : %(<li class="page-item next disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.next')}</a></li></ul>) }
37
- %(<nav id="#{id}" class="pagy-bootstrap-nav-js pagination" role="navigation" aria-label="pager"></nav>#{pagy_json_tag(:nav, id, tags, pagy.sequels, defined?(TRIM) && pagy.vars[:page_param])})
37
+ %(<nav id="#{id}" class="pagy-bootstrap-nav-js" role="navigation" aria-label="pager"></nav>#{pagy_json_tag(:nav, id, tags, pagy.sequels, defined?(TRIM) && pagy.vars[:page_param])})
38
38
  end
39
39
 
40
40
  # Javascript combo pagination for bootstrap: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -26,11 +26,11 @@ class Pagy
26
26
  url_str = pagy_url_for(PAGE_PLACEHOLDER, pagy, :url)
27
27
  hash = { 'Link' => Hash[rels.map{|rel, n|[rel, url_str.sub(PAGE_PLACEHOLDER, n.to_s)] if n}.compact] }
28
28
  headers = pagy.vars[:headers]
29
- hash[headers[:page]] = pagy.page if headers[:page]
30
- hash[headers[:items]] = pagy.vars[:items] if headers[:items]
29
+ hash[headers[:page]] = pagy.page.to_s if headers[:page]
30
+ hash[headers[:items]] = pagy.vars[:items].to_s if headers[:items]
31
31
  unless countless
32
- hash[headers[:pages]] = pagy.pages if headers[:pages]
33
- hash[headers[:count]] = pagy.count if headers[:count]
32
+ hash[headers[:pages]] = pagy.pages.to_s if headers[:pages]
33
+ hash[headers[:count]] = pagy.count.to_s if headers[:count]
34
34
  end
35
35
  hash
36
36
  end
@@ -6,7 +6,7 @@
6
6
  Usage: link.call( page_number [, text [, extra_attributes_string ]])
7
7
  -%>
8
8
  <% link = pagy_link_proc(pagy, 'class="page-link"') -%>
9
- <%# -%><nav aria-label="pager" class="pagy-bootstrap-nav pagination" role="navigation">
9
+ <%# -%><nav aria-label="pager" class="pagy-bootstrap-nav" role="navigation">
10
10
  <%# -%> <ul class="pagination">
11
11
  <% if pagy.prev -%> <li class="page-item prev"><%== link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"') %></li>
12
12
  <% else -%> <li class="page-item prev disabled"><a href="#" class="page-link"><%== pagy_t('pagy.nav.prev') %></a></li>
@@ -6,7 +6,7 @@
6
6
 
7
7
  - link = pagy_link_proc(pagy, 'class="page-link"')
8
8
 
9
- %nav.pagy-bootstrap-nav.pagination{"aria-label" => "pager", :role => "navigation"}
9
+ %nav.pagy-bootstrap-nav{"aria-label" => "pager", :role => "navigation"}
10
10
 
11
11
  %ul.pagination
12
12
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  - link = pagy_link_proc(pagy, 'class="page-link"')
8
8
 
9
- nav.pagy-bootstrap-nav.pagination role="navigation" aria-label="pager"
9
+ nav.pagy-bootstrap-nav role="navigation" aria-label="pager"
10
10
 
11
11
  ul.pagination
12
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagy
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.0
4
+ version: 3.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domizio Demichelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-06 00:00:00.000000000 Z
11
+ date: 2020-03-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Agnostic pagination in plain ruby: it works with any framework, ORM
14
14
  and DB type, with all kinds of collections, even pre-paginated, scopes, Arrays,
@@ -25,6 +25,7 @@ files:
25
25
  - lib/locales/README.md
26
26
  - lib/locales/bg.yml
27
27
  - lib/locales/ca.yml
28
+ - lib/locales/da.yml
28
29
  - lib/locales/de.yml
29
30
  - lib/locales/en.yml
30
31
  - lib/locales/es.yml
@@ -36,9 +37,10 @@ files:
36
37
  - lib/locales/nb.yml
37
38
  - lib/locales/nl.yml
38
39
  - lib/locales/pl.yml
39
- - lib/locales/pt-br.yml
40
+ - lib/locales/pt-BR.yml
40
41
  - lib/locales/ru.yml
41
- - lib/locales/se.yml
42
+ - lib/locales/sv-SE.yml
43
+ - lib/locales/sv.yml
42
44
  - lib/locales/tr.yml
43
45
  - lib/locales/utils/i18n.rb
44
46
  - lib/locales/utils/loader.rb