Skip to content

Commit ff77237

Browse files
committed
Add translation
+ some little fix
1 parent 3afb5b0 commit ff77237

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

models/gpg_key.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,14 @@ func populateHash(hashFunc crypto.Hash, msg []byte) (hash.Hash, error) {
313313
return h, nil
314314
}
315315

316-
// readArmoredSign reads an armored signture block with the given type. https://sourcegraph.com/github.com/golang/crypto/-/blob/openpgp/read.go#L24:6-24:17
316+
// readArmoredSign read an armored signature block with the given type. https://sourcegraph.com/github.com/golang/crypto/-/blob/openpgp/read.go#L24:6-24:17
317317
func readArmoredSign(r io.Reader) (body io.Reader, err error) {
318-
expectedType := "PGP SIGNATURE"
319318
block, err := armor.Decode(r)
320319
if err != nil {
321320
return
322321
}
323-
if block.Type != expectedType {
324-
return nil, fmt.Errorf("expected '" + expectedType + "', got: " + block.Type)
322+
if block.Type != openpgp.SignatureType {
323+
return nil, fmt.Errorf("expected '" + openpgp.SignatureType + "', got: " + block.Type)
325324
}
326325
return block.Body, nil
327326
}
@@ -378,7 +377,7 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
378377
log.Error(3, "SignatureRead err: %v", err)
379378
return &CommitVerification{
380379
Verified: false,
381-
Reason: "Failed to extract signature",
380+
Reason: "gpg.error.extract_sign",
382381
}
383382
}
384383
//Generating hash of commit
@@ -387,7 +386,7 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
387386
log.Error(3, "PopulateHash: %v", err)
388387
return &CommitVerification{
389388
Verified: false,
390-
Reason: "Failed to generate hash of commit",
389+
Reason: "gpg.error.generate_hash",
391390
}
392391
}
393392

@@ -397,7 +396,7 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
397396
log.Error(3, "NoCommitterAccount: %v", err)
398397
return &CommitVerification{
399398
Verified: false,
400-
Reason: "No account linked to committer email",
399+
Reason: "gpg.error.no_committer_account",
401400
}
402401
}
403402

@@ -406,7 +405,7 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
406405
log.Error(3, "ListGPGKeys: %v", err)
407406
return &CommitVerification{
408407
Verified: false,
409-
Reason: "Failed to retrieve publics keys of committer",
408+
Reason: "gpg.error.failed_retrieval_gpg_keys",
410409
}
411410
}
412411

@@ -434,13 +433,13 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
434433
}
435434
return &CommitVerification{ //Default at this stage
436435
Verified: false,
437-
Reason: "No known key found for this signature in database",
436+
Reason: "gpg.error.no_gpg_keys_found",
438437
}
439438
}
440439

441440
return &CommitVerification{
442-
Verified: false, //Default value
443-
Reason: "Not a signed commit", //Default value
441+
Verified: false, //Default value
442+
Reason: "gpg.error.not_signed_commit", //Default value
444443
}
445444
}
446445

options/locale/locale_en-US.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,3 +1347,12 @@ no_read = You do not have any read notifications.
13471347
pin = Pin notification
13481348
mark_as_read = Mark as read
13491349
mark_as_unread = Mark as unread
1350+
1351+
1352+
[gpg]
1353+
error.extract_sign = Failed to extract signature
1354+
error.generate_hash = Failed to generate hash of commit
1355+
error.no_committer_account = No account linked to committer email
1356+
error.no_gpg_keys_found = "Failed to retrieve publics keys of committer"
1357+
error.no_gpg_keys_found = "No known key found for this signature in database"
1358+
error.not_signed_commit = "Not a signed commit"

templates/repo/commits_table.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
{{ShortSha .ID.String}}
4747
{{if .Signature}}
4848
<div class="ui detail icon button">
49-
<i title="{{.Verification.Reason}}" class="{{if .Verification.Verified }}lock green{{else}}unlock{{end}} icon"></i>
49+
{{if .Verification.Verified}}
50+
<i title="{{.Verification.Reason}}" class="lock green icon"></i>
51+
{{else}}
52+
<i title="{{$.i18n.Tr .Verification.Reason}}" class="unlock icon"></i>
53+
{{end}}
5054
</div>
5155
{{end}}
5256
</a>

templates/repo/diff/page.tmpl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,14 @@
4545
{{if .Verification.Verified }}
4646
<div class="ui bottom attached positive message" style="text-align: initial;color: black;">
4747
<i class="green lock icon"></i>
48-
<span>
49-
<span style="color: #2C662D;">Signed by :</span>
50-
<a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Commit.Committer.Name}}</strong></a> <{{.Commit.Committer.Email}}>
51-
</span>
48+
<span style="color: #2C662D;">Signed by :</span>
49+
<a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Commit.Committer.Name}}</strong></a> <{{.Commit.Committer.Email}}>
5250
<span class="pull-right"><span style="color: #2C662D;">GPG key ID:</span> {{.Verification.SigningKey.KeyID}}</span>
5351
</div>
5452
{{else}}
5553
<div class="ui bottom attached message" style="text-align: initial;color: black;">
5654
<i class="grey unlock icon"></i>
57-
{{.Verification.Reason}}
55+
{{.i18n.Tr .Verification.Reason}}
5856
</div>
5957
{{end}}
6058
{{end}}

0 commit comments

Comments
 (0)