From patchwork Fri Jun 23 19:48:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emir SARI X-Patchwork-Id: 13290903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68B52EB64D7 for ; Fri, 23 Jun 2023 19:49:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231636AbjFWTtJ (ORCPT ); Fri, 23 Jun 2023 15:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjFWTtH (ORCPT ); Fri, 23 Jun 2023 15:49:07 -0400 Received: from pv50p00im-ztdg10011901.me.com (pv50p00im-ztdg10011901.me.com [17.58.6.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E0C92718 for ; Fri, 23 Jun 2023 12:49:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1687549746; bh=cp7eEuVIFeuLtpxzY52U09wJw7q9zna8NUSuKg0/qhU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=ijC+/c9LAP75k3QLSfNSZ01bFCdOlgEZwGuMpoXeffGKBy1+TxQOAfA627m6+JsA7 ks1dAWMMlFhzT7NOelPWBH3ohRLJh6Cw+vT+8fRTxlaN7adENot3j0rFjNzN9mXxHj a3EkwxE9WcRW94dQm4t3+KCP64/85VC04GM1O5QVo7cdTC6ctVr52/D2h4ZDa2901w c/imnsYy9odKxplaLxjANiP+9M8FbEtm85uFMC9tfKHf1KO/l9PFkfXemW9REdkxHT 2yN6YBa7reIohtRD0EvYTKtCtAHeudgEukFV4hk8usdO6g0Lxpujceo5tsiUnNuyJ5 PTZ4VQ65D0a0g== Received: from localhost.localdomain (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10011901.me.com (Postfix) with ESMTPSA id B43393A0236; Fri, 23 Jun 2023 19:49:04 +0000 (UTC) From: Emir SARI To: git@vger.kernel.org Cc: Emir SARI Subject: [PATCH v2] i18n: Enable percentage l10n for more strings Date: Fri, 23 Jun 2023 22:48:49 +0300 Message-ID: <20230623194856.3696-1-emir_sari@icloud.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: vPJmlqCZvV0QX4LtOU-o8hYlSlgqY4tG X-Proofpoint-GUID: vPJmlqCZvV0QX4LtOU-o8hYlSlgqY4tG X-Proofpoint-Virus-Version: =?utf-8?q?vendor=3Dfsecure_engine=3D1=2E1=2E170-?= =?utf-8?q?22c6f66c430a71ce266a39bfe25bc2903e8d5c8f=3A6=2E0=2E138=2C18=2E0?= =?utf-8?q?=2E572=2C17=2E11=2E64=2E514=2E0000000_definitions=3D2020-02-14=5F?= =?utf-8?q?11=3A2020-02-14=5F02=2C2020-02-14=5F11=2C2022-02-23=5F01_signatur?= =?utf-8?q?es=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 bulkscore=0 mlxlogscore=997 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2306230178 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This enables percentage localization in more progress views, and provides a more cohesive l10n environment among the translated messages. --- progress.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/progress.c b/progress.c index f695798aca..1f8d372284 100644 --- a/progress.c +++ b/progress.c @@ -124,10 +124,24 @@ static void display(struct progress *progress, uint64_t n, const char *done) progress->last_percent = percent; strbuf_reset(counters_sb); - strbuf_addf(counters_sb, - "%3u%% (%"PRIuMAX"/%"PRIuMAX")%s", percent, + + struct strbuf progress_sb = STRBUF_INIT; + strbuf_addf(&progress_sb, + _("%u%% (%"PRIuMAX"/%"PRIuMAX")%s"), percent, (uintmax_t)n, (uintmax_t)progress->total, tp); + struct strbuf progress_str = STRBUF_INIT; + strbuf_addstr(&progress_str, progress_sb.buf); + strbuf_release(&progress_sb); + + if (percent < 10) + strbuf_insert(&progress_str, 0, " ", 2); + else if (percent < 100) + strbuf_insert(&progress_str, 0, " ", 1); + + strbuf_addf(counters_sb, "%s", progress_str.buf); + strbuf_release(&progress_str); + show_update = 1; } } else if (progress_update) {