From cf0ba058ecc5ac7ad3be99f99219d18c051e9a43 Mon Sep 17 00:00:00 2001 From: Humdinger Date: Mon, 6 Feb 2017 16:49:35 +0100 Subject: [PATCH] Add localization to package daemon and solver Thanks to Adrien and Rene for reviewing and guidance. Fixes #13282. --- src/kits/package/Jamfile | 6 ++- src/kits/package/solver/Jamfile | 12 ++++- src/kits/package/solver/LibsolvSolver.rdef | 14 +++++ src/kits/package/solver/SolverProblem.cpp | 49 +++++++++++------- .../package/solver/SolverProblemSolution.cpp | 51 +++++++++++-------- src/servers/package/Jamfile | 11 +++- src/servers/package/ProblemWindow.cpp | 32 +++++++----- src/servers/package/ResultWindow.cpp | 22 +++++--- 8 files changed, 133 insertions(+), 64 deletions(-) create mode 100644 src/kits/package/solver/LibsolvSolver.rdef diff --git a/src/kits/package/Jamfile b/src/kits/package/Jamfile index 7d221f2cf0..9063876059 100644 --- a/src/kits/package/Jamfile +++ b/src/kits/package/Jamfile @@ -72,6 +72,10 @@ for architectureObject in [ MultiArchSubDirSetup ] { Includes [ FGristFiles InitTerminateLibPackage.cpp ] : [ BuildFeatureAttribute curl : headers ] ; + AddResources $(libsolv) : + LibsolvSolver.rdef + ; + SharedLibrary [ MultiArchDefaultGristFiles libpackage.so ] : ActivateRepositoryCacheJob.cpp @@ -130,7 +134,7 @@ for architectureObject in [ MultiArchSubDirSetup ] { : shared bnetapi - be + be localestub [ BuildFeatureAttribute curl : library ] [ TargetLibstdc++ ] $(TARGET_NETWORK_LIBS) diff --git a/src/kits/package/solver/Jamfile b/src/kits/package/solver/Jamfile index e9f8bdb0f2..e4e75c28f6 100644 --- a/src/kits/package/solver/Jamfile +++ b/src/kits/package/solver/Jamfile @@ -12,6 +12,10 @@ for architectureObject in [ MultiArchSubDirSetup ] { = [ BuildFeatureAttribute libsolv : headers : path ] ; UseHeaders [ FDirName $(libsolvHeaders) solv ] ; + AddResources $(libsolv) : + LibsolvSolver.rdef + ; + UsePrivateHeaders shared ; SharedLibrary @@ -24,8 +28,14 @@ for architectureObject in [ MultiArchSubDirSetup ] { be [ TargetLibstdc++ ] ; - Includes [ FGristFiles LibsolvSolver.cpp ] : [ BuildFeatureAttribute libsolv : headers ] ; } } + +DoCatalogs libsolv : + x-vnd.Haiku-libsolvsolver + : + SolverProblem.cpp + SolverProblemSolution.cpp +; diff --git a/src/kits/package/solver/LibsolvSolver.rdef b/src/kits/package/solver/LibsolvSolver.rdef new file mode 100644 index 0000000000..b930b11891 --- /dev/null +++ b/src/kits/package/solver/LibsolvSolver.rdef @@ -0,0 +1,14 @@ +resource app_version { + major = 1, + middle = 0, + minor = 0, + + variety = B_APPV_ALPHA, + + internal = 7, + + short_info = "Walter", + long_info = "©2001-2017 Haiku Inc." +}; + +resource app_signature "application/x-vnd.Haiku-libsolvsolver" ; diff --git a/src/kits/package/solver/SolverProblem.cpp b/src/kits/package/solver/SolverProblem.cpp index e0adce076d..a6a6bfbe88 100644 --- a/src/kits/package/solver/SolverProblem.cpp +++ b/src/kits/package/solver/SolverProblem.cpp @@ -7,31 +7,42 @@ */ +#include + #include #include #include +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "SolverProblem" + + static const char* const kToStringTexts[] = { - "unspecified problem", - "%source% does not belong to a distupgrade repository", - "%source% has inferior architecture", - "problem with installed package %source%", - "conflicting requests", - "nothing provides requested %dependency%", - "%dependency% is provided by the system", - "dependency problem", - "package %source% is not installable", - "nothing provides %dependency% needed by %source%", - "cannot install both %source% and %target%", - "package %source% conflicts with %dependency% provided by %target%", - "package %source% obsoletes %dependency% provided by %target%", - "installed package %source% obsoletes %dependency% provided by %target%", - "package %source% implicitly obsoletes %dependency% provided by %target%", - "package %source% requires %dependency%, but none of the providers can be " - "installed", - "package %source% conflicts with %dependency% provided by itself" + B_TRANSLATE_MARK("unspecified problem"), + B_TRANSLATE_MARK("%source% does not belong to a distupgrade repository"), + B_TRANSLATE_MARK("%source% has inferior architecture"), + B_TRANSLATE_MARK("problem with installed package %source%"), + B_TRANSLATE_MARK("conflicting requests"), + B_TRANSLATE_MARK("nothing provides requested %dependency%"), + B_TRANSLATE_MARK("%dependency% is provided by the system"), + B_TRANSLATE_MARK("dependency problem"), + B_TRANSLATE_MARK("package %source% is not installable"), + B_TRANSLATE_MARK("nothing provides %dependency% needed by %source%"), + B_TRANSLATE_MARK("cannot install both %source% and %target%"), + B_TRANSLATE_MARK("package %source% conflicts with %dependency% provided " + "by %target%"), + B_TRANSLATE_MARK("package %source% obsoletes %dependency% provided by " + "%target%"), + B_TRANSLATE_MARK("installed package %source% obsoletes %dependency% " + "provided by %target%"), + B_TRANSLATE_MARK("package %source% implicitly obsoletes %dependency% " + "provided by %target%"), + B_TRANSLATE_MARK("package %source% requires %dependency%, but none of the " + "providers can be installed"), + B_TRANSLATE_MARK("package %source% conflicts with %dependency% provided by " + "itself") }; @@ -124,7 +135,7 @@ BSolverProblem::ToString() const if (index >= sizeof(kToStringTexts) / sizeof(kToStringTexts[0])) index = 0; - return BString(kToStringTexts[index]) + return BString(B_TRANSLATE_NOCOLLECT(kToStringTexts[index])) .ReplaceAll("%source%", fSourcePackage != NULL ? fSourcePackage->VersionedName().String() : "?") diff --git a/src/kits/package/solver/SolverProblemSolution.cpp b/src/kits/package/solver/SolverProblemSolution.cpp index 26cf36f91f..44ff4c5f4e 100644 --- a/src/kits/package/solver/SolverProblemSolution.cpp +++ b/src/kits/package/solver/SolverProblemSolution.cpp @@ -7,33 +7,40 @@ */ +#include + #include #include +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "SolverProblemSolution" + + static const char* const kToStringTexts[] = { - "do something", - "do not keep %source% installed", - "do not install \"%selection%\"", - "do not install the most recent version of \"%selection%\"", - "do not forbid installation of %source%", - "do not deinstall \"%selection%\"", - "do not deinstall all resolvables \"%selection%\"", - "do not lock \"%selection%\"", - "keep %source% despite its inferior architecture", - "keep %source% from excluded repository", - "keep old %source%", - "install %source% despite its inferior architecture", - "install %source% from excluded repository", - "install %selection% despite its old version", - "allow downgrade of %source% to %target%", - "allow name change of %source% to %target%", - "allow architecture change of %source% to %target%", - "allow vendor change from \"%sourceVendor%\" (%source%) to " - "\"%targetVendor%\" (%target%)", - "allow replacement of %source% with %target%", - "allow deinstallation of %source%" + B_TRANSLATE_MARK("do something"), + B_TRANSLATE_MARK("do not keep %source% installed"), + B_TRANSLATE_MARK("do not install \"%selection%\""), + B_TRANSLATE_MARK("do not install the most recent version of " + "\"%selection%\""), + B_TRANSLATE_MARK("do not forbid installation of %source%"), + B_TRANSLATE_MARK("do not deinstall \"%selection%\""), + B_TRANSLATE_MARK("do not deinstall all resolvables \"%selection%\""), + B_TRANSLATE_MARK("do not lock \"%selection%\""), + B_TRANSLATE_MARK("keep %source% despite its inferior architecture"), + B_TRANSLATE_MARK("keep %source% from excluded repository"), + B_TRANSLATE_MARK("keep old %source%"), + B_TRANSLATE_MARK("install %source% despite its inferior architecture"), + B_TRANSLATE_MARK("install %source% from excluded repository"), + B_TRANSLATE_MARK("install %selection% despite its old version"), + B_TRANSLATE_MARK("allow downgrade of %source% to %target%"), + B_TRANSLATE_MARK("allow name change of %source% to %target%"), + B_TRANSLATE_MARK("allow architecture change of %source% to %target%"), + B_TRANSLATE_MARK("allow vendor change from \"%sourceVendor%\" (%source%) " + "to \"%targetVendor%\" (%target%)"), + B_TRANSLATE_MARK("allow replacement of %source% with %target%"), + B_TRANSLATE_MARK("allow deinstallation of %source%") }; @@ -95,7 +102,7 @@ BSolverProblemSolutionElement::ToString() const if (index >= sizeof(kToStringTexts) / sizeof(kToStringTexts[0])) index = 0; - return BString(kToStringTexts[index]) + return BString(B_TRANSLATE_NOCOLLECT(kToStringTexts[index])) .ReplaceAll("%source%", fSourcePackage != NULL ? fSourcePackage->VersionedName().String() : "?") diff --git a/src/servers/package/Jamfile b/src/servers/package/Jamfile index b7b944c3e1..ee33ef7c68 100644 --- a/src/servers/package/Jamfile +++ b/src/servers/package/Jamfile @@ -24,8 +24,15 @@ Server package_daemon Volume.cpp VolumeState.cpp : - be package + be localestub package [ TargetLibstdc++ ] : package_daemon.rdef - ; +; + +DoCatalogs package_daemon : + x-vnd.haiku-package_daemon + : + ProblemWindow.cpp + ResultWindow.cpp +; diff --git a/src/servers/package/ProblemWindow.cpp b/src/servers/package/ProblemWindow.cpp index 7b40ea78c7..47b61404f0 100644 --- a/src/servers/package/ProblemWindow.cpp +++ b/src/servers/package/ProblemWindow.cpp @@ -7,6 +7,7 @@ #include "ProblemWindow.h" #include +#include #include #include #include @@ -22,6 +23,9 @@ #include +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "PackageProblem" + using namespace BPackageKit; using BPackageKit::BManager::BPrivate::BFatalErrorException; @@ -53,7 +57,8 @@ struct ProblemWindow::Solution { ProblemWindow::ProblemWindow() : - BWindow(BRect(0, 0, 400, 300), "Package problems", B_TITLED_WINDOW_LOOK, + BWindow(BRect(0, 0, 400, 300), B_TRANSLATE_COMMENT("Package problems", + "Window title"), B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES), @@ -77,14 +82,15 @@ ProblemWindow::ProblemWindow() BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING) .SetInsets(B_USE_SMALL_INSETS) - .Add(topTextView = new BStringView(NULL, - "The following problems have been encountered. Please select a " - "solution for each:")) + .Add(topTextView = new BStringView(NULL, B_TRANSLATE( + "The following problems have been encountered. Please select " + "a solution for each:"))) .Add(new BScrollView(NULL, viewPort = new BViewPort(), 0, false, true)) .AddGroup(B_HORIZONTAL) - .Add(fCancelButton = new BButton("Cancel", new BMessage(B_CANCEL))) + .Add(fCancelButton = new BButton(B_TRANSLATE("Cancel"), + new BMessage(B_CANCEL))) .AddGlue() - .Add(fRetryButton = new BButton("Retry", + .Add(fRetryButton = new BButton(B_TRANSLATE("Retry"), new BMessage(kRetryMessage))) .End(); @@ -236,10 +242,11 @@ ProblemWindow::_AddProblem(BSolverProblem* problem, problemView->AdoptParentColors(); int32 solutionCount = problem->CountSolutions(); - for (int32 k = 0; k < solutionCount; k++) { + for (int k = 0; k < solutionCount; k++) { const BSolverProblemSolution* solution = problem->SolutionAt(k); BRadioButton* solutionButton = new BRadioButton( - BString().SetToFormat("solution %" B_PRId32 ":", k + 1), + BString().SetToFormat(B_TRANSLATE_COMMENT("solution %d:", + "Don't change the %d variable"), k + 1), new BMessage(kUpdateRetryButtonMessage)); problemGroup->AddChild(solutionButton); @@ -261,8 +268,8 @@ ProblemWindow::_AddProblem(BSolverProblem* problem, fSolutions[solutionButton] = Solution(problem, solution); } - BRadioButton* ignoreButton = new BRadioButton("ignore problem for now", - new BMessage(kUpdateRetryButtonMessage)); + BRadioButton* ignoreButton = new BRadioButton(B_TRANSLATE( + "ignore problem for now"), new BMessage(kUpdateRetryButtonMessage)); problemGroup->AddChild(ignoreButton); ignoreButton->SetValue(B_CONTROL_ON); } @@ -278,8 +285,9 @@ ProblemWindow::_SolutionElementText( if (element->Type() == BSolverProblemSolutionElement::B_ALLOW_DEINSTALLATION && package != NULL && fPackagesAddedByUser->find(package) != fPackagesAddedByUser->end()) { - return BString("don't activate package %source%").ReplaceAll( - "%source%", package->VersionedName()); + return BString(B_TRANSLATE_COMMENT("don't activate package %source%", + "don't change '%source%")).ReplaceAll( + "%source%", package->VersionedName()); } return element->ToString(); diff --git a/src/servers/package/ResultWindow.cpp b/src/servers/package/ResultWindow.cpp index 39253b45e3..ebc24e33a7 100644 --- a/src/servers/package/ResultWindow.cpp +++ b/src/servers/package/ResultWindow.cpp @@ -7,6 +7,7 @@ #include "ResultWindow.h" #include +#include #include #include #include @@ -19,6 +20,9 @@ #include +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "PackageResult" + using namespace BPackageKit; @@ -27,7 +31,8 @@ static const uint32 kApplyMessage = 'rtry'; ResultWindow::ResultWindow() : - BWindow(BRect(0, 0, 400, 300), "Package changes", B_TITLED_WINDOW_LOOK, + BWindow(BRect(0, 0, 400, 300), B_TRANSLATE_COMMENT("Package changes", + "Window title"), B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES), @@ -48,13 +53,14 @@ ResultWindow::ResultWindow() BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING) .SetInsets(B_USE_SMALL_INSETS) - .Add(topTextView = new BStringView(NULL, - "The following additional package changes have to be made:")) + .Add(topTextView = new BStringView(NULL, B_TRANSLATE( + "The following additional package changes have to be made:"))) .Add(new BScrollView(NULL, viewPort = new BViewPort(), 0, false, true)) .AddGroup(B_HORIZONTAL) - .Add(fCancelButton = new BButton("Cancel", new BMessage(B_CANCEL))) + .Add(fCancelButton = new BButton(B_TRANSLATE("Cancel"), + new BMessage(B_CANCEL))) .AddGlue() - .Add(fApplyButton = new BButton("Apply changes", + .Add(fApplyButton = new BButton(B_TRANSLATE("Apply changes"), new BMessage(kApplyMessage))) .End(); @@ -197,11 +203,13 @@ ResultWindow::_AddPackages(BGroupLayout* packagesGroup, BString text; if (install) { - text.SetToFormat("install package %s from repository %s\n", + text.SetToFormat(B_TRANSLATE_COMMENT("install package %s from " + "repository %s\n", "Don't change '%s' variables"), package->Info().FileName().String(), package->Repository()->Name().String()); } else { - text.SetToFormat("uninstall package %s\n", + text.SetToFormat(B_TRANSLATE_COMMENT("uninstall package %s\n", + "Don't change '%s' variable"), package->VersionedName().String()); }