Skip to content

Commit

Permalink
made byte units localizable, updated english strings file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Witt committed May 18, 2008
1 parent a0ee0f3 commit ce94db5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions NSNumber+Units.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
//

#import "NSNumber+Units.h"

#import "Sparkle.h"

@implementation NSNumber (Units)

+ (NSString *)humanReadableSizeFromDouble:(double)value
{
if (value < 1024)
return [NSString stringWithFormat:@"%ul", value];
return [NSString stringWithFormat:@"%.0lf %@", value, SULocalizedString(@"B", @"the unit for bytes")];

if (value < 1024 * 1024)
return [NSString stringWithFormat:@"%.0lf KB", value / 1024.0];
return [NSString stringWithFormat:@"%.0lf %@", value / 1024.0, SULocalizedString(@"KB", @"the unit for kilobytes")];

if (value < 1024 * 1024 * 1024)
return [NSString stringWithFormat:@"%.1lf MB", value / 1024.0 / 1024.0];
return [NSString stringWithFormat:@"%.1lf %@", value / 1024.0 / 1024.0, SULocalizedString(@"MB", @"the unit for megabytes")];

return [NSString stringWithFormat:@"%.2lf GB", value / 1024.0 / 1024.0 / 1024.0];
return [NSString stringWithFormat:@"%.2lf %@", value / 1024.0 / 1024.0 / 1024.0, SULocalizedString(@"GB", @"the unit for gigabytes")];
}

@end
Binary file modified en.lproj/Sparkle.strings
Binary file not shown.

0 comments on commit ce94db5

Please sign in to comment.