l10n: localizable upload progress messages
PATCH v6 1/1 l10n: localizable upload progress messages
Currenly the data rate in throughput_string(...) method is output by simple strbuf_humanise_bytes(...) call and '/s' append. But for proper translation of such string the translator needs full context.
Add strbuf_humanise_rate(...) method to properly print out localizable version of data rate ('3.5 MiB/s' etc) with full context.
Strings with the units in strbuf_humanise_bytes(...) are marked for translation.
--- progress.c | 3 +-- strbuf.c | 42 +++++++++++++++++++++++++++++++++++++----- strbuf.h | 6 ++++++ 3 files changed, 44 insertions(+), 7 deletions(-)
progress.c +1 -2
@@ -150,8 +150,7 @@ static void throughput_string(struct strbuf *buf, uint64_t total,strbuf_addstr (buf,", " );strbuf_humanise_bytes (buf, total);strbuf_addstr (buf," | " ); -strbuf_humanise_bytes (buf, rate *1024 ); -strbuf_addstr (buf,"/s" ); +strbuf_humanise_rate (buf, rate *1024 ); }void display_throughput (struct progress *progress,uint64_t total)
strbuf.c +37 -5
62 lines not on this page · raw message
strbuf.h +6 -0
@@ -372,6 +372,12 @@ void strbuf_addbuf_percentquote(struct strbuf *dst, const struct strbuf *src);*/ void strbuf_humanise_bytes (struct strbuf *buf,off_t bytes); +/** +* Append the given byte rate as a human-readable string (i.e. 12.23 KiB/s, +* 3.50 MiB/s). +*/ +void strbuf_humanise_rate (struct strbuf *buf,off_t bytes); +/** * Add a formatted string to the buffer. */
Signature · 1 line
2.22.0
Quoted 4 lines · Dimitriy Ryazantcev
strbuf.c +2
-1-void strbuf_humanise_bytes (struct strbuf *buf,off_t bytes) +static void strbuf_humanise (struct strbuf *buf,off_t bytes, +int humanise_rate) {
strbuf.c void strbuf_addstr_urlencode(struct strbuf *sb, const char *s, · line 825
Quoted 10 lines
strbuf.c +6
-1if (bytes >1 <<30 ) { -strbuf_addf (buf,"%u.%2.2u GiB" , +strbuf_addf (buf, + humanise_rate ==0 ? +/* TRANSLATORS: IEC 80000-13:2008 gibibyte */ +_ ("%u.%2.2u GiB" ) : +/* TRANSLATORS: IEC 80000-13:2008 gibibyte/second */ +_ ("%u.%2.2u GiB/s" ), (unsigned )(bytes >>30 ), (unsigned )(bytes & ((1 <<30 ) -1 )) /10737419 );
Thanks. I guess that the previous attempt to make it more table driven was probably a bit overkill, and because it did not quite work well for Q_(), this would probably be the "good enough, let's move on" optimal solution ;-)
Will queue.