forked from ddnexus/pagy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring of I18N constant: added support for multiple static langu…
…ages and plural rules
- Loading branch information
Showing
7 changed files
with
70 additions
and
21 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 |
---|---|---|
|
@@ -22,3 +22,5 @@ en: | |
items: | ||
show: "Show" | ||
items: "items per page" | ||
|
||
# PR for other languages are very welcome. Thanks! |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This file adds support for multiple built-in plualiztion types. | ||
# 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 = { | ||
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]) | ||
|
||
# Entries for all the languages defined in the pagy.yml dictionary | ||
plurals['en'] = rules[:zero_one_other] | ||
|
||
# PR for other languages are very welcome. Thanks! | ||
|
||
# Return plurals | ||
plurals |
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
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