mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 06:03:39 +08:00
49d59089e4
- Changes all `app.trans` calls to `app.translator.trans` calls. - Changes existing keys to [three-tier namespace structure](https://github.com/flarum/english/pull/12). - Extracts additional strings for `lib:` namespace. - Extracts two previously missed strings for EditGroupModal.js.
21 lines
570 B
JavaScript
21 lines
570 B
JavaScript
/**
|
|
* The `abbreviateNumber` utility converts a number to a shorter localized form.
|
|
*
|
|
* @example
|
|
* abbreviateNumber(1234);
|
|
* // "1.2K"
|
|
*
|
|
* @param {Integer} number
|
|
* @return {String}
|
|
*/
|
|
export default function abbreviateNumber(number) {
|
|
// TODO: translation
|
|
if (number >= 1000000) {
|
|
return Math.floor(number / 1000000) + app.translator.trans('core.lib.number_suffix.mega_text');
|
|
} else if (number >= 1000) {
|
|
return Math.floor(number / 1000) + app.translator.trans('core.lib.number_suffix.kilo_text');
|
|
} else {
|
|
return number.toString();
|
|
}
|
|
}
|