mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
45a857c951
refs fd91b593a5
- fixed incorrect call `pluralize(undefined, {withoutCount: true})` when number is undefined - `pluralize()` expects only one argument when no number is provided
- fixed destructuring in ghPluralize
- fixed linting error for undefined method after removal of `formatNumber` import
- fixed typo of import path in members controller
27 lines
846 B
JavaScript
27 lines
846 B
JavaScript
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, {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));
|
|
} 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, {withoutCount});
|
|
});
|