Skip to content

Commit d3c2239

Browse files
authored
pretty-bytes: Use locale-aware formatting via intl service (#12030)
This fixes the formatting mismatch between the SLoC and crate size values, that were using different rules right next to each other.
1 parent 391111f commit d3c2239

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

app/helpers/pretty-bytes.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
import { helper } from '@ember/component/helper';
1+
import Helper from '@ember/component/helper';
2+
import { service } from '@ember/service';
23

34
import prettyBytes from 'pretty-bytes';
45

56
/**
67
* See https://github.com/rust-lang/crates.io/discussions/7177
78
*/
8-
export default helper(([bytes], options) =>
9-
prettyBytes(bytes, {
10-
binary: true,
11-
...options,
12-
}),
13-
);
9+
export default class PrettyBytesHelper extends Helper {
10+
@service intl;
11+
12+
compute([bytes], options) {
13+
return prettyBytes(bytes, {
14+
binary: true,
15+
locale: this.intl.locale ?? true,
16+
...options,
17+
});
18+
}
19+
}

0 commit comments

Comments
 (0)