Skip to content

Commit cf0ba05

Browse files
author
Humdinger
committed
Add localization to package daemon and solver
Thanks to Adrien and Rene for reviewing and guidance. Fixes #13282.
1 parent 42d4bb3 commit cf0ba05

File tree

8 files changed

+133
-64
lines changed

8 files changed

+133
-64
lines changed

src/kits/package/Jamfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ for architectureObject in [ MultiArchSubDirSetup ] {
7272
Includes [ FGristFiles InitTerminateLibPackage.cpp ]
7373
: [ BuildFeatureAttribute curl : headers ] ;
7474

75+
AddResources $(libsolv) :
76+
LibsolvSolver.rdef
77+
;
78+
7579
SharedLibrary [ MultiArchDefaultGristFiles libpackage.so ]
7680
:
7781
ActivateRepositoryCacheJob.cpp
@@ -130,7 +134,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
130134
:
131135
shared
132136
bnetapi
133-
be
137+
be localestub
134138
[ BuildFeatureAttribute curl : library ]
135139
[ TargetLibstdc++ ]
136140
$(TARGET_NETWORK_LIBS)

src/kits/package/solver/Jamfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ for architectureObject in [ MultiArchSubDirSetup ] {
1212
= [ BuildFeatureAttribute libsolv : headers : path ] ;
1313
UseHeaders [ FDirName $(libsolvHeaders) solv ] ;
1414

15+
AddResources $(libsolv) :
16+
LibsolvSolver.rdef
17+
;
18+
1519
UsePrivateHeaders shared ;
1620

1721
SharedLibrary
@@ -24,8 +28,14 @@ for architectureObject in [ MultiArchSubDirSetup ] {
2428
be [ TargetLibstdc++ ]
2529
;
2630

27-
2831
Includes [ FGristFiles LibsolvSolver.cpp ]
2932
: [ BuildFeatureAttribute libsolv : headers ] ;
3033
}
3134
}
35+
36+
DoCatalogs libsolv :
37+
x-vnd.Haiku-libsolvsolver
38+
:
39+
SolverProblem.cpp
40+
SolverProblemSolution.cpp
41+
;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
resource app_version {
2+
major = 1,
3+
middle = 0,
4+
minor = 0,
5+
6+
variety = B_APPV_ALPHA,
7+
8+
internal = 7,
9+
10+
short_info = "Walter",
11+
long_info = "©2001-2017 Haiku Inc."
12+
};
13+
14+
resource app_signature "application/x-vnd.Haiku-libsolvsolver" ;

src/kits/package/solver/SolverProblem.cpp

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,42 @@
77
*/
88

99

10+
#include <Catalog.h>
11+
1012
#include <package/solver/SolverProblem.h>
1113

1214
#include <package/solver/SolverPackage.h>
1315
#include <package/solver/SolverProblemSolution.h>
1416

1517

18+
#undef B_TRANSLATION_CONTEXT
19+
#define B_TRANSLATION_CONTEXT "SolverProblem"
20+
21+
1622
static const char* const kToStringTexts[] = {
17-
"unspecified problem",
18-
"%source% does not belong to a distupgrade repository",
19-
"%source% has inferior architecture",
20-
"problem with installed package %source%",
21-
"conflicting requests",
22-
"nothing provides requested %dependency%",
23-
"%dependency% is provided by the system",
24-
"dependency problem",
25-
"package %source% is not installable",
26-
"nothing provides %dependency% needed by %source%",
27-
"cannot install both %source% and %target%",
28-
"package %source% conflicts with %dependency% provided by %target%",
29-
"package %source% obsoletes %dependency% provided by %target%",
30-
"installed package %source% obsoletes %dependency% provided by %target%",
31-
"package %source% implicitly obsoletes %dependency% provided by %target%",
32-
"package %source% requires %dependency%, but none of the providers can be "
33-
"installed",
34-
"package %source% conflicts with %dependency% provided by itself"
23+
B_TRANSLATE_MARK("unspecified problem"),
24+
B_TRANSLATE_MARK("%source% does not belong to a distupgrade repository"),
25+
B_TRANSLATE_MARK("%source% has inferior architecture"),
26+
B_TRANSLATE_MARK("problem with installed package %source%"),
27+
B_TRANSLATE_MARK("conflicting requests"),
28+
B_TRANSLATE_MARK("nothing provides requested %dependency%"),
29+
B_TRANSLATE_MARK("%dependency% is provided by the system"),
30+
B_TRANSLATE_MARK("dependency problem"),
31+
B_TRANSLATE_MARK("package %source% is not installable"),
32+
B_TRANSLATE_MARK("nothing provides %dependency% needed by %source%"),
33+
B_TRANSLATE_MARK("cannot install both %source% and %target%"),
34+
B_TRANSLATE_MARK("package %source% conflicts with %dependency% provided "
35+
"by %target%"),
36+
B_TRANSLATE_MARK("package %source% obsoletes %dependency% provided by "
37+
"%target%"),
38+
B_TRANSLATE_MARK("installed package %source% obsoletes %dependency% "
39+
"provided by %target%"),
40+
B_TRANSLATE_MARK("package %source% implicitly obsoletes %dependency% "
41+
"provided by %target%"),
42+
B_TRANSLATE_MARK("package %source% requires %dependency%, but none of the "
43+
"providers can be installed"),
44+
B_TRANSLATE_MARK("package %source% conflicts with %dependency% provided by "
45+
"itself")
3546
};
3647

3748

@@ -124,7 +135,7 @@ BSolverProblem::ToString() const
124135
if (index >= sizeof(kToStringTexts) / sizeof(kToStringTexts[0]))
125136
index = 0;
126137

127-
return BString(kToStringTexts[index])
138+
return BString(B_TRANSLATE_NOCOLLECT(kToStringTexts[index]))
128139
.ReplaceAll("%source%",
129140
fSourcePackage != NULL
130141
? fSourcePackage->VersionedName().String() : "?")

src/kits/package/solver/SolverProblemSolution.cpp

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,40 @@
77
*/
88

99

10+
#include <Catalog.h>
11+
1012
#include <package/solver/SolverProblemSolution.h>
1113

1214
#include <package/solver/SolverPackage.h>
1315

1416

17+
#undef B_TRANSLATION_CONTEXT
18+
#define B_TRANSLATION_CONTEXT "SolverProblemSolution"
19+
20+
1521
static const char* const kToStringTexts[] = {
16-
"do something",
17-
"do not keep %source% installed",
18-
"do not install \"%selection%\"",
19-
"do not install the most recent version of \"%selection%\"",
20-
"do not forbid installation of %source%",
21-
"do not deinstall \"%selection%\"",
22-
"do not deinstall all resolvables \"%selection%\"",
23-
"do not lock \"%selection%\"",
24-
"keep %source% despite its inferior architecture",
25-
"keep %source% from excluded repository",
26-
"keep old %source%",
27-
"install %source% despite its inferior architecture",
28-
"install %source% from excluded repository",
29-
"install %selection% despite its old version",
30-
"allow downgrade of %source% to %target%",
31-
"allow name change of %source% to %target%",
32-
"allow architecture change of %source% to %target%",
33-
"allow vendor change from \"%sourceVendor%\" (%source%) to "
34-
"\"%targetVendor%\" (%target%)",
35-
"allow replacement of %source% with %target%",
36-
"allow deinstallation of %source%"
22+
B_TRANSLATE_MARK("do something"),
23+
B_TRANSLATE_MARK("do not keep %source% installed"),
24+
B_TRANSLATE_MARK("do not install \"%selection%\""),
25+
B_TRANSLATE_MARK("do not install the most recent version of "
26+
"\"%selection%\""),
27+
B_TRANSLATE_MARK("do not forbid installation of %source%"),
28+
B_TRANSLATE_MARK("do not deinstall \"%selection%\""),
29+
B_TRANSLATE_MARK("do not deinstall all resolvables \"%selection%\""),
30+
B_TRANSLATE_MARK("do not lock \"%selection%\""),
31+
B_TRANSLATE_MARK("keep %source% despite its inferior architecture"),
32+
B_TRANSLATE_MARK("keep %source% from excluded repository"),
33+
B_TRANSLATE_MARK("keep old %source%"),
34+
B_TRANSLATE_MARK("install %source% despite its inferior architecture"),
35+
B_TRANSLATE_MARK("install %source% from excluded repository"),
36+
B_TRANSLATE_MARK("install %selection% despite its old version"),
37+
B_TRANSLATE_MARK("allow downgrade of %source% to %target%"),
38+
B_TRANSLATE_MARK("allow name change of %source% to %target%"),
39+
B_TRANSLATE_MARK("allow architecture change of %source% to %target%"),
40+
B_TRANSLATE_MARK("allow vendor change from \"%sourceVendor%\" (%source%) "
41+
"to \"%targetVendor%\" (%target%)"),
42+
B_TRANSLATE_MARK("allow replacement of %source% with %target%"),
43+
B_TRANSLATE_MARK("allow deinstallation of %source%")
3744
};
3845

3946

@@ -95,7 +102,7 @@ BSolverProblemSolutionElement::ToString() const
95102
if (index >= sizeof(kToStringTexts) / sizeof(kToStringTexts[0]))
96103
index = 0;
97104

98-
return BString(kToStringTexts[index])
105+
return BString(B_TRANSLATE_NOCOLLECT(kToStringTexts[index]))
99106
.ReplaceAll("%source%",
100107
fSourcePackage != NULL
101108
? fSourcePackage->VersionedName().String() : "?")

src/servers/package/Jamfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ Server package_daemon
2424
Volume.cpp
2525
VolumeState.cpp
2626
:
27-
be package
27+
be localestub package
2828
[ TargetLibstdc++ ]
2929
:
3030
package_daemon.rdef
31-
;
31+
;
32+
33+
DoCatalogs package_daemon :
34+
x-vnd.haiku-package_daemon
35+
:
36+
ProblemWindow.cpp
37+
ResultWindow.cpp
38+
;

src/servers/package/ProblemWindow.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "ProblemWindow.h"
88

99
#include <Button.h>
10+
#include <Catalog.h>
1011
#include <GroupView.h>
1112
#include <LayoutBuilder.h>
1213
#include <RadioButton.h>
@@ -22,6 +23,9 @@
2223
#include <ViewPort.h>
2324

2425

26+
#undef B_TRANSLATION_CONTEXT
27+
#define B_TRANSLATION_CONTEXT "PackageProblem"
28+
2529
using namespace BPackageKit;
2630

2731
using BPackageKit::BManager::BPrivate::BFatalErrorException;
@@ -53,7 +57,8 @@ struct ProblemWindow::Solution {
5357

5458
ProblemWindow::ProblemWindow()
5559
:
56-
BWindow(BRect(0, 0, 400, 300), "Package problems", B_TITLED_WINDOW_LOOK,
60+
BWindow(BRect(0, 0, 400, 300), B_TRANSLATE_COMMENT("Package problems",
61+
"Window title"), B_TITLED_WINDOW_LOOK,
5762
B_NORMAL_WINDOW_FEEL,
5863
B_ASYNCHRONOUS_CONTROLS | B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS,
5964
B_ALL_WORKSPACES),
@@ -77,14 +82,15 @@ ProblemWindow::ProblemWindow()
7782

7883
BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING)
7984
.SetInsets(B_USE_SMALL_INSETS)
80-
.Add(topTextView = new BStringView(NULL,
81-
"The following problems have been encountered. Please select a "
82-
"solution for each:"))
85+
.Add(topTextView = new BStringView(NULL, B_TRANSLATE(
86+
"The following problems have been encountered. Please select "
87+
"a solution for each:")))
8388
.Add(new BScrollView(NULL, viewPort = new BViewPort(), 0, false, true))
8489
.AddGroup(B_HORIZONTAL)
85-
.Add(fCancelButton = new BButton("Cancel", new BMessage(B_CANCEL)))
90+
.Add(fCancelButton = new BButton(B_TRANSLATE("Cancel"),
91+
new BMessage(B_CANCEL)))
8692
.AddGlue()
87-
.Add(fRetryButton = new BButton("Retry",
93+
.Add(fRetryButton = new BButton(B_TRANSLATE("Retry"),
8894
new BMessage(kRetryMessage)))
8995
.End();
9096

@@ -236,10 +242,11 @@ ProblemWindow::_AddProblem(BSolverProblem* problem,
236242
problemView->AdoptParentColors();
237243

238244
int32 solutionCount = problem->CountSolutions();
239-
for (int32 k = 0; k < solutionCount; k++) {
245+
for (int k = 0; k < solutionCount; k++) {
240246
const BSolverProblemSolution* solution = problem->SolutionAt(k);
241247
BRadioButton* solutionButton = new BRadioButton(
242-
BString().SetToFormat("solution %" B_PRId32 ":", k + 1),
248+
BString().SetToFormat(B_TRANSLATE_COMMENT("solution %d:",
249+
"Don't change the %d variable"), k + 1),
243250
new BMessage(kUpdateRetryButtonMessage));
244251
problemGroup->AddChild(solutionButton);
245252

@@ -261,8 +268,8 @@ ProblemWindow::_AddProblem(BSolverProblem* problem,
261268
fSolutions[solutionButton] = Solution(problem, solution);
262269
}
263270

264-
BRadioButton* ignoreButton = new BRadioButton("ignore problem for now",
265-
new BMessage(kUpdateRetryButtonMessage));
271+
BRadioButton* ignoreButton = new BRadioButton(B_TRANSLATE(
272+
"ignore problem for now"), new BMessage(kUpdateRetryButtonMessage));
266273
problemGroup->AddChild(ignoreButton);
267274
ignoreButton->SetValue(B_CONTROL_ON);
268275
}
@@ -278,8 +285,9 @@ ProblemWindow::_SolutionElementText(
278285
if (element->Type() == BSolverProblemSolutionElement::B_ALLOW_DEINSTALLATION
279286
&& package != NULL
280287
&& fPackagesAddedByUser->find(package) != fPackagesAddedByUser->end()) {
281-
return BString("don't activate package %source%").ReplaceAll(
282-
"%source%", package->VersionedName());
288+
return BString(B_TRANSLATE_COMMENT("don't activate package %source%",
289+
"don't change '%source%")).ReplaceAll(
290+
"%source%", package->VersionedName());
283291
}
284292

285293
return element->ToString();

src/servers/package/ResultWindow.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "ResultWindow.h"
88

99
#include <Button.h>
10+
#include <Catalog.h>
1011
#include <GroupView.h>
1112
#include <LayoutBuilder.h>
1213
#include <ScrollView.h>
@@ -19,6 +20,9 @@
1920
#include <ViewPort.h>
2021

2122

23+
#undef B_TRANSLATION_CONTEXT
24+
#define B_TRANSLATION_CONTEXT "PackageResult"
25+
2226
using namespace BPackageKit;
2327

2428

@@ -27,7 +31,8 @@ static const uint32 kApplyMessage = 'rtry';
2731

2832
ResultWindow::ResultWindow()
2933
:
30-
BWindow(BRect(0, 0, 400, 300), "Package changes", B_TITLED_WINDOW_LOOK,
34+
BWindow(BRect(0, 0, 400, 300), B_TRANSLATE_COMMENT("Package changes",
35+
"Window title"), B_TITLED_WINDOW_LOOK,
3136
B_NORMAL_WINDOW_FEEL,
3237
B_ASYNCHRONOUS_CONTROLS | B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS,
3338
B_ALL_WORKSPACES),
@@ -48,13 +53,14 @@ ResultWindow::ResultWindow()
4853

4954
BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING)
5055
.SetInsets(B_USE_SMALL_INSETS)
51-
.Add(topTextView = new BStringView(NULL,
52-
"The following additional package changes have to be made:"))
56+
.Add(topTextView = new BStringView(NULL, B_TRANSLATE(
57+
"The following additional package changes have to be made:")))
5358
.Add(new BScrollView(NULL, viewPort = new BViewPort(), 0, false, true))
5459
.AddGroup(B_HORIZONTAL)
55-
.Add(fCancelButton = new BButton("Cancel", new BMessage(B_CANCEL)))
60+
.Add(fCancelButton = new BButton(B_TRANSLATE("Cancel"),
61+
new BMessage(B_CANCEL)))
5662
.AddGlue()
57-
.Add(fApplyButton = new BButton("Apply changes",
63+
.Add(fApplyButton = new BButton(B_TRANSLATE("Apply changes"),
5864
new BMessage(kApplyMessage)))
5965
.End();
6066

@@ -197,11 +203,13 @@ ResultWindow::_AddPackages(BGroupLayout* packagesGroup,
197203

198204
BString text;
199205
if (install) {
200-
text.SetToFormat("install package %s from repository %s\n",
206+
text.SetToFormat(B_TRANSLATE_COMMENT("install package %s from "
207+
"repository %s\n", "Don't change '%s' variables"),
201208
package->Info().FileName().String(),
202209
package->Repository()->Name().String());
203210
} else {
204-
text.SetToFormat("uninstall package %s\n",
211+
text.SetToFormat(B_TRANSLATE_COMMENT("uninstall package %s\n",
212+
"Don't change '%s' variable"),
205213
package->VersionedName().String());
206214
}
207215

0 commit comments

Comments
 (0)