Hello, The percentage formatting among different locales can vary. For instance, Turkish uses %100 style formatting, whereas French uses 100 %. There are also other languages that use varying styles like using non-break spaces between the sign and the number and else. However, the percentage values displayed in apt only uses a fixed format, such as 100%. Please allow localising the percentage values. This will allow a more complete l10n experience, where the translated text matches the other locale formatting.
Hi, Can you give example(s) of the messages you refer to? On the top of my head I can only think of the bottom line while packages are installed, which reads (in English) "Progress: [ 42%] …" (on a green background). That message, including the percentage value is already translatable. A few translations have this line translated so far, Turkish among them which reads as of today: msgid "Progress: [%3li%%]" msgstr "Durum: [%3li%%]" French has it translated, too, but also hasn't touched the %3li%% part. So you might want to talk it up with the respektive language teams and last active translation maintainers (see the top of the po files in the source for the contact information). My own knowledge in either language (as well as many others) is non-existent. The other place I can think of is the progress indication shown as the bottom line while files are downloaded (e.g. indexes in 'update' or debs pretty much everywhere else). These "%.0f%%" are indeed not marked for translation, but I am not sure if it is a good idea as they come without any explanation and show info pretty densely more or less to the benefit of "something is happening" rather than "here are all the details you could possibly ask for so you can refer back to this great knowledge forever". Never the less I suppose we can put in the work to make them translatable (currently the formatting is hardcoded in a few places, that would need to be fixed). On the other hand, it seems pointless labour to make the string translatable if a similar translatable string isn't used in this way, so as a compromise I suggest a deal: I will see to implement it if a language team/translator asks for it here. (translation updates are allowed in freeze, the other part would likely need to wait for trixie through as that likely doesn't sell as release- critical code change) Best regards David Kalnischkies
Hello, Yes, Progress message is one of them, and also there are percentages on each individual package and/or repository update string. I have contacted Mr. Dirik, as he’s the current translator and CC’d him here. He said he is going to fix the Progress string, your help in i18n’sing other currently non-i18n percentages would be really appreciated and make it more coherent among all apt. Thank you for your help. Best regards, Emir
Hi, Please see the attached translation update for apt 2.6.0 Best regards
From 091f902682c7cb7b3a4c5340df3fb0bbcd910aaa Mon Sep 17 00:00:00 2001
From: Emir SARI <emir_sari@icloud.com>
Date: Fri, 5 May 2023 18:58:03 +0300
Subject: [PATCH] Apply i18n to percentage display
Languages like Turkish and French (and some other more), use a
custom percentage format, other than the standard 100%. Allowing
i18n to these values, make the apt interface a lot coherent with
the rest of the output, since they mostly appear next to translated
strings.
This commit also fixes the issue of "Progress: [100%]" to have
extra blank characters when the percentage sign is prepended to the
number; e.g. "Progress: [ %1]". Previously, it output [% 1] due
to the absolute placeholder format.
---
apt-pkg/install-progress.cc | 10 +++++++++-
apt-private/acqprogress.cc | 9 ++++++---
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc
index c7f7573..e7c5e55 100644
--- a/apt-pkg/install-progress.cc
+++ b/apt-pkg/install-progress.cc
@@ -56,7 +56,15 @@ bool PackageManager::StatusChanged(std::string /*PackageName*/,
{
int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1);
percentage = StepsDone/(double)TotalSteps * 100.0;
- strprintf(progress_str, _("Progress: [%3li%%]"), std::lround(percentage));
+ // Progress percentage, localize according to your locale settings
+ progress_str = strprintf(_("Progress: [%d%%]"), std::lround(percentage));
+
+ if (percentage < 10)
+ progress_str.insert(11, " ");
+ else if (percentage < 100) {
+ progress_str.insert(11, " ");
+
+ std::printf("%s", progress_str.c_str());
if(percentage < (last_reported_progress + reporting_steps))
return false;
diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc
index fa7edfc..bbb15ae 100644
--- a/apt-private/acqprogress.cc
+++ b/apt-private/acqprogress.cc
@@ -232,9 +232,11 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
if (I->CurrentItem->TotalSize > 0 && I->CurrentItem->Owner->Complete == false)
{
if (Mode == Short)
- ioprintf(S, " %.0f%%", (I->CurrentItem->CurrentSize*100.0)/I->CurrentItem->TotalSize);
+ // Progress percentage, localize according to your locale settings
+ ioprintf(S, _(" %.0f%%"), (I->CurrentItem->CurrentSize*100.0)/I->CurrentItem->TotalSize);
else
- ioprintf(S, "/%sB %.0f%%", SizeToStr(I->CurrentItem->TotalSize).c_str(),
+ // Progress percentage, localize according to your locale settings
+ ioprintf(S, _("/%sB %.0f%%"), SizeToStr(I->CurrentItem->TotalSize).c_str(),
(I->CurrentItem->CurrentSize*100.0)/I->CurrentItem->TotalSize);
}
S << "]";
@@ -249,7 +251,8 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
// Put in the percent done
{
std::stringstream S;
- ioprintf(S, "%.0f%%", Percent);
+ // Progress percentage, localize according to your locale settings
+ ioprintf(S, _("%.0f%%"), Percent);
S << Line;
Line = S.str();
S.clear();
Hi, (sry, I seem to be either chronically out of time currently) Thanks – but could you perhaps create a merge request on salsa [0] rather than attaching patches to bug reports as that is easier to review and less likely to get lost. It also runs out test and all such, so it gives you and reviewers some direct visible feedback. [0] https://salsa.debian.org/apt-team/apt/-/merge_requests The first hunk seems wrong as our 'strprintf' 'prints to a std::string' given as first argument and doesn't return anything. Meantime, your change also uses std::printf which means it would print directly to stdout, which this code shouldn't do either. In general, I suppose the formatting currently is "Progress: [ 42%]" so "Progress: [ %42]" is your target? I think we could go with a "%d%%" string for all (four) cases (which is my other remark) and assemble the individual strings with e.g. "Progress: [%s]". The code could format a "%100" first to establish the maximum length and prepend spaces as needed for the real value. Oh, and one more thing: Comments in code meant for translators are per convention prefixed with: "TRANSLATORS: " (see existing usages) and should try a little harder to convey what a string is used for, meanwhile a "localize according to your locale settings" could be said about each and every string… Best regards David Kalnischkies
Hello, Thanks for the reply. I’ve tried to register on Salsa, but my accounts have not been approved yet. I’ve tried two times with usernames bitigchi and emirsari. Is it possible to direct me to a support channels about this? I will look at the patch and try to modify as per your comments. Best, Emir
See https://wiki.debian.org/Salsa/Doc which mentions that account approval is manual due to spam registrations and so might take a bit of time unfortunately – and mentions how to reach support if it takes too long. Best regards David Kalnischkies
From 4e7e0db117990e9469295934b0c7462e8c11255f Mon Sep 17 00:00:00 2001
From: Emir SARI <emir_sari@icloud.com>
Date: Fri, 5 May 2023 18:58:03 +0300
Subject: [PATCH] Apply i18n to percentage display
Languages like Turkish and French (and some other more), use a
custom percentage format, other than the standard 100%. Allowing
i18n to these values, make the apt interface a lot coherent with
the rest of the output, since they mostly appear next to translated
strings.
This commit also fixes the issue of "Progress: [100%]" to have
extra blank characters when the percentage sign is prepended to the
number; e.g. "Progress: [ %1]". Previously, it output [% 1] due
to the absolute placeholder format.
---
apt-pkg/install-progress.cc | 12 +++++++++++-
apt-private/acqprogress.cc | 9 ++++++---
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc
index c7f7573..8378200 100644
--- a/apt-pkg/install-progress.cc
+++ b/apt-pkg/install-progress.cc
@@ -56,7 +56,17 @@ bool PackageManager::StatusChanged(std::string /*PackageName*/,
{
int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1);
percentage = StepsDone/(double)TotalSteps * 100.0;
- strprintf(progress_str, _("Progress: [%3li%%]"), std::lround(percentage));
+
+ std::string percent_str;
+ // TRANSLATORS: Percentage value; %d is the number, %% is the sign
+ strprintf(percent_str, _("%d%%"), std::lround(percentage));
+
+ if (percentage < 10)
+ percent_str.insert(0, " ");
+ else if (percentage < 100)
+ percent_str.insert(0, " ");
+
+ strprintf(progress_str, _("Progress: [%s]"), percent_str.c_str());
if(percentage < (last_reported_progress + reporting_steps))
return false;
diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc
index fa7edfc..f54d732 100644
--- a/apt-private/acqprogress.cc
+++ b/apt-private/acqprogress.cc
@@ -232,9 +232,11 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
if (I->CurrentItem->TotalSize > 0 && I->CurrentItem->Owner->Complete == false)
{
if (Mode == Short)
- ioprintf(S, " %.0f%%", (I->CurrentItem->CurrentSize*100.0)/I->CurrentItem->TotalSize);
+ // TRANSLATORS: Percentage value; %0.f is the number, %% is the sign
+ ioprintf(S, _(" %.0f%%"), (I->CurrentItem->CurrentSize*100.0)/I->CurrentItem->TotalSize);
else
- ioprintf(S, "/%sB %.0f%%", SizeToStr(I->CurrentItem->TotalSize).c_str(),
+ // TRANSLATORS: Percentage value; %0.f is the number, %% is the sign
+ ioprintf(S, _("/%sB %.0f%%"), SizeToStr(I->CurrentItem->TotalSize).c_str(),
(I->CurrentItem->CurrentSize*100.0)/I->CurrentItem->TotalSize);
}
S << "]";
@@ -249,7 +251,8 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
// Put in the percent done
{
std::stringstream S;
- ioprintf(S, "%.0f%%", Percent);
+ // TRANSLATORS: Percentage value; %0.f is the number, %% is the sign
+ ioprintf(S, _("%.0f%%"), Percent);
S << Line;
Line = S.str();
S.clear();
(Re-sending, since my previous message formatting got messed-up) Hello, Oops, silly mistake. Should be fine with the new patch. Yes, correct. I left the other three as-is for now, since it would probably require casts ortype changes from int to double etc. Feel free to correct me though. I amnew to C-like languages. Done. Best regards, Emir
Hello, MR created: https://salsa.debian.org/apt-team/apt/-/merge_requests/294 Best regards, Emir (𐰽𐰺𐰍) ** E-mail needs to stay simple ** Use plain text e-mail