[haiku-commits] haiku: hrev50949 - in src: kits/package/solver servers/package

  • From: humdingerb@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 11 Feb 2017 10:57:23 +0100 (CET)

hrev50949 adds 1 changeset to branch 'master'
old head: 42d4bb33f8ed1fb28b2eb322e4acf65c81f98aeb
new head: cf0ba058ecc5ac7ad3be99f99219d18c051e9a43
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=cf0ba058ecc5+%5E42d4bb33f8ed

----------------------------------------------------------------------------

cf0ba058ecc5: Add localization to package daemon and solver
  
  Thanks to Adrien and Rene for reviewing and guidance.
  Fixes #13282.

                                        [ Humdinger <humdingerb@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev50949
Commit:      cf0ba058ecc5ac7ad3be99f99219d18c051e9a43
URL:         http://cgit.haiku-os.org/haiku/commit/?id=cf0ba058ecc5
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Mon Feb  6 15:49:35 2017 UTC

Ticket:      https://dev.haiku-os.org/ticket/13282

----------------------------------------------------------------------------

8 files changed, 133 insertions(+), 64 deletions(-)
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 ++++++---

----------------------------------------------------------------------------

diff --git a/src/kits/package/Jamfile b/src/kits/package/Jamfile
index 7d221f2..9063876 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 e9f8bdb..e4e75c2 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 0000000..b930b11
--- /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 e0adce0..a6a6bfb 100644
--- a/src/kits/package/solver/SolverProblem.cpp
+++ b/src/kits/package/solver/SolverProblem.cpp
@@ -7,31 +7,42 @@
  */
 
 
+#include <Catalog.h>
+
 #include <package/solver/SolverProblem.h>
 
 #include <package/solver/SolverPackage.h>
 #include <package/solver/SolverProblemSolution.h>
 
 
+#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 26cf36f..44ff4c5 100644
--- a/src/kits/package/solver/SolverProblemSolution.cpp
+++ b/src/kits/package/solver/SolverProblemSolution.cpp
@@ -7,33 +7,40 @@
  */
 
 
+#include <Catalog.h>
+
 #include <package/solver/SolverProblemSolution.h>
 
 #include <package/solver/SolverPackage.h>
 
 
+#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 b7b944c..ee33ef7 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 7b40ea7..47b6140 100644
--- a/src/servers/package/ProblemWindow.cpp
+++ b/src/servers/package/ProblemWindow.cpp
@@ -7,6 +7,7 @@
 #include "ProblemWindow.h"
 
 #include <Button.h>
+#include <Catalog.h>
 #include <GroupView.h>
 #include <LayoutBuilder.h>
 #include <RadioButton.h>
@@ -22,6 +23,9 @@
 #include <ViewPort.h>
 
 
+#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 39253b4..ebc24e3 100644
--- a/src/servers/package/ResultWindow.cpp
+++ b/src/servers/package/ResultWindow.cpp
@@ -7,6 +7,7 @@
 #include "ResultWindow.h"
 
 #include <Button.h>
+#include <Catalog.h>
 #include <GroupView.h>
 #include <LayoutBuilder.h>
 #include <ScrollView.h>
@@ -19,6 +20,9 @@
 #include <ViewPort.h>
 
 
+#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());
                }
 


Other related posts:

  • » [haiku-commits] haiku: hrev50949 - in src: kits/package/solver servers/package - humdingerb