(trunk, web) replace Transmission.formatter.plural() with a slightly less brittle pluralization tool
This commit is contained in:
parent
7219f26dae
commit
4dd6e35bd7
|
@ -268,9 +268,15 @@ Transmission.fmt = (function()
|
|||
return [date, time, period].join(' ');
|
||||
},
|
||||
|
||||
plural: function(i, word)
|
||||
ngettext: function(msgid, msgid_plural, n)
|
||||
{
|
||||
return [ i.toStringWithCommas(), ' ', word, (i==1?'':'s') ].join('');
|
||||
// TODO(i18n): http://doc.qt.digia.com/4.6/i18n-plural-rules.html
|
||||
return n === 1 ? msgid : msgid_plural;
|
||||
},
|
||||
|
||||
countString: function(msgid, msgid_plural, n)
|
||||
{
|
||||
return [ n.toStringWithCommas(), ngettext(msgid,msgid_plural,n) ].join(' ');
|
||||
},
|
||||
|
||||
peerStatus: function( flagStr )
|
||||
|
|
|
@ -670,7 +670,7 @@ function Inspector(controller) {
|
|||
if (tracker.hasAnnounced) {
|
||||
lastAnnounceTime = Transmission.fmt.timestamp(tracker.lastAnnounceTime);
|
||||
if (tracker.lastAnnounceSucceeded) {
|
||||
lastAnnounce = [ lastAnnounceTime, ' (got ', Transmission.fmt.plural(tracker.lastAnnouncePeerCount, 'peer'), ')' ];
|
||||
lastAnnounce = [ lastAnnounceTime, ' (got ', Transmission.fmt.countString('peer','peers',tracker.lastAnnouncePeerCount), ')' ];
|
||||
} else {
|
||||
lastAnnounceLabel = 'Announce error';
|
||||
lastAnnounce = [ (tracker.lastAnnounceResult ? (tracker.lastAnnounceResult + ' - ') : ''), lastAnnounceTime ];
|
||||
|
|
|
@ -167,15 +167,15 @@ TorrentRendererFull.prototype =
|
|||
return [ 'Downloading from',
|
||||
t.getPeersSendingToUs(),
|
||||
'of',
|
||||
fmt.plural (peer_count, 'peer'),
|
||||
fmt.countString('peer','peers',peer_count),
|
||||
'and',
|
||||
fmt.plural (webseed_count, 'web seed') ].join(' ');
|
||||
fmt.countString('web seed','web seeds',webseed_count) ].join(' ');
|
||||
}
|
||||
else if (webseed_count)
|
||||
{
|
||||
// Downloading from 2 webseed(s)
|
||||
return [ 'Downloading from',
|
||||
fmt.plural (webseed_count, 'web seed') ].join(' ');
|
||||
fmt.countString('web seed','web seeds',webseed_count) ].join(' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -183,7 +183,7 @@ TorrentRendererFull.prototype =
|
|||
return [ 'Downloading from',
|
||||
t.getPeersSendingToUs(),
|
||||
'of',
|
||||
fmt.plural (peer_count, 'peer') ].join(' ');
|
||||
fmt.countString('peer','peers',peer_count) ].join(' ');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ TorrentRendererFull.prototype =
|
|||
return [ 'Seeding to',
|
||||
t.getPeersGettingFromUs(),
|
||||
'of',
|
||||
fmt.plural (t.getPeersConnected(), 'peer'),
|
||||
fmt.countString ('peer','peers',t.getPeersConnected()),
|
||||
'-',
|
||||
TorrentRendererHelper.formatUL(t) ].join(' ');
|
||||
|
||||
|
|
|
@ -1146,7 +1146,7 @@ Transmission.prototype =
|
|||
$('#speed-dn-label').text( fmt.speedBps( d ) );
|
||||
|
||||
// visible torrents
|
||||
$('#filter-count').text( fmt.plural(this._rows.length, 'Transfer') );
|
||||
$('#filter-count').text( fmt.countString('Transfer','Transfers',this._rows.length ) );
|
||||
},
|
||||
|
||||
setEnabled: function(key, flag)
|
||||
|
|
Loading…
Reference in New Issue