Permalink
Browse files

Improved localization support.

Use formatted fingerprint instead of key id in verification results.
[#242 state:fixed assigned:mento milestone:1.11.7]
Use Libmacgpg's localized validity descriptions.
Use localization methods with english as fallback.
Added some localizable strings.
  • Loading branch information...
Mento committed Jan 28, 2019
1 parent e9578ed commit 3788922e7543edf45a89d5a95ae100ed94ce703b
@@ -17,6 +17,7 @@
301E96B02175F2310081B43D /* GPGAltTitleTableColumn.m in Sources */ = {isa = PBXBuildFile; fileRef = 301E96AF2175F2310081B43D /* GPGAltTitleTableColumn.m */; };
3021FB1515D83ED300510CA8 /* SimpleTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3021FB1415D83ED300510CA8 /* SimpleTextView.m */; };
302D33D516D41BF000C05409 /* Libmacgpg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 302D33D316D41BCF00C05409 /* Libmacgpg.framework */; };
303B51E621FF09C50061CE1F /* Localization.m in Sources */ = {isa = PBXBuildFile; fileRef = 303B51E521FF09C50061CE1F /* Localization.m */; };
305E3FE316FFD70000CE05C2 /* InProgressWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 305E3FE216FFD70000CE05C2 /* InProgressWindow.xib */; };
30753EA320DA839400C667CA /* GKFingerprintTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 30753EA220DA839400C667CA /* GKFingerprintTransformer.m */; };
30B2057114D56F1E00AE9583 /* PrivateKeyChooserWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3058B7CB14D56C5E00AA8881 /* PrivateKeyChooserWindow.xib */; };
@@ -162,6 +163,8 @@
3021FB1315D83ED300510CA8 /* SimpleTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SimpleTextView.h; path = Source/SimpleTextView.h; sourceTree = "<group>"; };
3021FB1415D83ED300510CA8 /* SimpleTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SimpleTextView.m; path = Source/SimpleTextView.m; sourceTree = "<group>"; };
302D33D316D41BCF00C05409 /* Libmacgpg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Libmacgpg.framework; path = /Library/Frameworks/Libmacgpg.framework; sourceTree = "<absolute>"; };
303B51E421FF09C50061CE1F /* Localization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Localization.h; path = Source/Localization.h; sourceTree = "<group>"; };
303B51E521FF09C50061CE1F /* Localization.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = Localization.m; path = Source/Localization.m; sourceTree = "<group>"; };
305E3FE216FFD70000CE05C2 /* InProgressWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InProgressWindow.xib; sourceTree = "<group>"; };
30753EA120DA839400C667CA /* GKFingerprintTransformer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = GKFingerprintTransformer.h; path = Source/GKFingerprintTransformer.h; sourceTree = "<group>"; };
30753EA220DA839400C667CA /* GKFingerprintTransformer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = GKFingerprintTransformer.m; path = Source/GKFingerprintTransformer.m; sourceTree = "<group>"; };
@@ -273,6 +276,8 @@
45DD3DE015657C4900C9A4C1 /* ServiceWrappedOperation.m */,
45FC40D91566D2D80020A12B /* ServiceWrappedArgs.h */,
45FC40DA1566D2D80020A12B /* ServiceWrappedArgs.m */,
303B51E421FF09C50061CE1F /* Localization.h */,
303B51E521FF09C50061CE1F /* Localization.m */,
);
name = Classes;
sourceTree = "<group>";
@@ -675,6 +680,7 @@
45DD3DDA1565729000C9A4C1 /* InProgressWindowController.m in Sources */,
45DD3DDE156579FF00C9A4C1 /* ServiceWorker.m in Sources */,
45DD3DE115657C4900C9A4C1 /* ServiceWrappedOperation.m in Sources */,
303B51E621FF09C50061CE1F /* Localization.m in Sources */,
45C2B9E31565AEC300B3571A /* WorkerProgressViewItem.m in Sources */,
45FC40DB1566D2D80020A12B /* ServiceWrappedArgs.m in Sources */,
451D886C156ABFAD00A0B890 /* GPGTempFile.m in Sources */,
@@ -19,22 +19,22 @@
<window title="Verification Results" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" visibleAtLaunch="NO" frameAutosaveName="verificationResults" animationBehavior="default" id="1">
<windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="364" y="458" width="937" height="253"/>
<rect key="contentRect" x="364" y="458" width="1050" height="253"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<value key="minSize" type="size" width="480" height="205"/>
<view key="contentView" misplaced="YES" id="2">
<rect key="frame" x="0.0" y="0.0" width="937" height="253"/>
<rect key="frame" x="0.0" y="0.0" width="1050" height="253"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="16">
<rect key="frame" x="20" y="60" width="897" height="173"/>
<rect key="frame" x="20" y="60" width="1010" height="173"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" id="lX9-Bh-zph">
<rect key="frame" x="1" y="0.0" width="895" height="172"/>
<rect key="frame" x="1" y="0.0" width="1008" height="172"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" multipleSelection="NO" autosaveName="recipientTable" headerView="20" id="19">
<rect key="frame" x="0.0" y="0.0" width="895" height="149"/>
<rect key="frame" x="0.0" y="0.0" width="1008" height="149"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -60,7 +60,7 @@
</binding>
</connections>
</tableColumn>
<tableColumn identifier="result" editable="NO" width="729" minWidth="300" maxWidth="1000" id="68">
<tableColumn identifier="result" editable="NO" width="842" minWidth="300" maxWidth="1000" id="68">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Result">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@@ -93,12 +93,12 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="20">
<rect key="frame" x="0.0" y="0.0" width="895" height="23"/>
<rect key="frame" x="0.0" y="0.0" width="1008" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<button verticalHuggingPriority="750" id="55">
<rect key="frame" x="827" y="12" width="96" height="32"/>
<rect key="frame" x="940" y="12" width="96" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="56">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -235,4 +235,10 @@ NO_SEC_KEY_DECRYPT_TEXT_ERROR_MSG = "The secret key required to decrypt the cont
"and" = "and";
KeyDescriptionAndMore = "%1$@ and %2$lu more";

"trust" = "trust";

"Signed by: %1$@ (%2$@) – " = "Signed by: %1$@ (%2$@) – ";

"Verification %1$@: %2$@ (Code: %3$i)" = "Verification %1$@: %2$@ (Code: %3$i)";


@@ -9,6 +9,7 @@
#import <Cocoa/Cocoa.h>
//#import <MacGPGME/MacGPGME.h>
#import "Libmacgpg/Libmacgpg.h"
#import "Localization.h"

#import "FileVerificationDataSource.h"

@@ -58,45 +59,36 @@ - (void)addResultFromSigOnMain:(NSArray *)args {
NSColor* bgColor = nil;

if([sig status] == GPGErrorNoError) {
GPGValidity validity = [sig trust];
NSString* validityDesc = nil;
// We should have a validity description method, like [sig validityDescription]
GPGValidity validity = sig.trust;

switch(validity) {
case GPGValidityUnknown:
bgColor = [NSColor clearColor];
validityDesc = @"unknown";
break;
case GPGValidityUndefined:
bgColor = [NSColor clearColor];
validityDesc = @"undefined";
break;
switch (validity) {
case GPGValidityNever:
bgColor = [NSColor colorWithCalibratedRed:0.8 green:0.0 blue:0.0 alpha:0.7];
validityDesc = @"never";
break;
case GPGValidityMarginal:
bgColor = [NSColor colorWithCalibratedRed:0.9 green:0.8 blue:0.0 alpha:1.0];
validityDesc = @"marginal";
break;
case GPGValidityFull:
bgColor = [NSColor colorWithCalibratedRed:0.0 green:0.8 blue:0.0 alpha:1.0];
validityDesc = @"full";
break;
case GPGValidityUltimate:
bgColor = [NSColor colorWithCalibratedRed:0.0 green:0.8 blue:0.0 alpha:1.0];
validityDesc = @"ultimate";
break;
default:
bgColor = [NSColor clearColor];
}
break;
}


NSString *string1 = [NSString stringWithFormat:@"Signed by: %@ (%@) – ", sig.userIDDescription, sig.fingerprint.keyID];
NSString *formattedFingerprint = [[GPGFingerprintTransformer new] transformedValue:sig.fingerprint];

NSString *string1 = localizedWithFormat(@"Signed by: %1$@ (%2$@) – ", sig.userIDDescription, formattedFingerprint);
NSMutableAttributedString *resultString = [[NSMutableAttributedString alloc] initWithString:string1 attributes:nil];

NSDictionary *attributes = @{NSFontAttributeName: [NSFont boldSystemFontOfSize:[NSFont systemFontSize]], NSBackgroundColorAttributeName: bgColor};
NSAttributedString *trustString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ trust", validityDesc] attributes:attributes];

NSString *validityDesc = [NSString stringWithFormat:@"%@ %@", [[GPGValidityDescriptionTransformer new] transformedValue:@(validity)], localized(@"trust")];
NSAttributedString *trustString = [[NSAttributedString alloc] initWithString:validityDesc attributes:attributes];
[resultString appendAttributedString:trustString];

NSMutableParagraphStyle *style = [NSMutableParagraphStyle new];
@@ -114,10 +106,12 @@ - (void)addResultFromSigOnMain:(NSArray *)args {
bgColor = [NSColor colorWithCalibratedRed:0.8 green:0.0 blue:0.0 alpha:0.7];

// Should really call GPGErrorDescription but Libmacgpg nolonger offer that.
verificationResult = [NSString stringWithFormat:@"Verification FAILED: %@ (Code: %i)", sig.humanReadableDescription, sig.status];
NSMutableAttributedString* tmp = [[NSMutableAttributedString alloc] initWithString:verificationResult
NSString *failed = localized(@"FAILED");
verificationResult = localizedWithFormat(@"Verification %1$@: %2$@ (Code: %3$i)", failed, sig.humanReadableDescription, sig.status);

NSMutableAttributedString* tmp = [[NSMutableAttributedString alloc] initWithString:verificationResult
attributes:nil];
NSRange range = [verificationResult rangeOfString:@"FAILED"];
NSRange range = [verificationResult rangeOfString:failed];
[tmp addAttribute:NSFontAttributeName
value:[NSFont boldSystemFontOfSize:[NSFont systemFontSize]]
range:range];
@@ -12,8 +12,6 @@

@interface GPGKey (GPGKey_utils)

+ (NSString*)validityDescription:(GPGValidity)validity;

- (GPGValidity)overallValidity;
- (NSString*)algorithmDescription;

@@ -10,25 +10,6 @@

@implementation GPGKey (GPGKey_utils)

+ (NSString*)validityDescription:(GPGValidity)validity {
switch(validity) {
case GPGValidityUndefined:
return @"Undefined";
case GPGValidityNever:
return @"Never";
case GPGValidityMarginal:
return @"Marginal";
case GPGValidityFull:
return @"Full";
case GPGValidityUltimate:
return @"Ultimate";
default:
return @"Unknown";
}

return @"Unknown";
}

- (GPGValidity)overallValidity {
GPGValidity val = [self validity];

@@ -140,6 +140,4 @@ typedef enum {
- (void)goneIn60Seconds;
- (void)selfQuit:(NSTimer *)timer;

+ (NSString *)localizedStringForKey:(NSString *)key;

@end
Oops, something went wrong.

0 comments on commit 3788922

Please sign in to comment.