mirror of
https://github.com/transmission/transmission
synced 2024-12-27 01:57:52 +00:00
use number formatters when displaying the number of transfers
This commit is contained in:
parent
904f09a076
commit
69fcecce1a
3 changed files with 19 additions and 8 deletions
|
@ -1785,21 +1785,27 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
|
|
||||||
- (void) setBottomCountText: (BOOL) filtering
|
- (void) setBottomCountText: (BOOL) filtering
|
||||||
{
|
{
|
||||||
|
NSNumberFormatter * numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
|
||||||
|
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
|
||||||
|
[numberFormatter setMaximumFractionDigits: 0];
|
||||||
|
|
||||||
NSString * totalTorrentsString;
|
NSString * totalTorrentsString;
|
||||||
NSInteger totalCount = [fTorrents count];
|
NSUInteger totalCount = [fTorrents count];
|
||||||
if (totalCount != 1)
|
if (totalCount != 1)
|
||||||
totalTorrentsString = [NSString stringWithFormat: NSLocalizedString(@"%d transfers", "Status bar transfer count"), totalCount];
|
totalTorrentsString = [NSString stringWithFormat: NSLocalizedString(@"%@ transfers", "Status bar transfer count"),
|
||||||
|
[numberFormatter stringFromNumber: [NSNumber numberWithUnsignedInteger: totalCount]]];
|
||||||
else
|
else
|
||||||
totalTorrentsString = NSLocalizedString(@"1 transfer", "Status bar transfer count");
|
totalTorrentsString = NSLocalizedString(@"1 transfer", "Status bar transfer count");
|
||||||
|
|
||||||
if (filtering)
|
if (filtering)
|
||||||
{
|
{
|
||||||
NSInteger count = [fTableView numberOfRows]; //have to factor in collapsed rows
|
NSUInteger count = [fTableView numberOfRows]; //have to factor in collapsed rows
|
||||||
if (count > 0 && ![[fDisplayedTorrents objectAtIndex: 0] isKindOfClass: [Torrent class]])
|
if (count > 0 && ![[fDisplayedTorrents objectAtIndex: 0] isKindOfClass: [Torrent class]])
|
||||||
count -= [fDisplayedTorrents count];
|
count -= [fDisplayedTorrents count];
|
||||||
|
|
||||||
totalTorrentsString = [NSString stringWithFormat: NSLocalizedString(@"%d of %@", "Status bar transfer count"),
|
totalTorrentsString = [NSString stringWithFormat: NSLocalizedString(@"%@ of %@", "Status bar transfer count"),
|
||||||
count, totalTorrentsString];
|
[numberFormatter stringFromNumber: [NSNumber numberWithUnsignedInteger: count]],
|
||||||
|
totalTorrentsString];
|
||||||
}
|
}
|
||||||
|
|
||||||
[fTotalTorrentsField setStringValue: totalTorrentsString];
|
[fTotalTorrentsField setStringValue: totalTorrentsString];
|
||||||
|
|
|
@ -41,8 +41,14 @@
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fCount = count;
|
fCount = count;
|
||||||
|
|
||||||
|
NSNumberFormatter * numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
|
||||||
|
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
|
||||||
|
[numberFormatter setMaximumFractionDigits: 0];
|
||||||
|
|
||||||
[self setToolTip: fCount == 1 ? NSLocalizedString(@"1 transfer", "Filter Button -> tool tip")
|
[self setToolTip: fCount == 1 ? NSLocalizedString(@"1 transfer", "Filter Button -> tool tip")
|
||||||
: [NSString stringWithFormat: NSLocalizedString(@"%d transfers", "Filter Bar Button -> tool tip"), fCount]];
|
: [NSString stringWithFormat: NSLocalizedString(@"%@ transfers", "Filter Bar Button -> tool tip"),
|
||||||
|
[numberFormatter stringFromNumber: [NSNumber numberWithUnsignedInteger: fCount]]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -503,11 +503,10 @@ tr_session * fHandle;
|
||||||
|
|
||||||
if (exists)
|
if (exists)
|
||||||
{
|
{
|
||||||
NSNumberFormatter * numberFormatter = [[NSNumberFormatter alloc] init];
|
NSNumberFormatter * numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
|
||||||
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
|
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
|
||||||
[numberFormatter setMaximumFractionDigits: 0];
|
[numberFormatter setMaximumFractionDigits: 0];
|
||||||
NSString * countString = [numberFormatter stringFromNumber: [NSNumber numberWithInt: tr_blocklistGetRuleCount(fHandle)]];
|
NSString * countString = [numberFormatter stringFromNumber: [NSNumber numberWithInt: tr_blocklistGetRuleCount(fHandle)]];
|
||||||
[numberFormatter release];
|
|
||||||
|
|
||||||
[fBlocklistMessageField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ IP address rules in list",
|
[fBlocklistMessageField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ IP address rules in list",
|
||||||
"Prefs -> blocklist -> message"), countString]];
|
"Prefs -> blocklist -> message"), countString]];
|
||||||
|
|
Loading…
Reference in a new issue