pagy 0.8.2 → 0.8.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c540ef29200104732d3123cddfd7490cbfdee6084a0da2e6d7608806a131d35
4
- data.tar.gz: 87103c5d8d1b3a6fd37149f6c333cd674d1f140af02a923415d57c7023c6bb7d
3
+ metadata.gz: 4d15c4b37bce77cfd5a60512d46d728a5ea33dcd8f9f32cf31de6307f9d5b5d8
4
+ data.tar.gz: 501a0e654d0874766cafaa5c12b79e3dc5b643cdb3150a99e6bd2d4cf45ce159
5
5
  SHA512:
6
- metadata.gz: 3128af4fcb7b0e4196c324e2ba7565784c9e90a30911814913a2116c833dcc505c35f4605f82f7010d7f5e433209391f45bc29c09fbb47c80815a30db67cefad
7
- data.tar.gz: 35cd02a10243dc4f4491c812b559f83e6ebdc2e74173221f19a295e7086063634be219256bed6799691d066d54fa6407de7be96cdfb0ffa54fda1890e3cd67c4
6
+ metadata.gz: eb2aff48d06edc8e6aa08c118f55b01cc9e70beafc23fbb99a9af5bcb45bd63d0abc90a766d941abfeafa7ed0dbdd592f2471c383b8082bda02f328a679c3ad6
7
+ data.tar.gz: c48a529c198243dbcb66c20f7b5047dd12bdec53a22d72954b61967dbbb205bc5037ab6e84426f12be2ca3f5d43d4b61380d99a16f64ace8116a08c79ee8d489
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'pathname'
4
4
 
5
- class Pagy ; VERSION = '0.8.2'
5
+ class Pagy ; VERSION = '0.8.3'
6
6
 
7
7
  class OutOfRangeError < StandardError; end
8
8
 
@@ -12,9 +12,6 @@ class Pagy ; VERSION = '0.8.2'
12
12
  # default core vars
13
13
  VARS = { page:1, items:20, outset:0, size:[1,4,4,1], page_param: :page, params: {} }
14
14
 
15
- # default I18n vars
16
- zero_one = [:zero, :one] ; I18N = { file: Pagy.root.join('locales', 'pagy.yml').to_s, plurals: -> (c) {(zero_one[c] || :other).to_s.freeze} }
17
-
18
15
  attr_reader :count, :page, :items, :vars, :pages, :last, :offset, :from, :to, :prev, :next
19
16
 
20
17
  # merge and validate the options, do some simple aritmetic and set the instance variables
@@ -46,10 +46,10 @@
46
46
  # Pagy::VARS[:breakpoints] = { 0 => [1,2,2,1], 350 => [2,3,3,2], 550 => [3,4,4,3] } # example of width/size pairs
47
47
 
48
48
 
49
- # I18n Variables
50
- # See https://ddnexus.github.io/pagy/api/frontend#pagy_tpath-vars
51
- # Pagy::I18N[:file] = Pagy.root.join('locales', 'pagy.yml').to_s # default
52
- # Pagy::I18N[:plurals] = -> (c) {([:zero, :one][c] || :other).to_s # default
49
+ # Pagy::Frontend::I18N Constant
50
+ # See https://ddnexus.github.io/pagy/api/frontend#i18n
51
+ # Pagy::Frontend::I18N[:plurals] = -> (c) {([:zero, :one][c] || :other).to_s # default
52
+ # Pagy::Frontend::I18N.load_file('path/to/dictionary.yml') # load a custom file
53
53
 
54
54
 
55
55
  # Rails: extras assets path required by compact or responsive extras
@@ -57,14 +57,16 @@ class Pagy
57
57
  end
58
58
 
59
59
 
60
- # load data from the first locale in the file
61
- I18N_DATA = YAML.load_file(I18N[:file]).first[1].freeze
60
+ # Pagy::Frontend::I18N constant
61
+ zero_one = [:zero, :one]; I18N = { plurals: -> (c) {(zero_one[c] || :other).to_s.freeze}, data: {}}
62
+ def I18N.load_file(file) I18N[:data].replace(YAML.load_file(file).first[1]) end
63
+ I18N[:data] = I18N.load_file(Pagy.root.join('locales', 'pagy.yml'))
62
64
 
63
65
  # Similar to I18n.t for interpolation and pluralization but without translation
64
66
  # Use only for single-language apps: it is specialized for pagy and 5x faster than I18n.t
65
67
  # See also https://ddnexus.github.io/pagy/extras/i18n to use the standard I18n gem instead
66
68
  def pagy_t(path, vars={})
67
- value = I18N_DATA.dig(*path.to_s.split('.'.freeze)) or return %(translation missing: "#{path}")
69
+ value = I18N[:data].dig(*path.to_s.split('.'.freeze)) or return %(translation missing: "#{path}")
68
70
  if value.is_a?(Hash)
69
71
  vars.key?(:count) or return value
70
72
  plural = I18N[:plurals].call(vars[:count])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domizio Demichelis