File: PkStrings.cpp

package info (click to toggle)
apper 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 9,868 kB
  • sloc: cpp: 14,381; xml: 941; makefile: 15; sh: 4
file content (1070 lines) | stat: -rw-r--r-- 54,590 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
/***************************************************************************
 *   Copyright (C) 2008-2011 by Daniel Nicoletti                           *
 *   dantti12@gmail.com                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; see the file COPYING. If not, write to       *
 *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  *
 *   Boston, MA 02110-1301, USA.                                           *
 ***************************************************************************/

#include "PkStrings.h"

#include <KLocalizedString>
#include <KFormat>
//#include <KGlobal>

#include <QLoggingCategory>

Q_DECLARE_LOGGING_CATEGORY(APPER_LIB)

using namespace PackageKit;

QString PkStrings::status(Transaction::Status status, uint speed, qulonglong downloadRemaining)
{
    switch (status) {
    case Transaction::StatusUnknown:
        return i18nc("This is when the transaction status is not known",
                     "Unknown state");
    case Transaction::StatusSetup:
        return i18nc("transaction state, the daemon is in the process of starting",
                     "Waiting for service to start");
    case Transaction::StatusWait:
        return i18nc("transaction state, the transaction is waiting for another to complete",
                     "Waiting for other tasks");
    case Transaction::StatusRunning :
        return i18nc("transaction state, just started",
                     "Running task");
    case Transaction::StatusQuery :
        return i18nc("transaction state, is querying data",
                     "Querying");
    case Transaction::StatusInfo :
        return i18nc("transaction state, getting data from a server",
                     "Getting information");
    case Transaction::StatusRemove :
        return i18nc("transaction state, removing packages",
                     "Removing packages");
    case Transaction::StatusDownload:
        if (speed != 0 && downloadRemaining != 0) {
            KFormat f;
            return i18nc("transaction state, downloading package files",
                         "Downloading at %1/s, %2 remaining",
                         f.formatByteSize(speed),
                         f.formatByteSize(downloadRemaining));
        } else if (speed != 0 && downloadRemaining == 0) {
            KFormat f;
            return i18nc("transaction state, downloading package files",
                         "Downloading at %1/s",
                         f.formatByteSize(speed));
        } else if (speed == 0 && downloadRemaining != 0) {
            KFormat f;
            return i18nc("transaction state, downloading package files",
                         "Downloading, %1 remaining",
                         f.formatByteSize(downloadRemaining));
        } else {
            return i18nc("transaction state, downloading package files",
                         "Downloading");
        }
    case Transaction::StatusInstall :
        return i18nc("transaction state, installing packages",
                     "Installing packages");
    case Transaction::StatusRefreshCache :
        return i18nc("transaction state, refreshing internal lists",
                     "Refreshing software list");
    case Transaction::StatusUpdate :
        return i18nc("transaction state, installing updates",
                     "Updating packages");
    case Transaction::StatusCleanup :
        return i18nc("transaction state, removing old packages, and cleaning config files",
                     "Cleaning up packages");
    case Transaction::StatusObsolete :
        return i18nc("transaction state, obsoleting old packages",
                     "Obsoleting packages");
    case Transaction::StatusDepResolve :
        return i18nc("transaction state, checking the transaction before we do it",
                     "Resolving dependencies");
    case Transaction::StatusSigCheck :
        return i18nc("transaction state, checking if we have all the security keys for the operation",
                     "Checking signatures");
    case Transaction::StatusTestCommit :
        return i18nc("transaction state, when we're doing a test transaction",
                     "Testing changes");
    case Transaction::StatusCommit :
        return i18nc("transaction state, when we're writing to the system package database",
                     "Committing changes");
    case Transaction::StatusRequest :
        return i18nc("transaction state, requesting data from a server",
                     "Requesting data");
    case Transaction::StatusFinished :
        return i18nc("transaction state, all done!",
                     "Finished");
    case Transaction::StatusCancel :
        return i18nc("transaction state, in the process of cancelling",
                     "Cancelling");
    case Transaction::StatusDownloadRepository :
        return i18nc("transaction state, downloading metadata",
                     "Downloading repository information");
    case Transaction::StatusDownloadPackagelist :
        return i18nc("transaction state, downloading metadata",
                     "Downloading list of packages");
    case Transaction::StatusDownloadFilelist :
        return i18nc("transaction state, downloading metadata",
                     "Downloading file lists");
    case Transaction::StatusDownloadChangelog :
        return i18nc("transaction state, downloading metadata",
                     "Downloading lists of changes");
    case Transaction::StatusDownloadGroup :
        return i18nc("transaction state, downloading metadata",
                     "Downloading groups");
    case Transaction::StatusDownloadUpdateinfo :
        return i18nc("transaction state, downloading metadata",
                     "Downloading update information");
    case Transaction::StatusRepackaging :
        return i18nc("transaction state, repackaging delta files",
                     "Repackaging files");
    case Transaction::StatusLoadingCache :
        return i18nc("transaction state, loading databases",
                     "Loading cache");
    case Transaction::StatusScanApplications :
        return i18nc("transaction state, scanning for running processes",
                     "Scanning installed applications");
    case Transaction::StatusGeneratePackageList :
        return i18nc("transaction state, generating a list of packages installed on the system",
                     "Generating package lists");
    case Transaction::StatusWaitingForLock :
        return i18nc("transaction state, when we're waiting for the native tools to exit",
                     "Waiting for package manager lock");
    case Transaction::StatusWaitingForAuth :
        return i18nc("waiting for user to type in a password",
                     "Waiting for authentication");
    case Transaction::StatusScanProcessList :
        return i18nc("we are updating the list of processes",
                     "Updating the list of running applications");
    case Transaction::StatusCheckExecutableFiles :
        return i18nc("we are checking executable files in use",
                     "Checking for applications currently in use");
    case Transaction::StatusCheckLibraries :
        return i18nc("we are checking for libraries in use",
                     "Checking for libraries currently in use");
    case Transaction::StatusCopyFiles :
        return i18nc("we are copying package files to prepare to install",
                     "Copying files");
    case Transaction::StatusRunHook :
        return i18nc("we are running hooks pre or post transaction",
                     "Running hooks");
    }
    qCWarning(APPER_LIB) << "status unrecognised: " << status;
    return QString();
}

QString PkStrings::status(int status, uint speed, qulonglong downloadRemaining)
{
    return PkStrings::status(static_cast<Transaction::Status>(status), speed, downloadRemaining);
}

QString PkStrings::statusPast(Transaction::Status status)
{
    switch (status) {
    case Transaction::StatusDownload:
        return i18nc("The action of the package, in past tense", "Downloaded");
    case Transaction::StatusUpdate:
        return i18nc("The action of the package, in past tense", "Updated");
    case Transaction::StatusInstall:
        return i18nc("The action of the package, in past tense", "Installed");
    case Transaction::StatusRemove:
        return i18nc("The action of the package, in past tense", "Removed");
    case Transaction::StatusCleanup:
        return i18nc("The action of the package, in past tense", "Cleaned Up");
    case Transaction::StatusObsolete:
        return i18nc("The action of the package, in past tense", "Obsoleted");
    default : // In this case we don't want to map all enums
        qCWarning(APPER_LIB) << "status unrecognised: " << status;
        return QString();
    }
}

QString PkStrings::action(Transaction::Role role, Transaction::TransactionFlags flags)
{
    switch (role) {
    case Transaction::RoleUnknown :
        return i18nc("The role of the transaction, in present tense", "Unknown role type");
    case Transaction::RoleDependsOn :
        return i18nc("The role of the transaction, in present tense", "Getting dependencies");
    case Transaction::RoleGetUpdateDetail :
        return i18nc("The role of the transaction, in present tense", "Getting update detail");
    case Transaction::RoleGetDetails:
    case Transaction::RoleGetDetailsLocal:
        return i18nc("The role of the transaction, in present tense", "Getting details");
    case Transaction::RoleRequiredBy :
        return i18nc("The role of the transaction, in present tense", "Getting requires");
    case Transaction::RoleGetUpdates :
        return i18nc("The role of the transaction, in present tense", "Getting updates");
    case Transaction::RoleSearchDetails :
        return i18nc("The role of the transaction, in present tense", "Searching details");
    case Transaction::RoleSearchFile :
        return i18nc("The role of the transaction, in present tense", "Searching for file");
    case Transaction::RoleSearchGroup :
        return i18nc("The role of the transaction, in present tense", "Searching groups");
    case Transaction::RoleSearchName :
        return i18nc("The role of the transaction, in present tense", "Searching by package name");
    case Transaction::RoleRemovePackages :
        if (flags & Transaction::TransactionFlagSimulate) {
            return i18nc("The role of the transaction, in present tense", "Simulating removal");
        } else if (flags & Transaction::TransactionFlagOnlyDownload) {
            return i18nc("The role of the transaction, in present tense", "Downloading packages");
        }
        return i18nc("The role of the transaction, in present tense", "Removing");
    case Transaction::RoleInstallPackages :
        if (flags & Transaction::TransactionFlagSimulate) {
            return i18nc("The role of the transaction, in present tense", "Simulating install");
        } else if (flags & Transaction::TransactionFlagOnlyDownload) {
            return i18nc("The role of the transaction, in present tense", "Downloading packages");
        }
        return i18nc("The role of the transaction, in present tense", "Installing");
    case Transaction::RoleInstallFiles :
        if (flags & Transaction::TransactionFlagSimulate) {
            return i18nc("The role of the transaction, in present tense", "Simulating file install");
        } else if (flags & Transaction::TransactionFlagOnlyDownload) {
            return i18nc("The role of the transaction, in present tense", "Downloading required packages");
        }
        return i18nc("The role of the transaction, in present tense", "Installing file");
    case Transaction::RoleRefreshCache :
        return i18nc("The role of the transaction, in present tense", "Refreshing package cache");
    case Transaction::RoleUpdatePackages :
        if (flags & Transaction::TransactionFlagSimulate) {
            return i18nc("The role of the transaction, in present tense", "Simulating update");
        } else if (flags & Transaction::TransactionFlagOnlyDownload) {
            return i18nc("The role of the transaction, in present tense", "Downloading updates");
        }
        return i18nc("The role of the transaction, in present tense", "Updating packages");
    case Transaction::RoleCancel :
        return i18nc("The role of the transaction, in present tense", "Canceling");
    case Transaction::RoleGetRepoList :
        return i18nc("The role of the transaction, in present tense", "Getting list of repositories");
    case Transaction::RoleRepoEnable :
        return i18nc("The role of the transaction, in present tense", "Enabling repository");
    case Transaction::RoleRepoSetData :
        return i18nc("The role of the transaction, in present tense", "Setting repository data");
    case Transaction::RoleResolve :
        return i18nc("The role of the transaction, in present tense", "Resolving");
    case Transaction::RoleGetFiles:
    case Transaction::RoleGetFilesLocal:
        return i18nc("The role of the transaction, in present tense", "Getting file list");
    case Transaction::RoleWhatProvides :
        return i18nc("The role of the transaction, in present tense", "Getting what provides");
    case Transaction::RoleInstallSignature :
        return i18nc("The role of the transaction, in present tense", "Installing signature");
    case Transaction::RoleGetPackages :
        return i18nc("The role of the transaction, in present tense", "Getting package lists");
    case Transaction::RoleAcceptEula :
        return i18nc("The role of the transaction, in present tense", "Accepting EULA");
    case Transaction::RoleDownloadPackages :
        return i18nc("The role of the transaction, in present tense", "Downloading packages");
    case Transaction::RoleGetDistroUpgrades :
        return i18nc("The role of the transaction, in present tense", "Getting distribution upgrade information");
    case Transaction::RoleGetCategories :
        return i18nc("The role of the transaction, in present tense", "Getting categories");
    case Transaction::RoleGetOldTransactions :
        return i18nc("The role of the transaction, in present tense", "Getting old transactions");
    case Transaction::RoleRepairSystem :
        return i18nc("The role of the transaction, in present tense", "Repairing system");
    case Transaction::RoleRepoRemove:
        return i18nc("The role of the transaction, in present tense", "Removing repository");
    case Transaction::RoleUpgradeSystem:
        return i18nc("The role of the transaction, in present tense", "Upgrading the system");
    }
    qCWarning(APPER_LIB) << "action unrecognised: " << role;
    return QString();
}

QString PkStrings::action(int role, int flags)
{
    return PkStrings::action(static_cast<Transaction::Role>(role), static_cast<Transaction::TransactionFlags>(flags));
}

QString PkStrings::actionPast(Transaction::Role action)
{
    switch (action) {
    case Transaction::RoleUnknown:
        return i18nc("The role of the transaction, in past tense", "Unknown role type");
    case Transaction::RoleDependsOn :
        return i18nc("The role of the transaction, in past tense", "Got dependencies");
    case Transaction::RoleGetUpdateDetail :
        return i18nc("The role of the transaction, in past tense", "Got update detail");
    case Transaction::RoleGetDetails:
    case Transaction::RoleGetDetailsLocal:
        return i18nc("The role of the transaction, in past tense", "Got details");
    case Transaction::RoleRequiredBy :
        return i18nc("The role of the transaction, in past tense", "Got requires");
    case Transaction::RoleGetUpdates :
        return i18nc("The role of the transaction, in past tense", "Got updates");
    case Transaction::RoleSearchDetails :
        return i18nc("The role of the transaction, in past tense", "Searched for package details");
    case Transaction::RoleSearchFile :
        return i18nc("The role of the transaction, in past tense", "Searched for file");
    case Transaction::RoleSearchGroup :
        return i18nc("The role of the transaction, in past tense", "Searched groups");
    case Transaction::RoleSearchName :
        return i18nc("The role of the transaction, in past tense", "Searched for package name");
    case Transaction::RoleRemovePackages :
        return i18nc("The role of the transaction, in past tense", "Removed packages");
    case Transaction::RoleInstallPackages :
        return i18nc("The role of the transaction, in past tense", "Installed packages");
    case Transaction::RoleInstallFiles :
        return i18nc("The role of the transaction, in past tense", "Installed local files");
    case Transaction::RoleRefreshCache :
        return i18nc("The role of the transaction, in past tense", "Refreshed package cache");
    case Transaction::RoleUpdatePackages :
        return i18nc("The role of the transaction, in past tense", "Updated packages");
    case Transaction::RoleCancel :
        return i18nc("The role of the transaction, in past tense", "Canceled");
    case Transaction::RoleGetRepoList :
        return i18nc("The role of the transaction, in past tense", "Got list of repositories");
    case Transaction::RoleRepoEnable :
        return i18nc("The role of the transaction, in past tense", "Enabled repository");
    case Transaction::RoleRepoSetData :
        return i18nc("The role of the transaction, in past tense", "Set repository data");
    case Transaction::RoleResolve :
        return i18nc("The role of the transaction, in past tense", "Resolved");
    case Transaction::RoleGetFiles:
    case Transaction::RoleGetFilesLocal:
        return i18nc("The role of the transaction, in past tense", "Got file list");
    case Transaction::RoleWhatProvides :
        return i18nc("The role of the transaction, in past tense", "Got what provides");
    case Transaction::RoleInstallSignature :
        return i18nc("The role of the transaction, in past tense", "Installed signature");
    case Transaction::RoleGetPackages :
        return i18nc("The role of the transaction, in past tense", "Got package lists");
    case Transaction::RoleAcceptEula :
        return i18nc("The role of the transaction, in past tense", "Accepted EULA");
    case Transaction::RoleDownloadPackages :
        return i18nc("The role of the transaction, in past tense", "Downloaded packages");
    case Transaction::RoleGetDistroUpgrades :
        return i18nc("The role of the transaction, in past tense", "Got distribution upgrades");
    case Transaction::RoleGetCategories :
        return i18nc("The role of the transaction, in past tense", "Got categories");
    case Transaction::RoleGetOldTransactions :
        return i18nc("The role of the transaction, in past tense", "Got old transactions");
    case Transaction::RoleRepairSystem:
        return i18nc("The role of the transaction, in past tense", "Repaired system");
    case Transaction::RoleRepoRemove:
        return i18nc("The role of the transaction, in past tense", "Removed repository");
    case Transaction::RoleUpgradeSystem:
        return i18nc("The role of the transaction, in past tense", "Upgraded the system");
    }
    qCWarning(APPER_LIB) << "action unrecognised: " << action;
    return QString();
}

QString PkStrings::infoPresent(Transaction::Info info)
{
    switch (info) {
    case Transaction::InfoDownloading :
        return i18n("Downloading");
    case Transaction::InfoUpdating :
        return i18n("Updating");
    case Transaction::InfoInstalling :
        return i18n("Installing");
    case Transaction::InfoRemoving :
        return i18n("Removing");
    case Transaction::InfoCleanup :
        return i18n("Cleaning up");
    case Transaction::InfoObsoleting :
        return i18n("Obsoleting");
    case Transaction::InfoReinstalling :
        return i18n("Reinstalling");
    case Transaction::InfoPreparing :
        return i18n("Preparing");
    case Transaction::InfoDecompressing :
        return i18n("Decompressing");
    default :
        qCWarning(APPER_LIB) << "info unrecognised:" << info;
        return QString();
    }
}

QString PkStrings::infoPast(Transaction::Info info)
{
    switch (info) {
    case Transaction::InfoDownloading :
        return i18n("Downloaded");
    case Transaction::InfoUpdating :
        return i18n("Updated");
    case Transaction::InfoInstalling :
        return i18n("Installed");
    case Transaction::InfoRemoving :
        return i18n("Removed");
    case Transaction::InfoCleanup :
        return i18n("Cleaned up");
    case Transaction::InfoObsoleting :
        return i18n("Obsoleted");
    case Transaction::InfoReinstalling :
        return i18n("Reinstalled");
    case Transaction::InfoPreparing :
        return i18n("Prepared");
    case Transaction::InfoDecompressing :
        return i18n("Decompressed");
    default :
        qCWarning(APPER_LIB) << "info unrecognised: " << info;
        return QString();
    }
}

QString PkStrings::error(Transaction::Error error)
{
    switch (error) {
    case Transaction::ErrorNoNetwork :
        return i18n("No network connection available");
    case Transaction::ErrorNoCache :
        return i18n("No package cache is available");
    case Transaction::ErrorOom :
        return i18n("Out of memory");
    case Transaction::ErrorCreateThreadFailed :
        return i18n("Failed to create a thread");
    case Transaction::ErrorNotSupported :
        return i18n("Not supported by this backend");
    case Transaction::ErrorInternalError :
        return i18n("An internal system error has occurred");
    case Transaction::ErrorGpgFailure :
        return i18n("A security trust relationship is not present");
    case Transaction::ErrorPackageNotInstalled :
        return i18n("The package is not installed");
    case Transaction::ErrorPackageNotFound :
        return i18n("The package was not found");
    case Transaction::ErrorPackageAlreadyInstalled :
        return i18n("The package is already installed");
    case Transaction::ErrorPackageDownloadFailed :
        return i18n("The package download failed");
    case Transaction::ErrorGroupNotFound :
        return i18n("The group was not found");
    case Transaction::ErrorGroupListInvalid :
        return i18n("The group list was invalid");
    case Transaction::ErrorDepResolutionFailed :
        return i18n("Dependency resolution failed");
    case Transaction::ErrorFilterInvalid :
        return i18n("Search filter was invalid");
    case Transaction::ErrorPackageIdInvalid :
        return i18n("The package identifier was not well formed");
    case Transaction::ErrorTransactionError :
        return i18n("Transaction error");
    case Transaction::ErrorRepoNotFound :
        return i18n("Repository name was not found");
    case Transaction::ErrorCannotRemoveSystemPackage :
        return i18n("Could not remove a protected system package");
    case Transaction::ErrorTransactionCancelled :
        return i18n("The task was canceled");
    case Transaction::ErrorProcessKill :
        return i18n("The task was forcibly canceled");
    case Transaction::ErrorFailedConfigParsing :
        return i18n("Reading the config file failed");
    case Transaction::ErrorCannotCancel :
        return i18n("The task cannot be cancelled");
    case Transaction::ErrorCannotInstallSourcePackage :
        return i18n("Source packages cannot be installed");
    case Transaction::ErrorNoLicenseAgreement :
        return i18n("The license agreement failed");
    case Transaction::ErrorFileConflicts :
        return i18n("Local file conflict between packages");
    case Transaction::ErrorPackageConflicts :
        return i18n("Packages are not compatible");
    case Transaction::ErrorRepoNotAvailable :
        return i18n("Problem connecting to a software origin");
    case Transaction::ErrorFailedInitialization :
        return i18n("Failed to initialize");
    case Transaction::ErrorFailedFinalise :
        return i18n("Failed to finalize");
    case Transaction::ErrorCannotGetLock :
        return i18n("Cannot get lock");
    case Transaction::ErrorNoPackagesToUpdate :
        return i18n("No packages to update");
    case Transaction::ErrorCannotWriteRepoConfig :
        return i18n("Cannot write repository configuration");
    case Transaction::ErrorLocalInstallFailed :
        return i18n("Local install failed");
    case Transaction::ErrorBadGpgSignature :
        return i18n("Bad GPG signature");
    case Transaction::ErrorMissingGpgSignature :
        return i18n("Missing GPG signature");
    case Transaction::ErrorRepoConfigurationError :
        return i18n("Repository configuration invalid");
    case Transaction::ErrorInvalidPackageFile :
        return i18n("Invalid package file");
    case Transaction::ErrorPackageInstallBlocked :
        return i18n("Package install blocked");
    case Transaction::ErrorPackageCorrupt :
        return i18n("Package is corrupt");
    case Transaction::ErrorAllPackagesAlreadyInstalled :
        return i18n("All packages are already installed");
    case Transaction::ErrorFileNotFound :
        return i18n("The specified file could not be found");
    case Transaction::ErrorNoMoreMirrorsToTry :
        return i18n("No more mirrors are available");
    case Transaction::ErrorNoDistroUpgradeData :
        return i18n("No distribution upgrade data is available");
    case Transaction::ErrorIncompatibleArchitecture :
        return i18n("Package is incompatible with this system");
    case Transaction::ErrorNoSpaceOnDevice :
        return i18n("No space is left on the disk");
    case Transaction::ErrorMediaChangeRequired :
        return i18n("A media change is required");
    case Transaction::ErrorNotAuthorized :
        return i18n("Authorization failed");
    case Transaction::ErrorUpdateNotFound :
        return i18n("Update not found");
    case Transaction::ErrorCannotInstallRepoUnsigned :
        return i18n("Cannot install from untrusted origin");
    case Transaction::ErrorCannotUpdateRepoUnsigned :
        return i18n("Cannot update from untrusted origin");
    case Transaction::ErrorCannotGetFilelist :
        return i18n("Cannot get the file list");
    case Transaction::ErrorCannotGetRequires :
        return i18n("Cannot get package requires");
    case Transaction::ErrorCannotDisableRepository :
        return i18n("Cannot disable origin");
    case Transaction::ErrorRestrictedDownload :
        return i18n("The download failed");
    case Transaction::ErrorPackageFailedToConfigure :
        return i18n("Package failed to configure");
    case Transaction::ErrorPackageFailedToBuild :
        return i18n("Package failed to build");
    case Transaction::ErrorPackageFailedToInstall :
        return i18n("Package failed to install");
    case Transaction::ErrorPackageFailedToRemove :
        return i18n("Package failed to be removed");
    case Transaction::ErrorUpdateFailedDueToRunningProcess :
        return i18n("Update failed due to running process");
    case Transaction::ErrorPackageDatabaseChanged :
        return i18n("The package database was changed");
    case Transaction::ErrorProvideTypeNotSupported :
        return i18n("Virtual provide type is not supported");
    case Transaction::ErrorInstallRootInvalid :
        return i18n("Install root is invalid");
    case Transaction::ErrorCannotFetchSources :
        return i18n("Cannot fetch install sources");
    case Transaction::ErrorCancelledPriority :
        return i18n("Rescheduled due to priority");
    case Transaction::ErrorUnfinishedTransaction:
        return i18n("Unfinished transaction");
    case Transaction::ErrorLockRequired:
        return i18n("Lock required");
    case Transaction::ErrorUnknown:
        return i18n("Unknown error");
    }
    qCWarning(APPER_LIB) << "error unrecognised: " << error;
    return QString();
}

QString PkStrings::errorMessage(Transaction::Error error)
{
    switch (error) {
    case Transaction::ErrorNoNetwork :
        return i18n("There is no network connection available.\n"
                    "Please check your connection settings and try again");
    case Transaction::ErrorNoCache :
        return i18n("The package list needs to be rebuilt.\n"
                    "This should have been done by the backend automatically.");
    case Transaction::ErrorOom :
        return i18n("The service that is responsible for handling user requests is out of memory.\n"
                    "Please close some programs or restart your computer.");
    case Transaction::ErrorCreateThreadFailed :
        return i18n("A thread could not be created to service the user request.");
    case Transaction::ErrorNotSupported :
        return i18n("The action is not supported by this backend.\n"
                    "Please report a bug as this should not have happened.");
    case Transaction::ErrorInternalError :
        return i18n("A problem that we were not expecting has occurred.\n"
                    "Please report this bug with the error description.");
    case Transaction::ErrorGpgFailure :
        return i18n("A security trust relationship could not be made with the software origin.\n"
                    "Please check your software signature settings.");
    case Transaction::ErrorPackageNotInstalled :
        return i18n("The package that is trying to be removed or updated is not already installed.");
    case Transaction::ErrorPackageNotFound :
        return i18n("The package that is being modified was not found on your system or in any software origin.");
    case Transaction::ErrorPackageAlreadyInstalled :
        return i18n("The package that is trying to be installed is already installed.");
    case Transaction::ErrorPackageDownloadFailed :
        return i18n("The package download failed.\n"
                    "Please check your network connectivity.");
    case Transaction::ErrorGroupNotFound :
        return i18n("The group type was not found.\n"
                    "Please check your group list and try again.");
    case Transaction::ErrorGroupListInvalid :
        return i18n("The group list could not be loaded.\n"
                    "Refreshing your cache may help, although this is normally a software "
                    "origin error.");
    case Transaction::ErrorDepResolutionFailed :
        return i18n("A package dependency could not be found.\n"
                    "More information is available in the detailed report.");
    case Transaction::ErrorFilterInvalid :
        return i18n("The search filter was not correctly formed.");
    case Transaction::ErrorPackageIdInvalid :
        return i18n("The package identifier was not well formed when sent to the system daemon.\n"
                    "This normally indicates an internal bug and should be reported.");
    case Transaction::ErrorTransactionError :
        return i18n("An error occurred while running the transaction.\n"
                    "More information is available in the detailed report.");
    case Transaction::ErrorRepoNotFound :
        return i18n("The remote software origin name was not found.\n"
                    "You may need to enable an item in Software Origins.");
    case Transaction::ErrorCannotRemoveSystemPackage :
        return i18n("Removing a protected system package is not allowed.");
    case Transaction::ErrorTransactionCancelled :
        return i18n("The task was canceled successfully and no packages were changed.");
    case Transaction::ErrorProcessKill :
        return i18n("The task was canceled successfully and no packages were changed.\n"
                    "The backend did not exit cleanly.");
    case Transaction::ErrorFailedConfigParsing :
        return i18n("The native package configuration file could not be opened.\n"
                    "Please make sure your system's configuration is valid.");
    case Transaction::ErrorCannotCancel :
        return i18n("The task is not safe to be cancelled at this time.");
    case Transaction::ErrorCannotInstallSourcePackage :
        return i18n("Source packages are not normally installed this way.\n"
                    "Check the extension of the file you are trying to install.");
    case Transaction::ErrorNoLicenseAgreement :
        return i18n("The license agreement was not agreed to.\n"
                    "To use this software you have to accept the license.");
    case Transaction::ErrorFileConflicts :
        return i18n("Two packages provide the same file.\n"
                    "This is usually due to mixing packages for different software origins.");
    case Transaction::ErrorPackageConflicts :
        return i18n("Multiple packages exist that are not compatible with each other.\n"
                    "This is usually due to mixing packages from different software origins.");
    case Transaction::ErrorRepoNotAvailable :
        return i18n("There was a (possibly temporary) problem connecting to a software origins.\n"
                    "Please check the detailed error for further details.");
    case Transaction::ErrorFailedInitialization :
        return i18n("Failed to initialize packaging backend.\n"
                    "This may occur if other packaging tools are being used simultaneously.");
    case Transaction::ErrorFailedFinalise :
        return i18n("Failed to close down the backend instance.\n"
                    "This error can normally be ignored.");
    case Transaction::ErrorCannotGetLock :
        return i18n("Cannot get the exclusive lock on the packaging backend.\n"
                    "Please close any other legacy packaging tools that may be open.");
    case Transaction::ErrorNoPackagesToUpdate :
        return i18n("None of the selected packages could be updated.");
    case Transaction::ErrorCannotWriteRepoConfig :
        return i18n("The repository configuration could not be modified.");
    case Transaction::ErrorLocalInstallFailed :
        return i18n("Installing the local file failed.\n"
                    "More information is available in the detailed report.");
    case Transaction::ErrorBadGpgSignature :
        return i18n("The package signature could not be verified.");
    case Transaction::ErrorMissingGpgSignature :
        return i18n("The package signature was missing and this package is untrusted.\n"
                    "This package was not signed with a GPG key when created.");
    case Transaction::ErrorRepoConfigurationError :
        return i18n("Repository configuration was invalid and could not be read.");
    case Transaction::ErrorInvalidPackageFile :
        return i18n("The package you are attempting to install is not valid.\n"
                    "The package file could be corrupt, or not a proper package.");
    case Transaction::ErrorPackageInstallBlocked :
        return i18n("Installation of this package was prevented by your packaging system's configuration.");
    case Transaction::ErrorPackageCorrupt :
        return i18n("The package that was downloaded is corrupt and needs to be downloaded again.");
    case Transaction::ErrorAllPackagesAlreadyInstalled :
        return i18n("All of the packages selected for install are already installed on the system.");
    case Transaction::ErrorFileNotFound :
        return i18n("The specified file could not be found on the system.\n"
                    "Check that the file still exists and has not been deleted.");
    case Transaction::ErrorNoMoreMirrorsToTry :
        return i18n("Required data could not be found on any of the configured software origins.\n"
                    "There were no more download mirrors that could be tried.");
    case Transaction::ErrorNoDistroUpgradeData :
        return i18n("Required upgrade data could not be found in any of the configured software origins.\n"
                    "The list of distribution upgrades will be unavailable.");
    case Transaction::ErrorIncompatibleArchitecture :
        return i18n("The package that is trying to be installed is incompatible with this system.");
    case Transaction::ErrorNoSpaceOnDevice :
        return i18n("There is insufficient space on the device.\n"
                    "Free some space on the system disk to perform this operation.");
    case Transaction::ErrorMediaChangeRequired :
        return i18n("Additional media is required to complete the transaction.");
    case Transaction::ErrorNotAuthorized :
        return i18n("You have failed to provide correct authentication.\n"
                    "Please check any passwords or account settings.");
    case Transaction::ErrorUpdateNotFound :
        return i18n("The specified update could not be found.\n"
                    "It could have already been installed or no longer available on the remote server.");
    case Transaction::ErrorCannotInstallRepoUnsigned :
        return i18n("The package could not be installed from untrusted origin.");
    case Transaction::ErrorCannotUpdateRepoUnsigned :
        return i18n("The package could not be updated from untrusted origin.");
    case Transaction::ErrorCannotGetFilelist :
        return i18n("The file list is not available for this package.");
    case Transaction::ErrorCannotGetRequires :
        return i18n("The information about what requires this package could not be obtained.");
    case Transaction::ErrorCannotDisableRepository :
        return i18n("The specified software origin could not be disabled.");
    case Transaction::ErrorRestrictedDownload :
        return i18n("The download could not be done automatically and should be done manually.\n"
                    "More information is available in the detailed report.");
    case Transaction::ErrorPackageFailedToConfigure :
        return i18n("One of the selected packages failed to configure correctly.\n"
                    "More information is available in the detailed report.");
    case Transaction::ErrorPackageFailedToBuild :
        return i18n("One of the selected packages failed to build correctly.\n"
                    "More information is available in the detailed report.");
    case Transaction::ErrorPackageFailedToInstall :
        return i18n("One of the selected packages failed to install correctly.\n"
                    "More information is available in the detailed report.");
    case Transaction::ErrorPackageFailedToRemove :
        return i18n("One of the selected packages failed to be removed correctly.\n"
                    "More information is available in the detailed report.");
    case Transaction::ErrorUpdateFailedDueToRunningProcess :
        return i18n("A program is running that has to be closed before the update can proceed.\n"
                    "More information is available in the detailed report.");
    case Transaction::ErrorPackageDatabaseChanged :
        return i18n("The package database was changed while the request was running.");
    case Transaction::ErrorProvideTypeNotSupported :
        return i18n("The virtual provide type is not supported by this system.");
    case Transaction::ErrorInstallRootInvalid :
        return i18n("The install root is invalid. Please contact your administrator.");
    case Transaction::ErrorCannotFetchSources :
        return i18n("The list of software could not be downloaded.");
    case Transaction::ErrorCancelledPriority :
        return i18n("The transaction has been cancelled and will be retried when the system is idle.");
    case Transaction::ErrorUnfinishedTransaction :
        return i18n("A previous package management transaction was interrupted.");
    case Transaction::ErrorLockRequired :
        return i18n("A package manager lock is required.");
    case Transaction::ErrorUnknown:
        return i18n("Unknown error, please report a bug.\n"
                    "More information is available in the detailed report.");
    }
    qCWarning(APPER_LIB) << "error unrecognised: " << error;
    return QString();
}

QString PkStrings::groups(Transaction::Group group)
{
    switch (group) {
    case Transaction::GroupAccessibility :
        return i18nc("The group type", "Accessibility");
    case Transaction::GroupAccessories :
        return i18nc("The group type", "Accessories");
    case Transaction::GroupEducation :
        return i18nc("The group type", "Education");
    case Transaction::GroupGames :
        return i18nc("The group type", "Games");
    case Transaction::GroupGraphics :
        return i18nc("The group type", "Graphics");
    case Transaction::GroupInternet :
        return i18nc("The group type", "Internet");
    case Transaction::GroupOffice :
        return i18nc("The group type", "Office");
    case Transaction::GroupOther :
        return i18nc("The group type", "Others");
    case Transaction::GroupProgramming :
        return i18nc("The group type", "Development");
    case Transaction::GroupMultimedia :
        return i18nc("The group type", "Multimedia");
    case Transaction::GroupSystem :
        return i18nc("The group type", "System");
    case Transaction::GroupDesktopGnome :
        return i18nc("The group type", "GNOME desktop");
    case Transaction::GroupDesktopKde :
        return i18nc("The group type", "KDE desktop");
    case Transaction::GroupDesktopXfce :
        return i18nc("The group type", "XFCE desktop");
    case Transaction::GroupDesktopOther :
        return i18nc("The group type", "Other desktops");
    case Transaction::GroupPublishing :
        return i18nc("The group type", "Publishing");
    case Transaction::GroupServers :
        return i18nc("The group type", "Servers");
    case Transaction::GroupFonts :
        return i18nc("The group type", "Fonts");
    case Transaction::GroupAdminTools :
        return i18nc("The group type", "Admin tools");
    case Transaction::GroupLegacy :
        return i18nc("The group type", "Legacy");
    case Transaction::GroupLocalization :
        return i18nc("The group type", "Localization");
    case Transaction::GroupVirtualization :
        return i18nc("The group type", "Virtualization");
    case Transaction::GroupSecurity :
        return i18nc("The group type", "Security");
    case Transaction::GroupPowerManagement :
        return i18nc("The group type", "Power management");
    case Transaction::GroupCommunication :
        return i18nc("The group type", "Communication");
    case Transaction::GroupNetwork :
        return i18nc("The group type", "Network");
    case Transaction::GroupMaps :
        return i18nc("The group type", "Maps");
    case Transaction::GroupRepos :
        return i18nc("The group type", "Software sources");
    case Transaction::GroupScience :
        return i18nc("The group type", "Science");
    case Transaction::GroupDocumentation :
        return i18nc("The group type", "Documentation");
    case Transaction::GroupElectronics :
        return i18nc("The group type", "Electronics");
    case Transaction::GroupCollections ://TODO check this one
        return i18nc("The group type", "Package collections");
    case Transaction::GroupVendor :
        return i18nc("The group type", "Vendor");
    case Transaction::GroupNewest :
        return i18nc("The group type", "Newest packages");
    case Transaction::GroupUnknown:
        return i18nc("The group type", "Unknown group");
    }
    qCWarning(APPER_LIB) << "group unrecognised: " << group;
    return QString();
}

QString PkStrings::info(int state)
{
    Transaction::Info stateEnum = static_cast<Transaction::Info>(state);
    switch (stateEnum) {
    case Transaction::InfoLow :
        return i18nc("The type of update", "Trivial update");
    case Transaction::InfoNormal :
        return i18nc("The type of update", "Normal update");
    case Transaction::InfoImportant :
        return i18nc("The type of update", "Important update");
    case Transaction::InfoSecurity :
        return i18nc("The type of update", "Security update");
    case Transaction::InfoBugfix :
        return i18nc("The type of update", "Bug fix update");
    case Transaction::InfoEnhancement :
        return i18nc("The type of update", "Enhancement update");
    case Transaction::InfoBlocked :
        return i18nc("The type of update", "Blocked update");
    case Transaction::InfoInstalled :
    case Transaction::InfoCollectionInstalled :
        return i18nc("The type of update", "Installed");
    case Transaction::InfoAvailable :
    case Transaction::InfoCollectionAvailable :
        return i18nc("The type of update", "Available");
    case Transaction::InfoUnknown:
        return i18nc("The type of update", "Unknown update");
    default : // In this case we don't want to map all enums
        qCWarning(APPER_LIB) << "info unrecognised: " << state;
        return QString();
    }
}

QString PkStrings::packageQuantity(bool updates, int packages, int selected)
{
    if (updates) {
        if (packages == 0) {
            return i18n("No Updates Available");
        } else if (packages == selected) {
            return i18ncp("Some updates were selected on the view",
                          "1 Update Selected",
                          "%1 Updates Selected", packages);
        } else if (selected == 0) {
            return i18ncp("Some updates are being shown on the screen",
                          "1 Update", "%1 Updates",
                          packages);
        } else {
            return i18nc("Type of update, in the case it's just an update", "%1, %2",
                         i18ncp("Part of: %1 Updates, %1 Selected", "%1 Update", "%1 Updates", packages),
                         i18ncp("Part of: %1 Updates, %1 Selected", "%1 Selected", "%1 Selected", selected));
        }
    } else {
        if (packages == 0) {
            return i18n("No Packages");
        }
        return i18np("1 Package", "%1 Packages", packages);
    }
}

QString PkStrings::restartTypeFuture(Transaction::Restart value)
{
    switch (value) {
    case Transaction::RestartNone:
        return i18n("No restart is necessary");
    case Transaction::RestartApplication:
        return i18n("You will be required to restart this application");
    case Transaction::RestartSession:
        return i18n("You will be required to log out and back in");
    case Transaction::RestartSystem:
        return i18n("A restart will be required");
    case Transaction::RestartSecuritySession:
        return i18n("You will be required to log out and back in due to a security update.");
    case Transaction::RestartSecuritySystem:
        return i18n("A restart will be required due to a security update.");
    case Transaction::RestartUnknown:
        qCWarning(APPER_LIB) << "restartTypeFuture(Transaction::RestartUnknown)";
        return QString();
    }
    qCWarning(APPER_LIB) << "restart unrecognised: " << value;
    return QString();
}

QString PkStrings::restartType(Transaction::Restart value)
{
    switch (value) {
    case Transaction::RestartNone:
        return i18n("No restart is required");
    case Transaction::RestartSystem:
        return i18n("A restart is required");
    case Transaction::RestartSession:
        return i18n("You need to log out and log back in");
    case Transaction::RestartApplication:
        return i18n("You need to restart the application");
    case Transaction::RestartSecuritySession:
        return i18n("You need to log out and log back in to remain secure.");
    case Transaction::RestartSecuritySystem:
        return i18n("A restart is required to remain secure.");
    case Transaction::RestartUnknown:
        qCWarning(APPER_LIB) << "restartType(Transaction::RestartUnknown)";
        return QString();
    }
    qCWarning(APPER_LIB) << "restart unrecognised: " << value;
    return QString();
}

QString PkStrings::updateState(Transaction::UpdateState value)
{
    switch (value) {
    case Transaction::UpdateStateStable:
        return i18n("Stable");
    case Transaction::UpdateStateUnstable:
        return i18n("Unstable");
    case Transaction::UpdateStateTesting:
        return i18n("Testing");
    case Transaction::UpdateStateUnknown:
        qCWarning(APPER_LIB) << "updateState(Transaction::UnknownUpdateState)";
        return QString();
    }
    qCWarning(APPER_LIB) << "value unrecognised: " << value;
    return QString();
}

QString PkStrings::mediaMessage(Transaction::MediaType value, const QString &text)
{
    switch (value) {
    case Transaction::MediaTypeCd :
        return i18n("Please insert the CD labeled '%1', and press continue.", text);
    case Transaction::MediaTypeDvd :
        return i18n("Please insert the DVD labeled '%1', and press continue.", text);
    case Transaction::MediaTypeDisc :
        return i18n("Please insert the disc labeled '%1', and press continue.", text);
    case Transaction::MediaTypeUnknown:
        return i18n("Please insert the medium labeled '%1', and press continue.", text);
    }
    qCWarning(APPER_LIB) << "value unrecognised: " << value;
    return i18n("Please insert the medium labeled '%1', and press continue.", text);
}

//QString PkStrings::message(Transaction::Message value)
//{
//    switch (value) {
//    case Transaction::MessageBrokenMirror :
//        return i18n("A mirror is possibly broken");
//    case Transaction::MessageConnectionRefused :
//        return i18n("The connection was refused");
//    case Transaction::MessageParameterInvalid :
//        return i18n("The parameter was invalid");
//    case Transaction::MessagePriorityInvalid :
//        return i18n("The priority was invalid");
//    case Transaction::MessageBackendError :
//        return i18n("Backend warning");
//    case Transaction::MessageDaemonError :
//        return i18n("Daemon warning");
//    case Transaction::MessageCacheBeingRebuilt :
//        return i18n("The package list cache is being rebuilt");
//    case Transaction::MessageUntrustedPackage :
//        return i18n("An untrusted package was installed");
//    case Transaction::MessageNewerPackageExists :
//        return i18n("A newer package exists");
//    case Transaction::MessageCouldNotFindPackage :
//        return i18n("Could not find package");
//    case Transaction::MessageConfigFilesChanged :
//        return i18n("Configuration files were changed");
//    case Transaction::MessagePackageAlreadyInstalled :
//        return i18n("Package is already installed");
//    case Transaction::MessageAutoremoveIgnored :
//        return i18n("Automatic cleanup is being ignored");
//    case Transaction::MessageRepoMetadataDownloadFailed :
//        return i18n("Software source download failed");
//    case Transaction::MessageRepoForDevelopersOnly :
//        return i18n("This software source is for developers only");
//    case Transaction::MessageOtherUpdatesHeldBack :
//        return i18n("Other updates have been held back");
//    case Transaction::MessageUnknown:
//        qCWarning(APPER_LIB) << "message(Enum::UnknownMessageType)";
//        return QString();
//    }
//    qCWarning(APPER_LIB) << "value unrecognised: " << value;
//    return QString();
//}

QString PkStrings::daemonError(int value)
{
    Transaction::InternalError statusEnum = static_cast<Transaction::InternalError>(value);
    switch (statusEnum) {
    case Transaction::InternalErrorFailedAuth :
        return i18n("You do not have the necessary privileges to perform this action.");
    case Transaction::InternalErrorNoTid :
        return i18n("Could not get a transaction id from packagekitd.");
    case Transaction::InternalErrorAlreadyTid :
        return i18n("Cannot connect to this transaction id.");
    case Transaction::InternalErrorRoleUnkown :
        return i18n("This action is unknown.");
    case Transaction::InternalErrorCannotStartDaemon :
        return i18n("The packagekitd service could not be started.");
    case Transaction::InternalErrorInvalidInput :
        return i18n("The query is not valid.");
    case Transaction::InternalErrorInvalidFile :
        return i18n("The file is not valid.");
    case Transaction::InternalErrorFunctionNotSupported :
        return i18n("This function is not yet supported.");
    case Transaction::InternalErrorDaemonUnreachable :
        return i18n("Could not talk to packagekitd.");
    case Transaction::InternalErrorFailed:
        return i18n("Error talking to packagekitd.");
    case Transaction::InternalErrorNone:
    case Transaction::InternalErrorUnkown :
        return i18n("An unknown error happened.");
    }
    qCWarning(APPER_LIB) << "value unrecognised: " << value;
    return i18n("An unknown error happened.");
}

QString PkStrings::prettyFormatDuration(unsigned long mSec)
{

    return KFormat().formatSpelloutDuration(mSec);
}

QString PkStrings::lastCacheRefreshTitle(uint lastTime)
{
    unsigned long fifteen = 60 * 60 * 24 * 15;
    unsigned long tirty = 60 * 60 * 24 * 30;

    if (lastTime != UINT_MAX && lastTime < fifteen) {
        return i18n("Your system is up to date");
    } else if (lastTime != UINT_MAX && lastTime > fifteen && lastTime < tirty) {
        return i18n("You have no updates");
    }
    return i18n("Last check for updates was more than a month ago");
}

QString PkStrings::lastCacheRefreshSubTitle(uint lastTime)
{
    unsigned long tirty = 60 * 60 * 24 * 30;

    if (lastTime != UINT_MAX && lastTime < tirty) {
        return i18n("Verified %1 ago", PkStrings::prettyFormatDuration(lastTime * 1000));
    }
    return i18n("It's strongly recommended that you check for new updates now");
}

#include "moc_PkStrings.cpp"