made byte units localizable, updated english strings file

This commit is contained in:
Jonas Witt committed 2008-05-18 14:18:49 +02:00
1 parent a0ee0f3f5b
commit ce94db5e4e
2 files changed
+5 -5

No files matched your search

+5 -5
View File
@@ -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 not shown.