Ticket #13282: 0001-Add-localization-to-package-daemon-and-solver.patch

File 0001-Add-localization-to-package-daemon-and-solver.patch, 13.4 KB (added by humdinger, 3 years ago)

localization patch

  • src/kits/package/solver/Jamfile

    From dd0c1cf0d5850e5dff29ab5abc1736c1321e465a Mon Sep 17 00:00:00 2001
    From: Humdinger <humdingerb@gmail.com>
    Date: Mon, 6 Feb 2017 16:49:35 +0100
    Subject: [PATCH] Add localization to package daemon and solver
    
    ---
     src/kits/package/solver/Jamfile                   | 10 ++++-
     src/kits/package/solver/SolverProblem.cpp         | 49 +++++++++++++---------
     src/kits/package/solver/SolverProblemSolution.cpp | 51 +++++++++++++----------
     src/servers/package/Jamfile                       | 11 ++++-
     src/servers/package/ProblemWindow.cpp             | 30 ++++++++-----
     src/servers/package/ResultWindow.cpp              | 22 ++++++----
     6 files changed, 110 insertions(+), 63 deletions(-)
    
    diff --git a/src/kits/package/solver/Jamfile b/src/kits/package/solver/Jamfile
    index e9f8bdb..050853c 100644
    a b for architectureObject in [ MultiArchSubDirSetup ] {  
    2121            :
    2222            package
    2323            [ BuildFeatureAttribute libsolv : libraries ]
    24             be [ TargetLibstdc++ ]
     24            be localestub [ TargetLibstdc++ ]
    2525        ;
    2626
    27 
    2827        Includes [ FGristFiles LibsolvSolver.cpp ]
    2928            : [ BuildFeatureAttribute libsolv : headers ] ;
    3029    }
    3130}
     31
     32DoCatalogs libsolv :
     33    x-vnd.Haiku-libsolv
     34    :
     35    SolverProblem.cpp
     36    SolverProblemSolution.cpp
     37;
  • src/kits/package/solver/SolverProblem.cpp

    diff --git a/src/kits/package/solver/SolverProblem.cpp b/src/kits/package/solver/SolverProblem.cpp
    index e0adce0..a6a6bfb 100644
    a b  
    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
    1622static 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
    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

    diff --git a/src/kits/package/solver/SolverProblemSolution.cpp b/src/kits/package/solver/SolverProblemSolution.cpp
    index 26cf36f..44ff4c5 100644
    a b  
    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
    1521static 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
    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

    diff --git a/src/servers/package/Jamfile b/src/servers/package/Jamfile
    index b7b944c..ee33ef7 100644
    a b 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
     33DoCatalogs package_daemon :
     34    x-vnd.haiku-package_daemon
     35    :
     36    ProblemWindow.cpp
     37    ResultWindow.cpp
     38;
  • src/servers/package/ProblemWindow.cpp

    diff --git a/src/servers/package/ProblemWindow.cpp b/src/servers/package/ProblemWindow.cpp
    index 7b40ea7..a38cb2e 100644
    a b  
    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>
     
    2223#include <ViewPort.h>
    2324
    2425
     26#undef B_TRANSLATION_CONTEXT
     27#define B_TRANSLATION_CONTEXT "PackageProblem"
     28
    2529using namespace BPackageKit;
    2630
    2731using BPackageKit::BManager::BPrivate::BFatalErrorException;
    struct ProblemWindow::Solution {  
    5357
    5458ProblemWindow::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),
    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
    ProblemWindow::_AddProblem(BSolverProblem* problem,  
    238244    int32 solutionCount = problem->CountSolutions();
    239245    for (int32 k = 0; k < solutionCount; k++) {
    240246        const BSolverProblemSolution* solution = problem->SolutionAt(k);
     247        BString solutionText = B_TRANSLATE("solution");
    241248        BRadioButton* solutionButton = new BRadioButton(
    242             BString().SetToFormat("solution %" B_PRId32 ":", k + 1),
     249            solutionText << BString().SetToFormat(" %" B_PRId32 ":", k + 1),
    243250            new BMessage(kUpdateRetryButtonMessage));
    244251        problemGroup->AddChild(solutionButton);
    245252
    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}
    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

    diff --git a/src/servers/package/ResultWindow.cpp b/src/servers/package/ResultWindow.cpp
    index 39253b4..ebc24e3 100644
    a b  
    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>
     
    1920#include <ViewPort.h>
    2021
    2122
     23#undef B_TRANSLATION_CONTEXT
     24#define B_TRANSLATION_CONTEXT "PackageResult"
     25
    2226using namespace BPackageKit;
    2327
    2428
    static const uint32 kApplyMessage = 'rtry';  
    2731
    2832ResultWindow::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),
    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
    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