pagy 2.1.4 → 2.1.5
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.
- checksums.yaml +4 -4
- data/lib/config/pagy.rb +1 -1
- data/lib/locales/README.md +2 -2
- data/lib/locales/utils/loader.rb +7 -0
- data/lib/locales/{zh-cn.yml → zh-CN.yml} +1 -1
- data/lib/locales/{zh-hk.yml → zh-HK.yml} +2 -2
- data/lib/locales/zh-TW.yml +20 -0
- data/lib/pagy/extras/items.rb +4 -3
- data/lib/pagy/frontend.rb +2 -2
- data/lib/pagy.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b070d610f896a8b61e0f100c733e83d8eed0bfce6976ff24ed6e533f329c1ad2
|
4
|
+
data.tar.gz: 6c3654d072aea0dede29f6bf15069cc82ee3d6869ef812db6b78b0dda401013d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4172ff22491bc6506fe9041e71ef6e7abf92c3bee1dbf17f7f067e7a25fd9fa0124f3e5c54dbf30807f2d3df9b49fc432d8683cc8fde0d8434aa4c1686823a6
|
7
|
+
data.tar.gz: 87f78b815480fa7bd1392b4b2991d4af65783acf55ada2dea2724546a1b7c2e0e046e0c5ea838b6c200c8a655d3850f1db9360ae7ee514419e667980759d61f4
|
data/lib/config/pagy.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
# Pagy initializer file (
|
4
|
+
# Pagy initializer file (2.1.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
|
|
data/lib/locales/README.md
CHANGED
@@ -6,10 +6,10 @@ If you are using pagy with some language missing from the dictionary files, plea
|
|
6
6
|
|
7
7
|
The `pagy.info.single_page`, `pagy.info.item_name` and `pagy.items` keys of the yaml file are pluralized according to the plural rules of the language.
|
8
8
|
|
9
|
-
If you are going to submit a dictionary, please check wether the pluralization type of your language exists in the [
|
9
|
+
If you are going to submit a dictionary, please check wether the pluralization type of your language exists in the [lib/locales/utils/p11n.rb](utils/p11n.rb) file. If it is missing, please, report it. Thanks.
|
10
10
|
|
11
11
|
### Useful Links
|
12
12
|
|
13
13
|
* [Pagy I18n Documentation](https://ddnexus.github.io/pagy/api/frontend#i18n)
|
14
|
-
* [
|
14
|
+
* [I18n Extra](https://ddnexus.github.io/pagy/extras/i18n)
|
15
15
|
|
data/lib/locales/utils/loader.rb
CHANGED
@@ -16,10 +16,17 @@ 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
|
+
|
19
21
|
# loader proc
|
20
22
|
lambda do |i18n, *args|
|
21
23
|
i18n.clear
|
22
24
|
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
|
23
30
|
arg[:filepath] ||= Pagy.root.join('locales', "#{arg[:locale]}.yml")
|
24
31
|
arg[:pluralize] ||= p11n[arg[:locale]]
|
25
32
|
hash = YAML.load(File.read(arg[:filepath], encoding: 'UTF-8')) #rubocop:disable Security/YAMLLoad
|
@@ -0,0 +1,20 @@
|
|
1
|
+
zh-TW:
|
2
|
+
pagy:
|
3
|
+
nav:
|
4
|
+
prev: "‹ 上一頁"
|
5
|
+
next: "下一頁 ›"
|
6
|
+
gap: "…"
|
7
|
+
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} 項"
|
data/lib/pagy/extras/items.rb
CHANGED
@@ -38,9 +38,10 @@ class Pagy
|
|
38
38
|
module Frontend
|
39
39
|
|
40
40
|
alias_method :pagy_url_for_without_items, :pagy_url_for
|
41
|
-
def pagy_url_for_with_items(page, pagy)
|
42
|
-
p_vars = pagy.vars; params = request.GET.merge(p_vars[:
|
43
|
-
|
41
|
+
def pagy_url_for_with_items(page, pagy, url=false)
|
42
|
+
p_vars = pagy.vars; params = request.GET.merge(p_vars[:params]); params[p_vars[:page_param].to_s] = page
|
43
|
+
params[p_vars[:items_param].to_s] = p_vars[:items]
|
44
|
+
"#{request.base_url if url}#{request.path}?#{Rack::Utils.build_nested_query(pagy_get_params(params))}#{p_vars[:anchor]}"
|
44
45
|
end
|
45
46
|
alias_method :pagy_url_for, :pagy_url_for_with_items
|
46
47
|
|
data/lib/pagy/frontend.rb
CHANGED
@@ -12,9 +12,9 @@ class Pagy
|
|
12
12
|
|
13
13
|
module Helpers
|
14
14
|
# This works with all Rack-based frameworks (Sinatra, Padrino, Rails, ...)
|
15
|
-
def pagy_url_for(page, pagy,
|
15
|
+
def pagy_url_for(page, pagy, url=false)
|
16
16
|
p_vars = pagy.vars; params = request.GET.merge(p_vars[:params]); params[p_vars[:page_param].to_s] = page
|
17
|
-
"#{request.
|
17
|
+
"#{request.base_url if url}#{request.path}?#{Rack::Utils.build_nested_query(pagy_get_params(params))}#{p_vars[:anchor]}"
|
18
18
|
end
|
19
19
|
|
20
20
|
# Sub-method called only by #pagy_url_for: here for easy customization of params by overriding
|
data/lib/pagy.rb
CHANGED
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: 2.1.
|
4
|
+
version: 2.1.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-03-
|
11
|
+
date: 2019-03-29 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,
|
@@ -37,8 +37,9 @@ files:
|
|
37
37
|
- lib/locales/utils/i18n.rb
|
38
38
|
- lib/locales/utils/loader.rb
|
39
39
|
- lib/locales/utils/p11n.rb
|
40
|
-
- lib/locales/zh-
|
41
|
-
- lib/locales/zh-
|
40
|
+
- lib/locales/zh-CN.yml
|
41
|
+
- lib/locales/zh-HK.yml
|
42
|
+
- lib/locales/zh-TW.yml
|
42
43
|
- lib/pagy.rb
|
43
44
|
- lib/pagy/backend.rb
|
44
45
|
- lib/pagy/countless.rb
|