Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Nov 11, 2023
2 parents dea652a + 8dbc008 commit 98f163b
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
GEM=pagy
VERSION=6.1.0
VERSION=6.2.0
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ None

<hr>

## Version 6.2.0

- Add Belarusian locale (#567)
- Reordered RubyMine tasks (fix #541)

## Version 6.1.0

- Add Vietnamese locale (#550)
Expand Down
2 changes: 1 addition & 1 deletion lib/config/pagy.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Pagy initializer file (6.1.0)
# Pagy initializer file (6.2.0)
# Customize only what you really need and notice that the core Pagy works also without any of the following lines.
# Should you just cherry pick part of this file, please maintain the require-order of the extras

Expand Down
4 changes: 2 additions & 2 deletions lib/javascripts/pagy-dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/javascripts/pagy-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const Pagy = (() => {
const trim = (link, param) => link.replace(new RegExp(`(\\?|&amp;)${param}=1\\b(?!&amp;)|\\b${param}=1&amp;`), "");
// Public interface
return {
version: "6.1.0",
version: "6.2.0",
// Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
init(arg) {
const target = arg instanceof Element ? arg : document;
Expand Down
2 changes: 1 addition & 1 deletion lib/javascripts/pagy.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions lib/locales/be.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)

be:
pagy:

item_name:
one: "запіс"
few: "запісы"
many: "запісаў"
other: "запісаў"

nav:
prev: "&lsaquo;&nbsp;Назад"
next: "Наперад&nbsp;&rsaquo;"
gap: "&hellip;"

info:
no_items: "Пакуль %{item_name} няма"
single_page: "<b>%{count}</b> %{item_name}"
multiple_pages: "Усяго <b>%{count}</b> %{item_name}, паказаны з <b>%{from}</b> па <b>%{to}</b>"

combo_nav_js: "<label>Старонка %{page_input} з %{pages}</label>"

items_selector_js: "<label>Паказаць %{items_input} %{item_name} на старонцы</label>"
2 changes: 1 addition & 1 deletion lib/locales/cs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# :czech pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
# :west_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)

cs:
pagy:
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/sw.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# :one_other pluralization
# :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)

sw:
pagy:
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/vi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
# :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)

vi:
pagy:
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Core class
class Pagy
VERSION = '6.1.0'
VERSION = '6.2.0'

# Root pathname to get the path of Pagy files like templates or dictionaries
def self.root
Expand Down
1 change: 1 addition & 0 deletions lib/pagy/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ module P11n
# the :one_other RULE is the default for locales missing from this list
LOCALE = Hash.new(RULE[:one_other]).tap do |hash|
hash['ar'] = RULE[:arabic]
hash['be'] = RULE[:east_slavic]
hash['bs'] = RULE[:east_slavic]
hash['cs'] = RULE[:west_slavic]
hash['id'] = RULE[:other]
Expand Down
1 change: 1 addition & 0 deletions pagy.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ lib/javascripts/pagy-module.d.ts
lib/javascripts/pagy-module.js
lib/javascripts/pagy.js
lib/locales/ar.yml
lib/locales/be.yml
lib/locales/bg.yml
lib/locales/bs.yml
lib/locales/ca.yml
Expand Down
2 changes: 1 addition & 1 deletion quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ If you use Bundler, add the gem in the Gemfile, optionally avoiding the next maj

||| Gemfile
```ruby
gem 'pagy', '~> 6.1' # omit patch digit
gem 'pagy', '~> 6.2' # omit patch digit
```
|||

Expand Down
2 changes: 1 addition & 1 deletion retype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ url: https://ddnexus.github.io/pagy

branding:
title: Pagy
label: 6.1.0
label: 6.2.0
colors:
label:
text: "#FFFFFF"
Expand Down
2 changes: 1 addition & 1 deletion src/pagy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const Pagy = (() => {

// Public interface
return {
version: "6.1.0",
version: "6.2.0",

// Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
init(arg?:Element|never) {
Expand Down
49 changes: 49 additions & 0 deletions test/pagy/i18n_locales_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: true

require_relative '../test_helper'

describe 'pagy/locales' do
let(:rules) { Pagy::I18n::P11n::RULE.keys }
let(:counts) do
{
arabic: %w[zero one two few many other],
east_slavic: %w[one few many other],
one_other: %w[one other],
one_two_other: %w[one two other],
one_upto_two_other: %w[one other],
other: %w[other],
polish: %w[one few many other],
west_slavic: %w[one few other]
}
end

# locale files loop
Pagy.root.join('locales').each_child do |f|
next unless f.extname == '.yml'

message = "locale file #{f}"
locale = f.basename.to_s[0..-5]
comment = f.readlines.first.to_s.strip
rule = comment.to_s.split[1][1..-1].to_s.to_sym

it 'includes a comment with the pluralization rule and the i18n.rb reference' do
_(rules).must_include rule, message
_(comment).must_match 'https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb', message
end
it 'defines and matches the locale pluralization rule' do
_(Pagy::I18n::P11n::LOCALE[locale]).must_equal Pagy::I18n::P11n::RULE[rule], message
end
it 'pluralizes item_name according to the rule' do
hash = YAML.safe_load(f.read)
item_name = hash[locale]['pagy']['item_name']
case item_name
when String
_(rule).must_equal :other
when Hash
_(item_name.keys - counts[rule]).must_be_empty
else
raise StandardError, "item_name must be Hash or String"
end
end
end
end

0 comments on commit 98f163b

Please sign in to comment.