-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup of i81n plurals in code and docs
- Loading branch information
Showing
2 changed files
with
15 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
# This file adds support for multiple built-in plualization types. | ||
# It defines the pluralization procs and gets eval(ed) at I18N.load time | ||
# It defines the pluralization procs and gets eval(ed) at I18N.load time. | ||
# frozen_string_literal: true | ||
|
||
# utility variables | ||
zero_one = ['zero', 'one'] | ||
|
||
# Rules | ||
# A rule is a proc returning a plural type string based on the passed count | ||
# Each plural rule may apply to many language/rule pairs below | ||
rules = { | ||
# Plurals | ||
# A plural proc returns a plural type string based on the passed count | ||
# Each plural proc may apply to one or more languages below | ||
plurals = { | ||
zero_one_other: -> (count) {zero_one[count] || 'other'} | ||
} | ||
|
||
# Plurals (language/rule pairs) | ||
# The default rule for missing languages is the :zero_one_other rule (used for English) | ||
plurals = Hash.new(rules[:zero_one_other]) | ||
# Languages (language/plural pairs) | ||
# Contain all the entries for all the languages defined in the pagy.yml dictionary | ||
# The default plural for missing languages is the :zero_one_other plural (used for English) | ||
Hash.new(plurals[:zero_one_other]).tap do |languages| | ||
languages['en'] = plurals[:zero_one_other] | ||
|
||
# Entries for all the languages defined in the pagy.yml dictionary | ||
plurals['en'] = rules[:zero_one_other] | ||
# PR for other languages and plurals are very welcome. Thanks! | ||
|
||
# PR for other languages are very welcome. Thanks! | ||
|
||
# Return plurals | ||
plurals | ||
end |