@@ -811,25 +811,57 @@ void strbuf_addstr_urlencode(struct strbuf *sb, const char *s,
811
811
strbuf_add_urlencode (sb , s , strlen (s ), reserved );
812
812
}
813
813
814
- void strbuf_humanise_bytes (struct strbuf * buf , off_t bytes )
814
+ static void strbuf_humanise (struct strbuf * buf , off_t bytes ,
815
+ int humanise_rate )
815
816
{
816
817
if (bytes > 1 << 30 ) {
817
- strbuf_addf (buf , "%u.%2.2u GiB" ,
818
+ strbuf_addf (buf ,
819
+ humanise_rate == 0 ?
820
+ /* TRANSLATORS: IEC 80000-13:2008 gibibyte */
821
+ _ ("%u.%2.2u GiB" ) :
822
+ /* TRANSLATORS: IEC 80000-13:2008 gibibyte/second */
823
+ _ ("%u.%2.2u GiB/s" ),
818
824
(unsigned )(bytes >> 30 ),
819
825
(unsigned )(bytes & ((1 << 30 ) - 1 )) / 10737419 );
820
826
} else if (bytes > 1 << 20 ) {
821
827
unsigned x = bytes + 5243 ; /* for rounding */
822
- strbuf_addf (buf , "%u.%2.2u MiB" ,
828
+ strbuf_addf (buf ,
829
+ humanise_rate == 0 ?
830
+ /* TRANSLATORS: IEC 80000-13:2008 mebibyte */
831
+ _ ("%u.%2.2u MiB" ) :
832
+ /* TRANSLATORS: IEC 80000-13:2008 mebibyte/second */
833
+ _ ("%u.%2.2u MiB/s" ),
823
834
x >> 20 , ((x & ((1 << 20 ) - 1 )) * 100 ) >> 20 );
824
835
} else if (bytes > 1 << 10 ) {
825
836
unsigned x = bytes + 5 ; /* for rounding */
826
- strbuf_addf (buf , "%u.%2.2u KiB" ,
837
+ strbuf_addf (buf ,
838
+ humanise_rate == 0 ?
839
+ /* TRANSLATORS: IEC 80000-13:2008 kibibyte */
840
+ _ ("%u.%2.2u KiB" ) :
841
+ /* TRANSLATORS: IEC 80000-13:2008 kibibyte/second */
842
+ _ ("%u.%2.2u KiB/s" ),
827
843
x >> 10 , ((x & ((1 << 10 ) - 1 )) * 100 ) >> 10 );
828
844
} else {
829
- strbuf_addf (buf , "%u bytes" , (unsigned )bytes );
845
+ strbuf_addf (buf ,
846
+ humanise_rate == 0 ?
847
+ /* TRANSLATORS: IEC 80000-13:2008 byte */
848
+ Q_ ("%u byte" , "%u bytes" , (unsigned )bytes ) :
849
+ /* TRANSLATORS: IEC 80000-13:2008 byte/second */
850
+ Q_ ("%u byte/s" , "%u bytes/s" , (unsigned )bytes ),
851
+ (unsigned )bytes );
830
852
}
831
853
}
832
854
855
+ void strbuf_humanise_bytes (struct strbuf * buf , off_t bytes )
856
+ {
857
+ strbuf_humanise (buf , bytes , 0 );
858
+ }
859
+
860
+ void strbuf_humanise_rate (struct strbuf * buf , off_t bytes )
861
+ {
862
+ strbuf_humanise (buf , bytes , 1 );
863
+ }
864
+
833
865
void strbuf_add_absolute_path (struct strbuf * sb , const char * path )
834
866
{
835
867
if (!* path )
0 commit comments