diff --git a/README.md b/README.md index bfbcb625b..9a92cd70e 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,10 @@ You would want to setup your editor to make use of the .clang-format file locate If for some reason you are unwilling or unable to do so, there is a shell script which you can use: `./code_style.sh` +### Translations + +See [language translations](docs/Translating.md). + ## Sponsors diff --git a/docs/Translating.md b/docs/Translating.md index 1ea7c62c7..23e3b75d6 100644 --- a/docs/Translating.md +++ b/docs/Translating.md @@ -4,10 +4,6 @@ As with any other project, we expect you to be familiar with particular Transmis General rule is that new localizations are only included in next release if they are at least 95% complete. Transifex (see below) offers a review functionality, so if you feel like it and are not afraid of responsibility — don't hesitate to ask and we could then have a different deal based on reviewed percentage instead (nothing is set in stone as of now). -## Qt and GTK+ clients -Translations for Qt and GTK+ clients are managed on Transifex. To help localize, or add your new localization, you'll need to [register on Transifex and join the translation team](https://docs.transifex.com/getting-started/translators) for [Transmission project](https://www.transifex.com/transmissionbt/transmissionbt). +Translations for Mac, Qt and GTK+ clients are managed on Transifex. To help localize, or add your new localization, you'll need to [register on Transifex and join the translation team](https://docs.transifex.com/getting-started/translators) for [Transmission project](https://www.transifex.com/transmissionbt/transmissionbt). _GTK+ client translations were previously managed on [Launchpad](https://translations.launchpad.net/transmission/trunk/+pots/transmission), but this is no longer the case. No phrases will be updated there, and none of your translations made there will be integrated back into Transmission._ - -## Mac client -Parts of Mac client translations have been recently uploaded to Transifex as well. We are still in the process of making all of the translations accessible there, including plural forms support and phrases currently only present in .xib files. It will all be there prior to next major release, so stay tuned. You could start localizing now (follow the same steps as above), but be prepared for some inconveniences along the way. diff --git a/macosx/AddWindowController.mm b/macosx/AddWindowController.mm index f0af38951..ec3b95bc2 100644 --- a/macosx/AddWindowController.mm +++ b/macosx/AddWindowController.mm @@ -320,7 +320,7 @@ typedef NS_ENUM(NSUInteger, PopupPriority) { NSUInteger count = self.torrent.fileCount; if (count != 1) { - fileString = [NSString stringWithFormat:NSLocalizedString(@"%lu files", "Add torrent -> info"), count]; + fileString = [NSString localizedStringWithFormat:NSLocalizedString(@"%lu files", "Add torrent -> info"), count]; } else { diff --git a/macosx/Badger.mm b/macosx/Badger.mm index 293e2d67b..6d59b58ce 100644 --- a/macosx/Badger.mm +++ b/macosx/Badger.mm @@ -49,7 +49,7 @@ NSParameterAssert(torrent != nil); [self.fHashes addObject:torrent.hashString]; - NSApp.dockTile.badgeLabel = [NSString formattedUInteger:self.fHashes.count]; + NSApp.dockTile.badgeLabel = [NSString localizedStringWithFormat:@"%lu", self.fHashes.count]; } - (void)removeTorrent:(Torrent*)torrent @@ -59,7 +59,7 @@ [self.fHashes removeObject:torrent.hashString]; if (self.fHashes.count > 0) { - NSApp.dockTile.badgeLabel = [NSString formattedUInteger:self.fHashes.count]; + NSApp.dockTile.badgeLabel = [NSString localizedStringWithFormat:@"%lu", self.fHashes.count]; } else { diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 050fc575d..da071cd74 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -969,11 +969,11 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool @"There is an active transfer that will be paused on quit." " The transfer will automatically resume on the next launch.", "Confirm Quit panel -> message") : - [NSString stringWithFormat:NSLocalizedString( - @"There are %lu active transfers that will be paused on quit." - " The transfers will automatically resume on the next launch.", - "Confirm Quit panel -> message"), - active]; + [NSString localizedStringWithFormat:NSLocalizedString( + @"There are %lu active transfers that will be paused on quit." + " The transfers will automatically resume on the next launch.", + "Confirm Quit panel -> message"), + active]; [alert addButtonWithTitle:NSLocalizedString(@"Quit", "Confirm Quit panel -> button")]; [alert addButtonWithTitle:NSLocalizedString(@"Cancel", "Confirm Quit panel -> button")]; alert.showsSuppressionButton = YES; @@ -1787,30 +1787,30 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool { if (deleteData) { - title = [NSString stringWithFormat:NSLocalizedString( - @"Are you sure you want to remove %lu transfers from the transfer list" - " and trash the data files?", - "Removal confirm panel -> title"), - selected]; + title = [NSString localizedStringWithFormat:NSLocalizedString( + @"Are you sure you want to remove %lu transfers from the transfer list" + " and trash the data files?", + "Removal confirm panel -> title"), + selected]; } else { - title = [NSString stringWithFormat:NSLocalizedString( - @"Are you sure you want to remove %lu transfers from the transfer list?", - "Removal confirm panel -> title"), - selected]; + title = [NSString localizedStringWithFormat:NSLocalizedString( + @"Are you sure you want to remove %lu transfers from the transfer list?", + "Removal confirm panel -> title"), + selected]; } if (selected == active) { - message = [NSString stringWithFormat:NSLocalizedString(@"There are %lu active transfers.", "Removal confirm panel -> message part 1"), - active]; + message = [NSString localizedStringWithFormat:NSLocalizedString(@"There are %lu active transfers.", "Removal confirm panel -> message part 1"), + active]; } else { - message = [NSString stringWithFormat:NSLocalizedString(@"There are %1$lu transfers (%2$lu active).", "Removal confirm panel -> message part 1"), - selected, - active]; + message = [NSString localizedStringWithFormat:NSLocalizedString(@"There are %1$lu transfers (%2$lu active).", "Removal confirm panel -> message part 1"), + selected, + active]; } message = [message stringByAppendingFormat:@" %@", NSLocalizedString( @@ -1983,10 +1983,10 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool } else { - message = [NSString stringWithFormat:NSLocalizedString( - @"Are you sure you want to remove %lu completed transfers from the transfer list?", - "Remove completed confirm panel -> title"), - torrents.count]; + message = [NSString localizedStringWithFormat:NSLocalizedString( + @"Are you sure you want to remove %lu completed transfers from the transfer list?", + "Remove completed confirm panel -> title"), + torrents.count]; info = NSLocalizedString( @"Once removed, continuing the transfers will require the torrent files or magnet links.", @@ -2040,7 +2040,8 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool else { panel.message = [NSString - stringWithFormat:NSLocalizedString(@"Select the new folder for %lu data files.", "Move torrent -> select destination folder"), count]; + localizedStringWithFormat:NSLocalizedString(@"Select the new folder for %lu data files.", "Move torrent -> select destination folder"), + count]; } [panel beginSheetModalForWindow:self.fWindow completionHandler:^(NSInteger result) { @@ -2314,7 +2315,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool NSUInteger totalCount = self.fTorrents.count; if (totalCount != 1) { - totalTorrentsString = [NSString stringWithFormat:NSLocalizedString(@"%lu transfers", "Status bar transfer count"), totalCount]; + totalTorrentsString = [NSString localizedStringWithFormat:NSLocalizedString(@"%lu transfers", "Status bar transfer count"), totalCount]; } else { @@ -2330,7 +2331,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool } totalTorrentsString = [NSString stringWithFormat:NSLocalizedString(@"%@ of %@", "Status bar transfer count"), - [NSString formattedUInteger:count], + [NSString localizedStringWithFormat:@"%lu", count], totalTorrentsString]; } @@ -4971,13 +4972,13 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool if (seeding > 0) { - NSString* title = [NSString stringWithFormat:NSLocalizedString(@"%lu Seeding", "Dock item - Seeding"), seeding]; + NSString* title = [NSString localizedStringWithFormat:NSLocalizedString(@"%lu Seeding", "Dock item - Seeding"), seeding]; [menu addItemWithTitle:title action:nil keyEquivalent:@""]; } if (downloading > 0) { - NSString* title = [NSString stringWithFormat:NSLocalizedString(@"%lu Downloading", "Dock item - Downloading"), downloading]; + NSString* title = [NSString localizedStringWithFormat:NSLocalizedString(@"%lu Downloading", "Dock item - Downloading"), downloading]; [menu addItemWithTitle:title action:nil keyEquivalent:@""]; } diff --git a/macosx/CreatorWindowController.mm b/macosx/CreatorWindowController.mm index 5554ee420..01c1a513a 100644 --- a/macosx/CreatorWindowController.mm +++ b/macosx/CreatorWindowController.mm @@ -182,7 +182,7 @@ NSMutableSet* creatorWindowControllerSet = nil; { NSUInteger const count = self.fBuilder->fileCount(); NSString* const fileString = count != 1 ? - [NSString stringWithFormat:NSLocalizedString(@"%lu files", "Create torrent -> info"), count] : + [NSString localizedStringWithFormat:NSLocalizedString(@"%lu files", "Create torrent -> info"), count] : NSLocalizedString(@"1 file", "Create torrent -> info"); status_string = [NSString stringWithFormat:@"%@, %@", fileString, status_string]; } diff --git a/macosx/DragOverlayWindow.mm b/macosx/DragOverlayWindow.mm index 8338a7380..b6cc19309 100644 --- a/macosx/DragOverlayWindow.mm +++ b/macosx/DragOverlayWindow.mm @@ -105,7 +105,7 @@ } else { - fileString = [NSString stringWithFormat:NSLocalizedString(@"%lu files", "Drag overlay -> torrents"), fileCount]; + fileString = [NSString localizedStringWithFormat:NSLocalizedString(@"%lu files", "Drag overlay -> torrents"), fileCount]; } secondString = [NSString stringWithFormat:@"%@, %@", fileString, secondString]; } @@ -117,7 +117,7 @@ } else { - name = [NSString stringWithFormat:NSLocalizedString(@"%lu Torrent Files", "Drag overlay -> torrents"), count]; + name = [NSString localizedStringWithFormat:NSLocalizedString(@"%lu Torrent Files", "Drag overlay -> torrents"), count]; secondString = [secondString stringByAppendingString:@" total"]; icon = [NSImage imageNamed:@"TransmissionDocument.icns"]; } diff --git a/macosx/FilterButton.mm b/macosx/FilterButton.mm index b58f97adb..08f6c16ef 100644 --- a/macosx/FilterButton.mm +++ b/macosx/FilterButton.mm @@ -25,8 +25,9 @@ _count = count; - self.toolTip = count == 1 ? NSLocalizedString(@"1 transfer", "Filter Button -> tool tip") : - [NSString stringWithFormat:NSLocalizedString(@"%lu transfers", "Filter Bar Button -> tool tip"), count]; + self.toolTip = count == 1 ? + NSLocalizedString(@"1 transfer", "Filter Button -> tool tip") : + [NSString localizedStringWithFormat:NSLocalizedString(@"%lu transfers", "Filter Bar Button -> tool tip"), count]; } @end diff --git a/macosx/InfoGeneralViewController.mm b/macosx/InfoGeneralViewController.mm index 5ea754b68..d1385255e 100644 --- a/macosx/InfoGeneralViewController.mm +++ b/macosx/InfoGeneralViewController.mm @@ -160,9 +160,9 @@ { Torrent* torrent = self.fTorrents[0]; -#warning candidate for localizedStringWithFormat (although then we'll get two commas) + // Associated Press Style: "Use a semicolon to clarify a series that includes a number of commas." NSString* piecesString = !torrent.magnet ? - [NSString stringWithFormat:@"%ld, %@", torrent.pieceCount, [NSString stringForFileSize:torrent.pieceSize]] : + [NSString localizedStringWithFormat:@"%ld; %@", torrent.pieceCount, [NSString stringForFileSize:torrent.pieceSize]] : @""; self.fPiecesField.stringValue = piecesString; diff --git a/macosx/InfoPeersViewController.mm b/macosx/InfoPeersViewController.mm index 7bc8d292e..c2860061a 100644 --- a/macosx/InfoPeersViewController.mm +++ b/macosx/InfoPeersViewController.mm @@ -187,7 +187,8 @@ static NSString* const kWebSeedAnimationId = @"webSeed"; } else { - connectedText = [NSString stringWithFormat:NSLocalizedString(@"%lu Connected", "Inspector -> Peers tab -> peers"), connected]; + connectedText = [NSString + localizedStringWithFormat:NSLocalizedString(@"%lu Connected", "Inspector -> Peers tab -> peers"), connected]; } if (connected > 0) @@ -196,12 +197,12 @@ static NSString* const kWebSeedAnimationId = @"webSeed"; if (toUs > 0) { [upDownComponents - addObject:[NSString stringWithFormat:NSLocalizedString(@"DL from %lu", "Inspector -> Peers tab -> peers"), toUs]]; + addObject:[NSString localizedStringWithFormat:NSLocalizedString(@"DL from %lu", "Inspector -> Peers tab -> peers"), toUs]]; } if (fromUs > 0) { [upDownComponents - addObject:[NSString stringWithFormat:NSLocalizedString(@"UL to %lu", "Inspector -> Peers tab -> peers"), fromUs]]; + addObject:[NSString localizedStringWithFormat:NSLocalizedString(@"UL to %lu", "Inspector -> Peers tab -> peers"), fromUs]]; } if (upDownComponents.count > 0) { @@ -211,38 +212,38 @@ static NSString* const kWebSeedAnimationId = @"webSeed"; NSMutableArray* fromComponents = [NSMutableArray arrayWithCapacity:7]; if (tracker > 0) { - [fromComponents - addObject:[NSString stringWithFormat:NSLocalizedString(@"%lu tracker", "Inspector -> Peers tab -> peers"), tracker]]; + [fromComponents addObject:[NSString localizedStringWithFormat:NSLocalizedString(@"%lu tracker", "Inspector -> Peers tab -> peers"), + tracker]]; } if (incoming > 0) { - [fromComponents - addObject:[NSString stringWithFormat:NSLocalizedString(@"%lu incoming", "Inspector -> Peers tab -> peers"), incoming]]; + [fromComponents addObject:[NSString localizedStringWithFormat:NSLocalizedString(@"%lu incoming", "Inspector -> Peers tab -> peers"), + incoming]]; } if (cache > 0) { [fromComponents - addObject:[NSString stringWithFormat:NSLocalizedString(@"%lu cache", "Inspector -> Peers tab -> peers"), cache]]; + addObject:[NSString localizedStringWithFormat:NSLocalizedString(@"%lu cache", "Inspector -> Peers tab -> peers"), cache]]; } if (lpd > 0) { - [fromComponents - addObject:[NSString stringWithFormat:NSLocalizedString(@"%lu local discovery", "Inspector -> Peers tab -> peers"), lpd]]; + [fromComponents addObject:[NSString localizedStringWithFormat:NSLocalizedString(@"%lu local discovery", "Inspector -> Peers tab -> peers"), + lpd]]; } if (pex > 0) { [fromComponents - addObject:[NSString stringWithFormat:NSLocalizedString(@"%lu PEX", "Inspector -> Peers tab -> peers"), pex]]; + addObject:[NSString localizedStringWithFormat:NSLocalizedString(@"%lu PEX", "Inspector -> Peers tab -> peers"), pex]]; } if (dht > 0) { [fromComponents - addObject:[NSString stringWithFormat:NSLocalizedString(@"%lu DHT", "Inspector -> Peers tab -> peers"), dht]]; + addObject:[NSString localizedStringWithFormat:NSLocalizedString(@"%lu DHT", "Inspector -> Peers tab -> peers"), dht]]; } if (ltep > 0) { [fromComponents - addObject:[NSString stringWithFormat:NSLocalizedString(@"%lu LTEP", "Inspector -> Peers tab -> peers"), ltep]]; + addObject:[NSString localizedStringWithFormat:NSLocalizedString(@"%lu LTEP", "Inspector -> Peers tab -> peers"), ltep]]; } connectedText = [connectedText stringByAppendingFormat:@"\n%@", [fromComponents componentsJoinedByString:@", "]]; diff --git a/macosx/InfoTrackersViewController.mm b/macosx/InfoTrackersViewController.mm index b2ee35efd..5ac0b1dd3 100644 --- a/macosx/InfoTrackersViewController.mm +++ b/macosx/InfoTrackersViewController.mm @@ -410,8 +410,8 @@ typedef NS_ENUM(NSInteger, TrackerSegmentTag) { if (removeTrackerCount > 1) { alert.messageText = [NSString - stringWithFormat:NSLocalizedString(@"Are you sure you want to remove %lu trackers?", "Remove trackers alert -> title"), - removeTrackerCount]; + localizedStringWithFormat:NSLocalizedString(@"Are you sure you want to remove %lu trackers?", "Remove trackers alert -> title"), + removeTrackerCount]; alert.informativeText = NSLocalizedString( @"Once removed, Transmission will no longer attempt to contact them." " This cannot be undone.", diff --git a/macosx/InfoWindowController.mm b/macosx/InfoWindowController.mm index 58afbfdf5..f43c60677 100644 --- a/macosx/InfoWindowController.mm +++ b/macosx/InfoWindowController.mm @@ -504,7 +504,7 @@ typedef NS_ENUM(unsigned int, tabTag) { self.fImageView.image = [NSImage imageNamed:NSImageNameMultipleDocuments]; self.fNameField.stringValue = [NSString - stringWithFormat:NSLocalizedString(@"%lu Torrents Selected", "Inspector -> selected torrents"), numberSelected]; + localizedStringWithFormat:NSLocalizedString(@"%lu Torrents Selected", "Inspector -> selected torrents"), numberSelected]; self.fNameField.hidden = NO; uint64_t size = 0; @@ -529,7 +529,8 @@ typedef NS_ENUM(unsigned int, tabTag) { } else { - fileString = [NSString stringWithFormat:NSLocalizedString(@"%lu files", "Inspector -> selected torrents"), fileCount]; + fileString = [NSString + localizedStringWithFormat:NSLocalizedString(@"%lu files", "Inspector -> selected torrents"), fileCount]; } [fileStrings addObject:fileString]; } @@ -543,7 +544,7 @@ typedef NS_ENUM(unsigned int, tabTag) { else { magnetString = [NSString - stringWithFormat:NSLocalizedString(@"%lu magnetized transfers", "Inspector -> selected torrents"), magnetCount]; + localizedStringWithFormat:NSLocalizedString(@"%lu magnetized transfers", "Inspector -> selected torrents"), magnetCount]; } [fileStrings addObject:magnetString]; } @@ -606,7 +607,8 @@ typedef NS_ENUM(unsigned int, tabTag) { } else { - fileString = [NSString stringWithFormat:NSLocalizedString(@"%lu files", "Inspector -> selected torrents"), fileCount]; + fileString = [NSString + localizedStringWithFormat:NSLocalizedString(@"%lu files", "Inspector -> selected torrents"), fileCount]; } basicString = [NSString stringWithFormat:@"%@, %@", fileString, basicString]; } diff --git a/macosx/NSStringAdditions.h b/macosx/NSStringAdditions.h index e41de4298..77ad3409f 100644 --- a/macosx/NSStringAdditions.h +++ b/macosx/NSStringAdditions.h @@ -9,8 +9,6 @@ @property(nonatomic, class, readonly) NSString* ellipsis; @property(nonatomic, readonly, copy) NSString* stringByAppendingEllipsis; -+ (NSString*)formattedUInteger:(NSUInteger)value; - + (NSString*)stringForFileSize:(uint64_t)size; + (NSString*)stringForFilePartialSize:(uint64_t)partialSize fullSize:(uint64_t)fullSize; diff --git a/macosx/NSStringAdditions.mm b/macosx/NSStringAdditions.mm index 4a15b5af7..8c81f7a92 100644 --- a/macosx/NSStringAdditions.mm +++ b/macosx/NSStringAdditions.mm @@ -25,12 +25,6 @@ return [self stringByAppendingString:NSString.ellipsis]; } -#warning use localizedStringWithFormat: directly when 10.9-only and stringsdict translations are in place -+ (NSString*)formattedUInteger:(NSUInteger)value -{ - return [NSString localizedStringWithFormat:@"%lu", value]; -} - // Maximum supported localization is 9.22 EB, which is the maximum supported filesystem size by macOS, 8 EiB. // https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/VolumeFormatComparison/VolumeFormatComparison.html + (NSString*)stringForFileSize:(uint64_t)size @@ -44,7 +38,7 @@ { NSByteCountFormatter* fileSizeFormatter = [[NSByteCountFormatter alloc] init]; - NSString* fullString = [fileSizeFormatter stringFromByteCount:fullSize]; + NSString* fullSizeString = [fileSizeFormatter stringFromByteCount:fullSize]; //figure out the magnitude of the two, since we can't rely on comparing the units because of localization and pluralization issues (for example, "1 byte of 2 bytes") BOOL partialUnitsSame; @@ -61,9 +55,9 @@ } fileSizeFormatter.includesUnit = !partialUnitsSame; - NSString* partialString = [fileSizeFormatter stringFromByteCount:partialSize]; + NSString* partialSizeString = [fileSizeFormatter stringFromByteCount:partialSize]; - return [NSString stringWithFormat:NSLocalizedString(@"%@ of %@", "file size string"), partialString, fullString]; + return [NSString stringWithFormat:NSLocalizedString(@"%@ of %@", "file size string"), partialSizeString, fullSizeString]; } + (NSString*)stringForSpeed:(CGFloat)speed diff --git a/macosx/PrefsController.mm b/macosx/PrefsController.mm index a66c6eab9..374a165dd 100644 --- a/macosx/PrefsController.mm +++ b/macosx/PrefsController.mm @@ -607,8 +607,8 @@ static NSString* const kWebUIURLFormat = @"http://localhost:%ld/"; if (exists) { self.fBlocklistMessageField.stringValue = [NSString - stringWithFormat:NSLocalizedString(@"%lu IP address rules in list", "Prefs -> blocklist -> message"), - tr_blocklistGetRuleCount(self.fHandle)]; + localizedStringWithFormat:NSLocalizedString(@"%lu IP address rules in list", "Prefs -> blocklist -> message"), + tr_blocklistGetRuleCount(self.fHandle)]; } else { diff --git a/macosx/QuickLookPlugin/GeneratePreviewForURL.mm b/macosx/QuickLookPlugin/GeneratePreviewForURL.mm index e88038ecc..0c7b55c13 100644 --- a/macosx/QuickLookPlugin/GeneratePreviewForURL.mm +++ b/macosx/QuickLookPlugin/GeneratePreviewForURL.mm @@ -86,7 +86,7 @@ OSStatus GeneratePreviewForURL(void* thisInterface, QLPreviewRequestRef preview, if (is_multifile) { NSString* fileCountString = [NSString - stringWithFormat:NSLocalizedStringFromTableInBundle(@"%lu files", nil, bundle, "quicklook file count"), n_files]; + localizedStringWithFormat:NSLocalizedStringFromTableInBundle(@"%lu files", nil, bundle, "quicklook file count"), n_files]; fileSizeString = [NSString stringWithFormat:@"%@, %@", fileCountString, fileSizeString]; } [htmlString appendFormat:@"

%@

", fileSizeString]; @@ -143,7 +143,8 @@ OSStatus GeneratePreviewForURL(void* thisInterface, QLPreviewRequestRef preview, NSString* headerTitleString = n_webseeds == 1 ? NSLocalizedStringFromTableInBundle(@"1 Web Seed", nil, bundle, "quicklook web seed header") : - [NSString stringWithFormat:NSLocalizedStringFromTableInBundle(@"%lu Web Seeds", nil, bundle, "quicklook web seed header"), n_webseeds]; + [NSString localizedStringWithFormat:NSLocalizedStringFromTableInBundle(@"%lu Web Seeds", nil, bundle, "quicklook web seed header"), + n_webseeds]; [listSection appendFormat:@"", headerTitleString]; for (size_t i = 0; i < n_webseeds; ++i) @@ -165,7 +166,7 @@ OSStatus GeneratePreviewForURL(void* thisInterface, QLPreviewRequestRef preview, auto const n = std::size(announce_list); NSString* headerTitleString = n == 1 ? NSLocalizedStringFromTableInBundle(@"1 Tracker", nil, bundle, "quicklook tracker header") : - [NSString stringWithFormat:NSLocalizedStringFromTableInBundle(@"%lu Trackers", nil, bundle, "quicklook tracker header"), n]; + [NSString localizedStringWithFormat:NSLocalizedStringFromTableInBundle(@"%lu Trackers", nil, bundle, "quicklook tracker header"), n]; [listSection appendFormat:@"", headerTitleString]; #warning handle tiers? @@ -185,7 +186,7 @@ OSStatus GeneratePreviewForURL(void* thisInterface, QLPreviewRequestRef preview, [listSection appendString:@"
%@
%@
"]; NSString* fileTitleString = [NSString - stringWithFormat:NSLocalizedStringFromTableInBundle(@"%lu Files", nil, bundle, "quicklook file header"), n_files]; + localizedStringWithFormat:NSLocalizedStringFromTableInBundle(@"%lu Files", nil, bundle, "quicklook file header"), n_files]; [listSection appendFormat:@"", fileTitleString]; #warning display folders? diff --git a/macosx/StatsWindowController.mm b/macosx/StatsWindowController.mm index e72a2f580..f363e858b 100644 --- a/macosx/StatsWindowController.mm +++ b/macosx/StatsWindowController.mm @@ -222,7 +222,7 @@ tr_session* fLib = NULL; else { self.fNumOpenedField.stringValue = [NSString - stringWithFormat:NSLocalizedString(@"%llu times", "stats window -> times opened"), statsAll.sessionCount]; + localizedStringWithFormat:NSLocalizedString(@"%llu times", "stats window -> times opened"), statsAll.sessionCount]; } } diff --git a/macosx/StatusBarController.mm b/macosx/StatusBarController.mm index bdb22cdb9..9dfee6c08 100644 --- a/macosx/StatusBarController.mm +++ b/macosx/StatusBarController.mm @@ -166,8 +166,8 @@ typedef NS_ENUM(unsigned int, statusTag) { { if ([NSUserDefaults.standardUserDefaults boolForKey:@"CheckUpload"]) { - uploadText = [NSString stringWithFormat:NSLocalizedString(@"%ld KB/s", "Status Bar -> speed tooltip"), - [NSUserDefaults.standardUserDefaults integerForKey:@"UploadLimit"]]; + uploadText = [NSString localizedStringWithFormat:NSLocalizedString(@"%ld KB/s", "Status Bar -> speed tooltip"), + [NSUserDefaults.standardUserDefaults integerForKey:@"UploadLimit"]]; } else { @@ -176,8 +176,8 @@ typedef NS_ENUM(unsigned int, statusTag) { if ([NSUserDefaults.standardUserDefaults boolForKey:@"CheckDownload"]) { - downloadText = [NSString stringWithFormat:NSLocalizedString(@"%ld KB/s", "Status Bar -> speed tooltip"), - [NSUserDefaults.standardUserDefaults integerForKey:@"DownloadLimit"]]; + downloadText = [NSString localizedStringWithFormat:NSLocalizedString(@"%ld KB/s", "Status Bar -> speed tooltip"), + [NSUserDefaults.standardUserDefaults integerForKey:@"DownloadLimit"]]; } else { diff --git a/macosx/Torrent.mm b/macosx/Torrent.mm index dc14988f7..2e144b1c4 100644 --- a/macosx/Torrent.mm +++ b/macosx/Torrent.mm @@ -1107,11 +1107,11 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error) break; case TR_STATUS_DOWNLOAD: - if (self.totalPeersConnected != 1) + if (NSUInteger const totalPeersCount = self.totalPeersConnected; totalPeersCount != 1) { - string = [NSString stringWithFormat:NSLocalizedString(@"Downloading from %lu of %lu peers", "Torrent -> status string"), - self.peersSendingToUs, - self.totalPeersConnected]; + string = [NSString localizedStringWithFormat:NSLocalizedString(@"Downloading from %lu of %lu peers", "Torrent -> status string"), + self.peersSendingToUs, + totalPeersCount]; } else { @@ -1122,13 +1122,14 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error) if (NSUInteger const webSeedCount = self.fStat->webseedsSendingToUs; webSeedCount > 0) { NSString* webSeedString; - if (webSeedCount == 1) + if (webSeedCount != 1) { - webSeedString = NSLocalizedString(@"web seed", "Torrent -> status string"); + webSeedString = [NSString + localizedStringWithFormat:NSLocalizedString(@"%lu web seeds", "Torrent -> status string"), webSeedCount]; } else { - webSeedString = [NSString stringWithFormat:NSLocalizedString(@"%lu web seeds", "Torrent -> status string"), webSeedCount]; + webSeedString = NSLocalizedString(@"web seed", "Torrent -> status string"); } string = [string stringByAppendingFormat:@" + %@", webSeedString]; @@ -1137,14 +1138,18 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error) break; case TR_STATUS_SEED: - if (self.totalPeersConnected != 1) + if (NSUInteger const totalPeersCount = self.totalPeersConnected; totalPeersCount != 1) { - string = [NSString stringWithFormat:NSLocalizedString(@"Seeding to %1$lu of %2$lu peers", "Torrent -> status string"), - self.peersGettingFromUs, - self.totalPeersConnected]; + string = [NSString localizedStringWithFormat:NSLocalizedString(@"Seeding to %1$lu of %2$lu peers", "Torrent -> status string"), + self.peersGettingFromUs, + totalPeersCount]; } else { + // TODO: "%lu of 1" vs "%u of 1" disparity + // - either change "Downloading from %lu of 1 peer" to "Downloading from %u of 1 peer" + // - or change "Seeding to %u of 1 peer" to "Seeding to %lu of 1 peer" + // then update Transifex accordingly string = [NSString stringWithFormat:NSLocalizedString(@"Seeding to %u of 1 peer", "Torrent -> status string"), (unsigned int)self.peersGettingFromUs]; } diff --git a/macosx/TorrentTableView.mm b/macosx/TorrentTableView.mm index 6e6424532..8b792032b 100644 --- a/macosx/TorrentTableView.mm +++ b/macosx/TorrentTableView.mm @@ -257,7 +257,7 @@ static NSTimeInterval const kToggleProgressSeconds = 0.175; } else { - return [NSString stringWithFormat:NSLocalizedString(@"%lu transfers", "Torrent table -> group row -> tooltip"), count]; + return [NSString localizedStringWithFormat:NSLocalizedString(@"%lu transfers", "Torrent table -> group row -> tooltip"), count]; } } else @@ -817,17 +817,17 @@ static NSTimeInterval const kToggleProgressSeconds = 0.175; NSMenuItem* item; if (menu.numberOfItems == 3) { - NSInteger const speedLimitActionValue[] = { 50, 100, 250, 500, 1000, 2500, 5000, 10000, -1 }; + static NSArray* const speedLimitActionValues = @[ @50, @100, @250, @500, @1000, @2500, @5000, @10000 ]; - for (NSInteger i = 0; speedLimitActionValue[i] != -1; i++) + for (NSNumber* i in speedLimitActionValues) { item = [[NSMenuItem alloc] - initWithTitle:[NSString stringWithFormat:NSLocalizedString(@"%ld KB/s", "Action menu -> upload/download limit"), - speedLimitActionValue[i]] + initWithTitle:[NSString localizedStringWithFormat:NSLocalizedString(@"%ld KB/s", "Action menu -> upload/download limit"), + i.integerValue] action:@selector(setQuickLimit:) keyEquivalent:@""]; item.target = self; - item.representedObject = @(speedLimitActionValue[i]); + item.representedObject = i; [menu addItem:item]; } } @@ -837,8 +837,8 @@ static NSTimeInterval const kToggleProgressSeconds = 0.175; item = [menu itemWithTag:ActionMenuTagLimit]; item.state = limit ? NSControlStateValueOn : NSControlStateValueOff; - item.title = [NSString stringWithFormat:NSLocalizedString(@"Limit (%ld KB/s)", "torrent action menu -> upload/download limit"), - [self.fMenuTorrent speedLimit:upload]]; + item.title = [NSString localizedStringWithFormat:NSLocalizedString(@"Limit (%ld KB/s)", "torrent action menu -> upload/download limit"), + [self.fMenuTorrent speedLimit:upload]]; item = [menu itemWithTag:ActionMenuTagUnlimited]; item.state = !limit ? NSControlStateValueOn : NSControlStateValueOff; @@ -848,15 +848,15 @@ static NSTimeInterval const kToggleProgressSeconds = 0.175; NSMenuItem* item; if (menu.numberOfItems == 4) { - float const ratioLimitActionValue[] = { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, -1.0 }; + static NSArray* const ratioLimitActionValue = @[ @0.25, @0.5, @0.75, @1.0, @1.5, @2.0, @3.0 ]; - for (NSInteger i = 0; ratioLimitActionValue[i] != -1.0; i++) + for (NSNumber* i in ratioLimitActionValue) { - item = [[NSMenuItem alloc] initWithTitle:[NSString localizedStringWithFormat:@"%.2f", ratioLimitActionValue[i]] + item = [[NSMenuItem alloc] initWithTitle:[NSString localizedStringWithFormat:@"%.2f", i.floatValue] action:@selector(setQuickRatio:) keyEquivalent:@""]; item.target = self; - item.representedObject = @(ratioLimitActionValue[i]); + item.representedObject = i; [menu addItem:item]; } } diff --git a/macosx/TrackerCell.mm b/macosx/TrackerCell.mm index 8803c4cd2..d2993361f 100644 --- a/macosx/TrackerCell.mm +++ b/macosx/TrackerCell.mm @@ -297,7 +297,8 @@ NSMutableSet* fTrackerIconLoading; - (NSAttributedString*)attributedCount:(NSInteger)count { - NSString* countString = count != -1 ? [NSString stringWithFormat:@"%ld", count] : NSLocalizedString(@"N/A", "tracker peer stat"); + NSString* countString = count != -1 ? [NSString localizedStringWithFormat:@"%ld", count] : + NSLocalizedString(@"N/A", "tracker peer stat"); return [[NSAttributedString alloc] initWithString:countString attributes:self.fStatusAttributes]; } diff --git a/macosx/TrackerNode.mm b/macosx/TrackerNode.mm index bf56ed00e..6fc0b1e6e 100644 --- a/macosx/TrackerNode.mm +++ b/macosx/TrackerNode.mm @@ -139,8 +139,8 @@ } else { - peerString = [NSString stringWithFormat:NSLocalizedString(@"got %lu peers", "Tracker last announce"), - (size_t)self.fStat.lastAnnouncePeerCount]; + peerString = [NSString localizedStringWithFormat:NSLocalizedString(@"got %lu peers", "Tracker last announce"), + (size_t)self.fStat.lastAnnouncePeerCount]; } baseString = [baseString stringByAppendingFormat:@" (%@)", peerString]; }
%@