Closing two units-related bugs: 231767 and 231598. Units now display in appropriate magnitudes (mb, kb, etc) and also in correct caps.

Thanks to Jonas Witt for the patch!
This commit is contained in:
Andy Matuschak committed 2008-05-22 22:59:06 -07:00
commit 2f953611db
30 files changed
+55 -2

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
//
// NSNumber+Units.h
// Sparkle
//
// Created by Jonas Witt on 5/18/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface NSNumber (Units)
+ (NSString *)humanReadableSizeFromDouble:(double)value;
@end
+28
View File
@@ -0,0 +1,28 @@
//
// NSNumber+Units.m
// Sparkle
//
// Created by Jonas Witt on 5/18/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "NSNumber+Units.h"
#import "Sparkle.h"
@implementation NSNumber (Units)
+ (NSString *)humanReadableSizeFromDouble:(double)value
{
if (value < 1024)
return [NSString stringWithFormat:@"%.0lf %@", value, SULocalizedString(@"B", @"the unit for bytes")];
if (value < 1024 * 1024)
return [NSString stringWithFormat:@"%.0lf %@", value / 1024.0, SULocalizedString(@"kB", @"the unit for kilobytes")];
if (value < 1024 * 1024 * 1024)
return [NSString stringWithFormat:@"%.1lf %@", value / 1024.0 / 1024.0, SULocalizedString(@"MB", @"the unit for megabytes")];
return [NSString stringWithFormat:@"%.2lf %@", value / 1024.0 / 1024.0 / 1024.0, SULocalizedString(@"GB", @"the unit for gigabytes")];
}
@end
+2 -1
View File
@@ -8,6 +8,7 @@
#import "SUUserInitiatedUpdateDriver.h"
#import "Sparkle.h"
#import "NSNumber+Units.h"
@implementation SUUserInitiatedUpdateDriver
@@ -83,7 +84,7 @@
- (void)download:(NSURLDownload *)download didReceiveDataOfLength:(unsigned)length
{
[statusController setProgressValue:[statusController progressValue] + length];
[statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%.0lfkb of %.0lfkb", nil), [statusController progressValue] / 1024.0, [statusController maxProgressValue] / 1024.0]];
[statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [NSNumber humanReadableSizeFromDouble:[statusController progressValue]], [NSNumber humanReadableSizeFromDouble:[statusController maxProgressValue]]]];
}
- (IBAction)cancelDownload:sender
+8
View File
@@ -94,6 +94,8 @@
61C46F340D9C54F300B06326 /* SUUpdatePermissionPrompt.nib in Resources */ = {isa = PBXBuildFile; fileRef = 61C46F330D9C54F300B06326 /* SUUpdatePermissionPrompt.nib */; };
61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */; };
61F83F740DBFE141006FDD30 /* SUBasicUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */; settings = {ATTRIBUTES = (Public, ); }; };
784590C10DE0429F00D0D64B /* NSNumber+Units.h in Headers */ = {isa = PBXBuildFile; fileRef = 784590BF0DE0429F00D0D64B /* NSNumber+Units.h */; };
784590C20DE0429F00D0D64B /* NSNumber+Units.m in Sources */ = {isa = PBXBuildFile; fileRef = 784590C00DE0429F00D0D64B /* NSNumber+Units.m */; };
DAAEFC9B0DA5722F0051E0D0 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
DAAEFD4E0DA572330051E0D0 /* relaunch.m in Sources */ = {isa = PBXBuildFile; fileRef = 613242130CD06CEF00106AA4 /* relaunch.m */; };
DAAEFD510DA572550051E0D0 /* relaunch in Resources */ = {isa = PBXBuildFile; fileRef = DAAEFC960DA571DF0051E0D0 /* relaunch */; };
@@ -263,6 +265,8 @@
61C46F350D9C54F300B06326 /* en */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = en; path = en.lproj/SUUpdatePermissionPrompt.nib; sourceTree = "<group>"; };
61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBasicUpdateDriver.h; sourceTree = "<group>"; };
61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBasicUpdateDriver.m; sourceTree = "<group>"; };
784590BF0DE0429F00D0D64B /* NSNumber+Units.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNumber+Units.h"; sourceTree = "<group>"; };
784590C00DE0429F00D0D64B /* NSNumber+Units.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNumber+Units.m"; sourceTree = "<group>"; };
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8DC2EF5B0486A6940098B216 /* Sparkle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Sparkle.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DAAEFC960DA571DF0051E0D0 /* relaunch */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = relaunch; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -474,6 +478,8 @@
children = (
61A225910D1C3ADD00430CCD /* NSBundle+SUAdditions.h */,
61A225920D1C3ADD00430CCD /* NSBundle+SUAdditions.m */,
784590BF0DE0429F00D0D64B /* NSNumber+Units.h */,
784590C00DE0429F00D0D64B /* NSNumber+Units.m */,
611779570D1111C400749C97 /* NSWorkspace_RBAdditions.h */,
611779560D1111C400749C97 /* NSWorkspace_RBAdditions.m */,
610134750DD252E60049ACDF /* NSWorkspace+SystemVersion.h */,
@@ -583,6 +589,7 @@
610134770DD252E60049ACDF /* NSWorkspace+SystemVersion.h in Headers */,
6101347B0DD2541A0049ACDF /* SUProbingUpdateDriver.h in Headers */,
61699BCC0DDB92BD005878A4 /* SUVersionComparisonTest.h in Headers */,
784590C10DE0429F00D0D64B /* NSNumber+Units.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -822,6 +829,7 @@
610134740DD250470049ACDF /* SUUpdateDriver.m in Sources */,
610134780DD252E60049ACDF /* NSWorkspace+SystemVersion.m in Sources */,
6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */,
784590C20DE0429F00D0D64B /* NSNumber+Units.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
/* No comment provided by engineer. */
"%.0lfk of %.0lfk" = "%1$.0lfk / %2$.0lfk";
"%@ of %@" = "%1$@ / %2$@";
/* No comment provided by engineer. */
"%@ %@ has been installed and will be ready to use next time %@ starts! Would you like to relaunch now?" = "%1$@ %2$@ 已安裝且下次 %3$@ 啟動時將會準備就緒!您現在是否要重新啟動? ";