~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/gpg.py

  • Committer: Patch Queue Manager
  • Date: 2011-09-12 14:54:21 UTC
  • mfrom: (6092.2.15 i18n-nulltranslations)
  • Revision ID: pqm@pqm.ubuntu.com-20110912145421-rnusbtz5vwjdpgg6
(jr) Use gettext.NullTranslations in i18n to allow use of i18n even when
 translations are not turned on. (Jonathan Riddell)

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    trace,
32
32
    ui,
33
33
    )
 
34
from bzrlib.i18n import (
 
35
    gettext, 
 
36
    ngettext,
 
37
    )
34
38
""")
35
39
 
36
 
class i18n:
37
 
    """this class is ready to use bzrlib.i18n but bzrlib.i18n is not ready to
38
 
    use so here is a stub until it is"""
39
 
    @staticmethod
40
 
    def gettext(string):
41
 
        return string
42
 
        
43
 
    @staticmethod
44
 
    def ngettext(single, plural, number):
45
 
        if number == 1:
46
 
            return single
47
 
        else:
48
 
            return plural
49
 
 
50
40
#verification results
51
41
SIGNATURE_VALID = 0
52
42
SIGNATURE_KEY_MISSING = 1
123
113
        return (count, result, all_verifiable)
124
114
 
125
115
    def valid_commits_message(self, count):
126
 
        return i18n.gettext(u"{0} commits with valid signatures").format(
 
116
        return gettext(u"{0} commits with valid signatures").format(
127
117
                                        count[SIGNATURE_VALID])            
128
118
 
129
119
    def unknown_key_message(self, count):
130
 
        return i18n.ngettext(u"{0} commit with unknown key",
 
120
        return ngettext(u"{0} commit with unknown key",
131
121
                             u"{0} commits with unknown keys",
132
122
                             count[SIGNATURE_KEY_MISSING]).format(
133
123
                                        count[SIGNATURE_KEY_MISSING])
134
124
 
135
125
    def commit_not_valid_message(self, count):
136
 
        return i18n.ngettext(u"{0} commit not valid",
 
126
        return ngettext(u"{0} commit not valid",
137
127
                             u"{0} commits not valid",
138
128
                             count[SIGNATURE_NOT_VALID]).format(
139
129
                                            count[SIGNATURE_NOT_VALID])
140
130
 
141
131
    def commit_not_signed_message(self, count):
142
 
        return i18n.ngettext(u"{0} commit not signed",
 
132
        return ngettext(u"{0} commit not signed",
143
133
                             u"{0} commits not signed",
144
134
                             count[SIGNATURE_NOT_SIGNED]).format(
145
135
                                        count[SIGNATURE_NOT_SIGNED])
146
136
 
147
137
    def expired_commit_message(self, count):
148
 
        return i18n.ngettext(u"{0} commit with key now expired",
149
 
                             u"{0} commits with key now expired",
150
 
                             count[SIGNATURE_EXPIRED]).format(
 
138
        return ngettext(u"{0} commit with key now expired",
 
139
                        u"{0} commits with key now expired",
 
140
                        count[SIGNATURE_EXPIRED]).format(
151
141
                                        count[SIGNATURE_EXPIRED])
152
142
 
153
143
 
342
332
                    self.acceptable_keys.append(key.subkeys[0].fpr)
343
333
                    trace.mutter("Added acceptable key: " + key.subkeys[0].fpr)
344
334
                if not found_key:
345
 
                    trace.note(i18n.gettext(
 
335
                    trace.note(gettext(
346
336
                            "No GnuPG key results for pattern: {0}"
347
337
                                ).format(pattern))
348
338
 
386
376
                signers[uid] += 1
387
377
        result = []
388
378
        for uid, number in signers.items():
389
 
             result.append( i18n.ngettext(u"{0} signed {1} commit", 
 
379
             result.append( ngettext(u"{0} signed {1} commit", 
390
380
                             u"{0} signed {1} commits",
391
381
                             number).format(uid, number) )
392
382
        return result
403
393
                signers[authors] += 1
404
394
        result = []
405
395
        for authors, number in signers.items():
406
 
            result.append( i18n.ngettext(u"{0} commit by author {1}", 
 
396
            result.append( ngettext(u"{0} commit by author {1}", 
407
397
                                 u"{0} commits by author {1}",
408
398
                                 number).format(number, authors) )
409
399
        return result
419
409
                signers[authors] += 1
420
410
        result = []
421
411
        for authors, number in signers.items():
422
 
            result.append( i18n.ngettext(u"{0} commit by author {1}", 
 
412
            result.append( ngettext(u"{0} commit by author {1}", 
423
413
                                 u"{0} commits by author {1}",
424
414
                                 number).format(number, authors) )
425
415
        return result
433
423
                signers[fingerprint] += 1
434
424
        result = []
435
425
        for fingerprint, number in signers.items():
436
 
            result.append( i18n.ngettext(u"Unknown key {0} signed {1} commit", 
 
426
            result.append( ngettext(u"Unknown key {0} signed {1} commit", 
437
427
                                 u"Unknown key {0} signed {1} commits",
438
428
                                 number).format(fingerprint, number) )
439
429
        return result
451
441
                fingerprint_to_authors[fingerprint] = authors
452
442
        result = []
453
443
        for fingerprint, number in signers.items():
454
 
            result.append( i18n.ngettext(u"{0} commit by author {1} with "\
455
 
                                          "key {2} now expired", 
456
 
                                 u"{0} commits by author {1} with key {2} now "\
457
 
                                  "expired",
458
 
                                 number).format(number,
 
444
            result.append(ngettext(u"{0} commit by author {1} with "\
 
445
                                    "key {2} now expired", 
 
446
                                   u"{0} commits by author {1} with key {2} now "\
 
447
                                    "expired",
 
448
                                    number).format(number,
459
449
                            fingerprint_to_authors[fingerprint], fingerprint) )
460
450
        return result
461
451
 
462
452
    def valid_commits_message(self, count):
463
453
        """returns message for number of commits"""
464
 
        return i18n.gettext(u"{0} commits with valid signatures").format(
 
454
        return gettext(u"{0} commits with valid signatures").format(
465
455
                                        count[SIGNATURE_VALID])
466
456
 
467
457
    def unknown_key_message(self, count):
468
458
        """returns message for number of commits"""
469
 
        return i18n.ngettext(u"{0} commit with unknown key",
470
 
                             u"{0} commits with unknown keys",
471
 
                             count[SIGNATURE_KEY_MISSING]).format(
 
459
        return ngettext(u"{0} commit with unknown key",
 
460
                        u"{0} commits with unknown keys",
 
461
                        count[SIGNATURE_KEY_MISSING]).format(
472
462
                                        count[SIGNATURE_KEY_MISSING])
473
463
 
474
464
    def commit_not_valid_message(self, count):
475
465
        """returns message for number of commits"""
476
 
        return i18n.ngettext(u"{0} commit not valid",
477
 
                             u"{0} commits not valid",
478
 
                             count[SIGNATURE_NOT_VALID]).format(
 
466
        return ngettext(u"{0} commit not valid",
 
467
                        u"{0} commits not valid",
 
468
                        count[SIGNATURE_NOT_VALID]).format(
479
469
                                            count[SIGNATURE_NOT_VALID])
480
470
 
481
471
    def commit_not_signed_message(self, count):
482
472
        """returns message for number of commits"""
483
 
        return i18n.ngettext(u"{0} commit not signed",
484
 
                             u"{0} commits not signed",
485
 
                             count[SIGNATURE_NOT_SIGNED]).format(
 
473
        return ngettext(u"{0} commit not signed",
 
474
                        u"{0} commits not signed",
 
475
                        count[SIGNATURE_NOT_SIGNED]).format(
486
476
                                        count[SIGNATURE_NOT_SIGNED])
487
477
 
488
478
    def expired_commit_message(self, count):
489
479
        """returns message for number of commits"""
490
 
        return i18n.ngettext(u"{0} commit with key now expired",
491
 
                             u"{0} commits with key now expired",
492
 
                             count[SIGNATURE_EXPIRED]).format(
493
 
                                        count[SIGNATURE_EXPIRED])
 
480
        return ngettext(u"{0} commit with key now expired",
 
481
                        u"{0} commits with key now expired",
 
482
                        count[SIGNATURE_EXPIRED]).format(
 
483
                                    count[SIGNATURE_EXPIRED])