diff --git a/NSNumber+Units.h b/NSNumber+Units.h new file mode 100644 index 00000000..a0fc9348 --- /dev/null +++ b/NSNumber+Units.h @@ -0,0 +1,16 @@ +// +// NSNumber+Units.h +// Sparkle +// +// Created by Jonas Witt on 5/18/08. +// Copyright 2008 __MyCompanyName__. All rights reserved. +// + +#import + + +@interface NSNumber (Units) + ++ (NSString *)humanReadableSizeFromDouble:(double)value; + +@end diff --git a/NSNumber+Units.m b/NSNumber+Units.m new file mode 100644 index 00000000..aa70e006 --- /dev/null +++ b/NSNumber+Units.m @@ -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 diff --git a/SUUserInitiatedUpdateDriver.m b/SUUserInitiatedUpdateDriver.m index fbbff90e..8adbff08 100644 --- a/SUUserInitiatedUpdateDriver.m +++ b/SUUserInitiatedUpdateDriver.m @@ -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 diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 73ce54c2..23f1c1c8 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -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 = ""; }; 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBasicUpdateDriver.h; sourceTree = ""; }; 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBasicUpdateDriver.m; sourceTree = ""; }; + 784590BF0DE0429F00D0D64B /* NSNumber+Units.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNumber+Units.h"; sourceTree = ""; }; + 784590C00DE0429F00D0D64B /* NSNumber+Units.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNumber+Units.m"; sourceTree = ""; }; 8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 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; }; diff --git a/ca.lproj/Sparkle.strings b/ca.lproj/Sparkle.strings index 880f3b62..af834f8d 100644 Binary files a/ca.lproj/Sparkle.strings and b/ca.lproj/Sparkle.strings differ diff --git a/cs.lproj/Sparkle.strings b/cs.lproj/Sparkle.strings index d435652a..53766305 100644 Binary files a/cs.lproj/Sparkle.strings and b/cs.lproj/Sparkle.strings differ diff --git a/cy.lproj/Sparkle.strings b/cy.lproj/Sparkle.strings index b7064e3e..8bacd3c1 100644 Binary files a/cy.lproj/Sparkle.strings and b/cy.lproj/Sparkle.strings differ diff --git a/da.lproj/Sparkle.strings b/da.lproj/Sparkle.strings index 5bac4526..7dd0293a 100644 Binary files a/da.lproj/Sparkle.strings and b/da.lproj/Sparkle.strings differ diff --git a/de.lproj/Sparkle.strings b/de.lproj/Sparkle.strings index 166cb2c3..098fcb31 100644 Binary files a/de.lproj/Sparkle.strings and b/de.lproj/Sparkle.strings differ diff --git a/en.lproj/Sparkle.strings b/en.lproj/Sparkle.strings index 22abfbea..b7ce99ea 100644 Binary files a/en.lproj/Sparkle.strings and b/en.lproj/Sparkle.strings differ diff --git a/es.lproj/Sparkle.strings b/es.lproj/Sparkle.strings index 27769e1c..36d6d8bf 100644 Binary files a/es.lproj/Sparkle.strings and b/es.lproj/Sparkle.strings differ diff --git a/fi.lproj/Sparkle.strings b/fi.lproj/Sparkle.strings index e3186edc..cc7a9d36 100644 Binary files a/fi.lproj/Sparkle.strings and b/fi.lproj/Sparkle.strings differ diff --git a/fr.lproj/Sparkle.strings b/fr.lproj/Sparkle.strings index 6ce47c2d..9d9ac091 100644 Binary files a/fr.lproj/Sparkle.strings and b/fr.lproj/Sparkle.strings differ diff --git a/he.lproj/Sparkle.strings b/he.lproj/Sparkle.strings index d24e516e..1632fc44 100644 Binary files a/he.lproj/Sparkle.strings and b/he.lproj/Sparkle.strings differ diff --git a/hu.lproj/Sparkle.strings b/hu.lproj/Sparkle.strings index b7064e3e..8bacd3c1 100644 Binary files a/hu.lproj/Sparkle.strings and b/hu.lproj/Sparkle.strings differ diff --git a/id.lproj/Sparkle.strings b/id.lproj/Sparkle.strings index b7064e3e..8bacd3c1 100644 Binary files a/id.lproj/Sparkle.strings and b/id.lproj/Sparkle.strings differ diff --git a/is.lproj/Sparkle.strings b/is.lproj/Sparkle.strings index 7127b019..2f90becf 100644 Binary files a/is.lproj/Sparkle.strings and b/is.lproj/Sparkle.strings differ diff --git a/it.lproj/Sparkle.strings b/it.lproj/Sparkle.strings index ee498390..7f5db43d 100644 Binary files a/it.lproj/Sparkle.strings and b/it.lproj/Sparkle.strings differ diff --git a/ja.lproj/Sparkle.strings b/ja.lproj/Sparkle.strings index f7a57495..973f30d8 100644 Binary files a/ja.lproj/Sparkle.strings and b/ja.lproj/Sparkle.strings differ diff --git a/ko.lproj/Sparkle.strings b/ko.lproj/Sparkle.strings index b7064e3e..8bacd3c1 100644 Binary files a/ko.lproj/Sparkle.strings and b/ko.lproj/Sparkle.strings differ diff --git a/nl.lproj/Sparkle.strings b/nl.lproj/Sparkle.strings index 06fb86ed..04ba854a 100644 Binary files a/nl.lproj/Sparkle.strings and b/nl.lproj/Sparkle.strings differ diff --git a/no.lproj/Sparkle.strings b/no.lproj/Sparkle.strings index 33e0909c..5f71c080 100644 Binary files a/no.lproj/Sparkle.strings and b/no.lproj/Sparkle.strings differ diff --git a/pl.lproj/Sparkle.strings b/pl.lproj/Sparkle.strings index 821c5842..4c8d830c 100644 Binary files a/pl.lproj/Sparkle.strings and b/pl.lproj/Sparkle.strings differ diff --git a/ru.lproj/Sparkle.strings b/ru.lproj/Sparkle.strings index 54b2bc9f..d7de1ef4 100644 Binary files a/ru.lproj/Sparkle.strings and b/ru.lproj/Sparkle.strings differ diff --git a/sk.lproj/Sparkle.strings b/sk.lproj/Sparkle.strings index e1a0dd89..26226c1b 100644 Binary files a/sk.lproj/Sparkle.strings and b/sk.lproj/Sparkle.strings differ diff --git a/sv.lproj/Sparkle.strings b/sv.lproj/Sparkle.strings index 8239966e..792fed8c 100644 Binary files a/sv.lproj/Sparkle.strings and b/sv.lproj/Sparkle.strings differ diff --git a/th.lproj/Sparkle.strings b/th.lproj/Sparkle.strings index b7064e3e..8bacd3c1 100644 Binary files a/th.lproj/Sparkle.strings and b/th.lproj/Sparkle.strings differ diff --git a/tr.lproj/Sparkle.strings b/tr.lproj/Sparkle.strings index c4326589..468e272a 100644 Binary files a/tr.lproj/Sparkle.strings and b/tr.lproj/Sparkle.strings differ diff --git a/zh_CN.lproj/Sparkle.strings b/zh_CN.lproj/Sparkle.strings index 09509826..9ec31e73 100644 Binary files a/zh_CN.lproj/Sparkle.strings and b/zh_CN.lproj/Sparkle.strings differ diff --git a/zh_TW.lproj/Sparkle.strings b/zh_TW.lproj/Sparkle.strings index 51d07990..c72a9f27 100644 --- a/zh_TW.lproj/Sparkle.strings +++ b/zh_TW.lproj/Sparkle.strings @@ -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$@ 啟動時將會準備就緒!您現在是否要重新啟動? ";