apps/softwareupdater localization improvement Bug #14526

* Use BStringFormat to allow better translations of
   strings in alert

 * Reorganise alert: shorten title length, move number of
   updates into alert text

 * (code formatting) trailing whitespace removal

Change-Id: Ib239564c26a48225f97f9beb79537e82cc206af5
Reviewed-on: https://review.haiku-os.org/c/1023
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Rob Gill
2019-02-10 10:06:44 +00:00
committed by Stephan Aßmus
parent 1e82c5d927
commit c306c63c13
+19 -13
View File
@@ -24,6 +24,7 @@
#include <NodeInfo.h> #include <NodeInfo.h>
#include <Notification.h> #include <Notification.h>
#include <Roster.h> #include <Roster.h>
#include <StringFormat.h>
#include <package/manager/Exceptions.h> #include <package/manager/Exceptions.h>
#include <package/solver/SolverPackage.h> #include <package/solver/SolverPackage.h>
@@ -74,7 +75,7 @@ CheckManager::CheckNetworkConnection()
return; return;
} }
} }
// No network connection detected, cannot continue // No network connection detected, cannot continue
fputs(B_TRANSLATE("No active network connection was found.\n"), stderr); fputs(B_TRANSLATE("No active network connection was found.\n"), stderr);
throw BAbortedByUserException(); throw BAbortedByUserException();
@@ -126,12 +127,12 @@ CheckManager::HandleProblems()
printf("problem %" B_PRId32 ": %s\n", i + 1, printf("problem %" B_PRId32 ": %s\n", i + 1,
problem->ToString().String()); problem->ToString().String());
} }
BString title(B_TRANSLATE("Available updates found")); BString title(B_TRANSLATE("Available updates found"));
BString text(B_TRANSLATE("Click here to run SoftwareUpdater. Some updates " BString text(B_TRANSLATE("Click here to run SoftwareUpdater. Some updates "
"will require a problem solution to be selected.")); "will require a problem solution to be selected."));
_SendNotification(title, text); _SendNotification(title, text);
throw BAbortedByUserException(); throw BAbortedByUserException();
} }
@@ -141,7 +142,7 @@ CheckManager::ConfirmChanges(bool fromMostSpecific)
{ {
int32 count = fInstalledRepositories.CountItems(); int32 count = fInstalledRepositories.CountItems();
int32 updateCount = 0; int32 updateCount = 0;
if (fromMostSpecific) { if (fromMostSpecific) {
for (int32 i = count - 1; i >= 0; i--) for (int32 i = count - 1; i >= 0; i--)
_CountUpdates(*fInstalledRepositories.ItemAt(i), updateCount); _CountUpdates(*fInstalledRepositories.ItemAt(i), updateCount);
@@ -149,14 +150,19 @@ CheckManager::ConfirmChanges(bool fromMostSpecific)
for (int32 i = 0; i < count; i++) for (int32 i = 0; i < count; i++)
_CountUpdates(*fInstalledRepositories.ItemAt(i), updateCount); _CountUpdates(*fInstalledRepositories.ItemAt(i), updateCount);
} }
printf("Update count=%" B_PRId32 "\n", updateCount); printf("Update count=%" B_PRId32 "\n", updateCount);
if (updateCount > 0) { if (updateCount > 0) {
BString title(B_TRANSLATE("%count% packages have available updates")); BString title;
BString count; static BStringFormat formatTitle(B_TRANSLATE(
count << updateCount; "Software {0, plural, one{update} other{updates}} available"));
title.ReplaceFirst("%count%", count); formatTitle.Format(title, updateCount);
BString text(B_TRANSLATE("Click here to install updates.")); BString text;
static BStringFormat formatText(B_TRANSLATE("Click here to "
"install {0, plural, one{# updated package} "
"other{# updated packages}}."));
formatText.Format(text, updateCount);
_SendNotification(title.String(), text.String()); _SendNotification(title.String(), text.String());
} }
throw BAbortedByUserException(); throw BAbortedByUserException();
@@ -183,7 +189,7 @@ CheckManager::ProgressPackageDownloadStarted(const char* packageName)
{ {
if (fVerbose) if (fVerbose)
_SendNotification(fHeaderChecking.String(), fTextContacting.String()); _SendNotification(fHeaderChecking.String(), fTextContacting.String());
printf("Downloading %s...\n", packageName); printf("Downloading %s...\n", packageName);
} }
@@ -235,7 +241,7 @@ CheckManager::ProgressPackageDownloadActive(const char* packageName,
printf(" %3d%%", (int)(completionPercentage * 100)); printf(" %3d%%", (int)(completionPercentage * 100));
fflush(stdout); fflush(stdout);
} }
@@ -259,7 +265,7 @@ CheckManager::ProgressPackageChecksumStarted(const char* title)
{ {
if (fVerbose) if (fVerbose)
_SendNotification(fHeaderChecking.String(), title); _SendNotification(fHeaderChecking.String(), title);
printf("%s...", title); printf("%s...", title);
} }