This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added number formatting to all pluralized counts
closes TryGhost/Ghost#12110 - adds `{{gh-pluralize}}` helper that wraps the `{{pluralize}}` helper from `ember-inflector` but formats the number using our `{{format-number}}` helper - updates all uses of `{{pluralize}}` to `{{gh-pluralize}}`
- Loading branch information
1 parent
fe1394e
commit 754f848
Showing
11 changed files
with
46 additions
and
22 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
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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {formatNumber} from './format-number'; | ||
import {helper} from '@ember/component/helper'; | ||
import {isBlank} from '@ember/utils'; | ||
import {pluralize} from 'ember-inflector'; | ||
|
||
export function ghPluralize(number, word, {'without-count': withoutCount} = {}) { | ||
let output = []; | ||
|
||
if (!isBlank(number) && withoutCount !== true) { | ||
output.push(formatNumber(number)); | ||
} | ||
|
||
// default {{pluralize}} allows for {{pluralize "word"}} with no number | ||
if (isBlank(number)) { | ||
output.push(pluralize(word, {withoutCount: true})); | ||
} else { | ||
output.push(pluralize(number, word, {withoutCount: true})); | ||
} | ||
|
||
return output.join(' '); | ||
} | ||
|
||
// like {{pluralize}} but formats the number according to current locale | ||
export default helper(function ([number, word], {'without-count': withoutCount} = {}) { | ||
return ghPluralize(number, word, {'without-count': withoutCount}); | ||
}); |
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