From 72d0964ffce928a1bc8dc8211bd55d6292744f17 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Tue, 24 Oct 2006 20:34:13 +0000 Subject: [PATCH] =?UTF-8?q?Use=20localized=20strings=20where=20necessary.?= =?UTF-8?q?=20Also=20a=20fix=20for=20the=20port=20checker.=20Thanks=20to?= =?UTF-8?q?=20Ce=CC=81dric=20Luthi=20for=20these.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Transmission.xcodeproj/project.pbxproj | 12 + macosx/Controller.m | 116 ++++---- macosx/English.lproj/Localizable.strings | 362 +++++++++++++++++++++++ macosx/InfoWindowController.m | 30 +- macosx/MessageWindowController.m | 8 +- macosx/PiecesView.m | 6 +- macosx/PortChecker.m | 11 +- macosx/PrefsController.m | 22 +- macosx/StringAdditions.m | 10 +- macosx/Torrent.m | 82 ++--- 10 files changed, 530 insertions(+), 129 deletions(-) create mode 100644 macosx/English.lproj/Localizable.strings diff --git a/Transmission.xcodeproj/project.pbxproj b/Transmission.xcodeproj/project.pbxproj index b66e35fcd..dc0dac21c 100644 --- a/Transmission.xcodeproj/project.pbxproj +++ b/Transmission.xcodeproj/project.pbxproj @@ -92,6 +92,7 @@ A21610FC0A050B1700E8E4C1 /* MenuButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A21610FB0A050B1700E8E4C1 /* MenuButton.m */; }; A2173E1C0A33C1B300B0D8AB /* ActionButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.png */; }; A21DFF100A292B2B007C5F76 /* Transfers.png in Resources */ = {isa = PBXBuildFile; fileRef = A21DFF0F0A292B2B007C5F76 /* Transfers.png */; }; + A22A8D560AEEAFA5007E9CB9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A22A8D540AEEAFA5007E9CB9 /* Localizable.strings */; }; A2305A800A3DC9E400AB2D77 /* ProgressBarWhite.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A7C0A3DC9E400AB2D77 /* ProgressBarWhite.png */; }; A2305A810A3DC9E400AB2D77 /* ProgressBarBlue.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A7D0A3DC9E400AB2D77 /* ProgressBarBlue.png */; }; A2305A820A3DC9E400AB2D77 /* ProgressBarGray.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A7E0A3DC9E400AB2D77 /* ProgressBarGray.png */; }; @@ -316,6 +317,7 @@ A21610FB0A050B1700E8E4C1 /* MenuButton.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MenuButton.m; path = macosx/MenuButton.m; sourceTree = ""; }; A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ActionButtonPressed.png; path = macosx/Images/ActionButtonPressed.png; sourceTree = ""; }; A21DFF0F0A292B2B007C5F76 /* Transfers.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Transfers.png; path = macosx/Images/Transfers.png; sourceTree = ""; }; + A22A8D550AEEAFA5007E9CB9 /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = macosx/English.lproj/Localizable.strings; sourceTree = ""; }; A2305A7C0A3DC9E400AB2D77 /* ProgressBarWhite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarWhite.png; path = macosx/Images/ProgressBarWhite.png; sourceTree = ""; }; A2305A7D0A3DC9E400AB2D77 /* ProgressBarBlue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarBlue.png; path = macosx/Images/ProgressBarBlue.png; sourceTree = ""; }; A2305A7E0A3DC9E400AB2D77 /* ProgressBarGray.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarGray.png; path = macosx/Images/ProgressBarGray.png; sourceTree = ""; }; @@ -496,6 +498,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + A22A8D540AEEAFA5007E9CB9 /* Localizable.strings */, A259316A0A73B2CC002F4FE7 /* Transmission Help */, A2F8951E0A2D4BA500ED2127 /* Credits.rtf */, A2305AA40A3DCCEF00AB2D77 /* ProgressBarEndAdvanced.png */, @@ -852,6 +855,7 @@ 35B038130AC5B6EB00A10FDF /* ResumeNoWaitOn.png in Resources */, 35B038140AC5B6EC00A10FDF /* ResumeNoWaitOff.png in Resources */, A29C8B330ACC6E93000ED9F9 /* YellowDot.tiff in Resources */, + A22A8D560AEEAFA5007E9CB9 /* Localizable.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -969,6 +973,14 @@ name = MessageWindow.nib; sourceTree = ""; }; + A22A8D540AEEAFA5007E9CB9 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + A22A8D550AEEAFA5007E9CB9 /* English */, + ); + name = Localizable.strings; + sourceTree = ""; + }; A2912C520A2956E80097A0CA /* PrefsWindow.nib */ = { isa = PBXVariantGroup; children = ( diff --git a/macosx/Controller.m b/macosx/Controller.m index 64ea29e58..30650cab2 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -201,8 +201,8 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy ? fSpeedLimitBlueImage : fSpeedLimitGraphiteImage]; } - [fActionButton setToolTip: @"Shortcuts for changing global settings."]; - [fSpeedLimitButton setToolTip: @"Speed Limit overrides the total bandwidth limits with its own limits."]; + [fActionButton setToolTip: NSLocalizedString(@"Shortcuts for changing global settings.", "Main window -> 1st bottom left button (action) tooltip")]; + [fSpeedLimitButton setToolTip: NSLocalizedString(@"Speed Limit overrides the total bandwidth limits with its own limits.", "Main window -> 2nd bottom left button (turtle) tooltip")]; [fTableView setTorrents: fDisplayedTorrents]; [[fTableView tableColumnWithIdentifier: @"Torrent"] setDataCell: [[TorrentCell alloc] init]]; @@ -277,7 +277,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [currentFilterButton setEnabled: YES]; //set upload limit action button - [fUploadLimitItem setTitle: [NSString stringWithFormat: @"Limit (%d KB/s)", + [fUploadLimitItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Limit (%d KB/s)", "Action context menu -> upload limit"), [fDefaults integerForKey: @"UploadLimit"]]]; if ([fDefaults boolForKey: @"CheckUpload"]) [fUploadLimitItem setState: NSOnState]; @@ -285,7 +285,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [fUploadNoLimitItem setState: NSOnState]; //set download limit action menu - [fDownloadLimitItem setTitle: [NSString stringWithFormat: @"Limit (%d KB/s)", + [fDownloadLimitItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Limit (%d KB/s)", "Action context menu -> download limit"), [fDefaults integerForKey: @"DownloadLimit"]]]; if ([fDefaults boolForKey: @"CheckDownload"]) [fDownloadLimitItem setState: NSOnState]; @@ -293,7 +293,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [fDownloadNoLimitItem setState: NSOnState]; //set ratio action menu - [fRatioSetItem setTitle: [NSString stringWithFormat: @"Stop at Ratio (%.2f)", + [fRatioSetItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Stop at Ratio (%.2f)", "Action context menu -> ratio stop"), [fDefaults floatForKey: @"RatioLimit"]]]; if ([fDefaults boolForKey: @"RatioCheck"]) [fRatioSetItem setState: NSOnState]; @@ -394,11 +394,11 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy if ([fDefaults boolForKey: @"CheckQuitDownloading"] ? downloading > 0 : active > 0) { NSString * message = active == 1 - ? @"There is an active transfer. Do you really want to quit?" + ? NSLocalizedString(@"There is an active transfer. Do you really want to quit?", "Confirm Quit panel -> message") : [NSString stringWithFormat: - @"There are %d active transfers. Do you really want to quit?", active]; + NSLocalizedString(@"There are %d active transfers. Do you really want to quit?", "Confirm Quit panel -> message"), active]; - NSBeginAlertSheet(@"Confirm Quit", @"Quit", @"Cancel", nil, fWindow, self, + NSBeginAlertSheet(NSLocalizedString(@"Confirm Quit", "Confirm Quit panel -> title"), NSLocalizedString(@"Quit", "Confirm Quit panel -> button"), NSLocalizedString(@"Cancel", "Confirm Quit panel -> button"), nil, fWindow, self, @selector(quitSheetDidEnd:returnCode:contextInfo:), nil, nil, message); return NSTerminateLater; } @@ -541,7 +541,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [panel setCanChooseFiles: NO]; [panel setCanChooseDirectories: YES]; - [panel setMessage: [NSString stringWithFormat: @"Select the download folder for \"%@\"", [torrent name]]]; + [panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the download folder for \"%@\"", "Open torrent -> select destination folder"), [torrent name]]]; NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: torrent, @"Torrent", files, @"Files", nil]; @@ -725,25 +725,25 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy int selected = [fTableView numberOfSelectedRows]; if (selected == 1) { - title = [NSString stringWithFormat: @"Comfirm Removal of \"%@\"", + title = [NSString stringWithFormat: NSLocalizedString(@"Confirm Removal of \"%@\"", "Removal confirm panel -> title"), [[fDisplayedTorrents objectAtIndex: [fTableView selectedRow]] name]]; - message = @"This transfer is active." + message = NSLocalizedString(@"This transfer is active." " Once removed, continuing the transfer will require the torrent file." - " Do you really want to remove it?"; + " Do you really want to remove it?", "Removal confirm panel -> message"); } else { - title = [NSString stringWithFormat: @"Comfirm Removal of %d Transfers", selected]; + title = [NSString stringWithFormat: NSLocalizedString(@"Confirm Removal of %d Transfers", "Removal confirm panel -> title"), selected]; if (selected == active) - message = [NSString stringWithFormat: @"There are %d active transfers.", active]; + message = [NSString stringWithFormat: NSLocalizedString(@"There are %d active transfers.", "Removal confirm panel -> message part 1"), active]; else - message = [NSString stringWithFormat: @"There are %d transfers (%d active).", selected, active]; + message = [NSString stringWithFormat: NSLocalizedString(@"There are %d transfers (%d active).", "Removal confirm panel -> message part 1"), selected, active]; message = [message stringByAppendingString: - @" Once removed, continuing the transfers will require the torrent files." - " Do you really want to remove them?"]; + NSLocalizedString(@" Once removed, continuing the transfers will require the torrent files." + " Do you really want to remove them?", "Removal confirm panel -> message part 2")]; } - NSBeginAlertSheet(title, @"Remove", @"Cancel", nil, fWindow, self, + NSBeginAlertSheet(title, NSLocalizedString(@"Remove", "Removal confirm panel -> button"), NSLocalizedString(@"Cancel", "Removal confirm panel -> button"), nil, fWindow, self, nil, @selector(removeSheetDidEnd:returnCode:contextInfo:), dict, message); return; } @@ -864,10 +864,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy if (![[NSFileManager defaultManager] fileExistsAtPath: [torrent torrentLocation]]) { NSAlert * alert = [[NSAlert alloc] init]; - [alert addButtonWithTitle: @"OK"]; - [alert setMessageText: [NSString stringWithFormat: @"Copy of \"%@\" Cannot Be Created", [torrent name]]]; + [alert addButtonWithTitle: NSLocalizedString(@"OK", "Torrent file copy alert -> button")]; + [alert setMessageText: [NSString stringWithFormat: NSLocalizedString(@"Copy of \"%@\" Cannot Be Created", "Torrent file copy alert -> title"), [torrent name]]]; [alert setInformativeText: [NSString stringWithFormat: - @"The torrent file (%@) cannot be found.", [torrent torrentLocation]]]; + NSLocalizedString(@"The torrent file (%@) cannot be found.", "Torrent file copy alert -> message"), [torrent torrentLocation]]]; [alert setAlertStyle: NSWarningAlertStyle]; [alert runModal]; @@ -960,8 +960,8 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy tr_torrentRates(fLib, & downloadRate, & uploadRate); if (![fStatusBar isHidden]) { - [fTotalDLField setStringValue: [@"Total DL: " stringByAppendingString: [NSString stringForSpeed: downloadRate]]]; - [fTotalULField setStringValue: [@"Total UL: " stringByAppendingString: [NSString stringForSpeed: uploadRate]]]; + [fTotalDLField setStringValue: [NSLocalizedString(@"Total DL: ", "Status bar -> total download") stringByAppendingString: [NSString stringForSpeed: downloadRate]]]; + [fTotalULField setStringValue: [NSLocalizedString(@"Total UL: ", "Status bar -> total upload") stringByAppendingString: [NSString stringForSpeed: uploadRate]]]; } //update non-constant parts of info window @@ -986,7 +986,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [sound play]; } - [GrowlApplicationBridge notifyWithTitle: @"Download Complete" description: [torrent name] + [GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Download Complete", "Growl notification title") description: [torrent name] notificationName: GROWL_DOWNLOAD_COMPLETE iconData: nil priority: 0 isSticky: NO clickContext: nil]; if (![fWindow isKeyWindow]) @@ -1228,7 +1228,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [totalTorrentsString appendFormat: @"%d/", [fDisplayedTorrents count]]; int totalCount = [fTorrents count]; - [totalTorrentsString appendFormat: @"%d Transfer%s", totalCount, totalCount == 1 ? "" : "s"]; + if (totalCount > 1) + [totalTorrentsString appendFormat: NSLocalizedString(@"%d Transfers", "Status bar transfer count"), totalCount]; + else + [totalTorrentsString appendFormat: NSLocalizedString(@"%d Transfer", "Status bar transfer count"), totalCount]; [fTotalTorrentsField setStringValue: totalTorrentsString]; @@ -1334,8 +1337,9 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [self toggleSpeedLimit: nil]; [GrowlApplicationBridge notifyWithTitle: fSpeedLimitEnabled - ? @"Speed Limit Auto Enabled" : @"Speed Limit Auto Disabled" - description: @"Bandwidth settings changed" + ? NSLocalizedString(@"Speed Limit Auto Enabled", "Growl notification title") + : NSLocalizedString(@"Speed Limit Auto Disabled", "Growl notification title") + description: NSLocalizedString(@"Bandwidth settings changed", "Growl notification description") notificationName: GROWL_AUTO_SPEED_LIMIT iconData: nil priority: 0 isSticky: NO clickContext: nil]; } } @@ -1372,7 +1376,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [limitItem setState: enable ? NSOnState : NSOffState]; [noLimitItem setState: !enable ? NSOnState : NSOffState]; - [limitItem setTitle: [NSString stringWithFormat: @"Limit (%d KB/s)", + [limitItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Limit (%d KB/s)", "Action context menu -> upload/download limit"), [[dict objectForKey: @"Limit"] intValue]]]; [dict release]; @@ -1396,7 +1400,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [fRatioSetItem setState: enable ? NSOnState : NSOffState]; [fRatioNotSetItem setState: !enable ? NSOnState : NSOffState]; - [fRatioSetItem setTitle: [NSString stringWithFormat: @"Stop at Ratio (%.2f)", + [fRatioSetItem setTitle: [NSString stringWithFormat: NSLocalizedString(@"Stop at Ratio (%.2f)", "Action context menu -> ratio stop"), [[dict objectForKey: @"Ratio"] floatValue]]]; [dict release]; @@ -1487,7 +1491,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [sound play]; } - [GrowlApplicationBridge notifyWithTitle: @"Seeding Complete" description: [[notification object] name] + [GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Seeding Complete", "Growl notification title") description: [[notification object] name] notificationName: GROWL_SEEDING_COMPLETE iconData: nil priority: 0 isSticky: NO clickContext: nil]; } @@ -1597,7 +1601,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy //import only actually happened if the torrent array is larger if (oldCount < [fTorrents count]) - [GrowlApplicationBridge notifyWithTitle: @"Torrent File Auto Added" description: file + [GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Torrent File Auto Added", "Growl notification title") description: file notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO clickContext: nil]; } } @@ -1912,72 +1916,72 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy if ([ident isEqualToString: TOOLBAR_OPEN]) { - [item setLabel: @"Open"]; - [item setPaletteLabel: @"Open Torrent Files"]; - [item setToolTip: @"Open torrent files"]; + [item setLabel: NSLocalizedString(@"Open", "Open toolbar item -> label")]; + [item setPaletteLabel: NSLocalizedString(@"Open Torrent Files", "Open toolbar item -> palette label")]; + [item setToolTip: NSLocalizedString(@"Open torrent files", "Open toolbar item -> tooltip")]; [item setImage: [NSImage imageNamed: @"Open.png"]]; [item setTarget: self]; [item setAction: @selector(openShowSheet:)]; } else if ([ident isEqualToString: TOOLBAR_REMOVE]) { - [item setLabel: @"Remove"]; - [item setPaletteLabel: @"Remove Selected"]; - [item setToolTip: @"Remove selected transfers"]; + [item setLabel: NSLocalizedString(@"Remove", "Remove toolbar item -> label")]; + [item setPaletteLabel: NSLocalizedString(@"Remove Selected", "Remove toolbar item -> palette label")]; + [item setToolTip: NSLocalizedString(@"Remove selected transfers", "Remove toolbar item -> tooltip")]; [item setImage: [NSImage imageNamed: @"Remove.png"]]; [item setTarget: self]; [item setAction: @selector(removeNoDelete:)]; } else if ([ident isEqualToString: TOOLBAR_INFO]) { - [item setLabel: @"Inspector"]; - [item setPaletteLabel: @"Toggle Inspector"]; - [item setToolTip: @"Toggle the torrent inspector"]; + [item setLabel: NSLocalizedString(@"Inspector", "Inspector toolbar item -> label")]; + [item setPaletteLabel: NSLocalizedString(@"Toggle Inspector", "Inspector toolbar item -> palette label")]; + [item setToolTip: NSLocalizedString(@"Toggle the torrent inspector", "Inspector toolbar item -> tooltip")]; [item setImage: [NSImage imageNamed: @"Info.png"]]; [item setTarget: self]; [item setAction: @selector(showInfo:)]; } else if ([ident isEqualToString: TOOLBAR_PAUSE_ALL]) { - [item setLabel: @"Pause All"]; + [item setLabel: NSLocalizedString(@"Pause All", "Pause All toolbar item -> label")]; [item setPaletteLabel: [item label]]; - [item setToolTip: @"Pause all transfers"]; + [item setToolTip: NSLocalizedString(@"Pause all transfers", "Pause All toolbar item -> tooltip")]; [item setImage: [NSImage imageNamed: @"PauseAll.png"]]; [item setTarget: self]; [item setAction: @selector(stopAllTorrents:)]; } else if ([ident isEqualToString: TOOLBAR_RESUME_ALL]) { - [item setLabel: @"Resume All"]; + [item setLabel: NSLocalizedString(@"Resume All", "Resume All toolbar item -> label")]; [item setPaletteLabel: [item label]]; - [item setToolTip: @"Resume all transfers"]; + [item setToolTip: NSLocalizedString(@"Resume all transfers", "Resume All toolbar item -> tooltip")]; [item setImage: [NSImage imageNamed: @"ResumeAll.png"]]; [item setTarget: self]; [item setAction: @selector(resumeAllTorrents:)]; } else if ([ident isEqualToString: TOOLBAR_PAUSE_SELECTED]) { - [item setLabel: @"Pause"]; - [item setPaletteLabel: @"Pause Selected"]; - [item setToolTip: @"Pause selected transfers"]; + [item setLabel: NSLocalizedString(@"Pause", "Pause toolbar item -> label")]; + [item setPaletteLabel: NSLocalizedString(@"Pause Selected", "Pause toolbar item -> palette label")]; + [item setToolTip: NSLocalizedString(@"Pause selected transfers", "Pause toolbar item -> tooltip")]; [item setImage: [NSImage imageNamed: @"PauseSelected.png"]]; [item setTarget: self]; [item setAction: @selector(stopSelectedTorrents:)]; } else if ([ident isEqualToString: TOOLBAR_RESUME_SELECTED]) { - [item setLabel: @"Resume"]; - [item setPaletteLabel: @"Resume Selected"]; - [item setToolTip: @"Resume selected transfers"]; + [item setLabel: NSLocalizedString(@"Resume", "Resume toolbar item -> label")]; + [item setPaletteLabel: NSLocalizedString(@"Resume Selected", "Resume toolbar item -> palette label")]; + [item setToolTip: NSLocalizedString(@"Resume selected transfers", "Resume toolbar item -> tooltip")]; [item setImage: [NSImage imageNamed: @"ResumeSelected.png"]]; [item setTarget: self]; [item setAction: @selector(resumeSelectedTorrents:)]; } else if ([ident isEqualToString: TOOLBAR_FILTER]) { - [item setLabel: @"Filter"]; - [item setPaletteLabel: @"Toggle Filter"]; - [item setToolTip: @"Toggle the filter bar"]; + [item setLabel: NSLocalizedString(@"Filter", "Filter toolbar item -> label")]; + [item setPaletteLabel: NSLocalizedString(@"Toggle Filter", "Filter toolbar item -> palette label")]; + [item setToolTip: NSLocalizedString(@"Toggle the filter bar", "Filter toolbar item -> tooltip")]; [item setImage: [NSImage imageNamed: @"Filter.png"]]; [item setTarget: self]; [item setAction: @selector(toggleFilterBar:)]; @@ -2096,7 +2100,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy //enable show info if (action == @selector(showInfo:)) { - NSString * title = [[fInfoController window] isVisible] ? @"Hide Inspector" : @"Show Inspector"; + NSString * title = [[fInfoController window] isVisible] ? NSLocalizedString(@"Hide Inspector", "View menu -> Inspector") : NSLocalizedString(@"Show Inspector", "View menu -> Inspector"); if (![[menuItem title] isEqualToString: title]) [menuItem setTitle: title]; @@ -2110,7 +2114,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy //enable toggle status bar if (action == @selector(toggleStatusBar:)) { - NSString * title = [fStatusBar isHidden] ? @"Show Status Bar" : @"Hide Status Bar"; + NSString * title = [fStatusBar isHidden] ? NSLocalizedString(@"Show Status Bar", "View menu -> Status Bar") : NSLocalizedString(@"Hide Status Bar", "View menu -> Status Bar"); if (![[menuItem title] isEqualToString: title]) [menuItem setTitle: title]; @@ -2120,7 +2124,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy //enable toggle filter bar if (action == @selector(toggleFilterBar:)) { - NSString * title = [fFilterBar isHidden] ? @"Show Filter Bar" : @"Hide Filter Bar"; + NSString * title = [fFilterBar isHidden] ? NSLocalizedString(@"Show Filter Bar", "View menu -> Filter Bar") : NSLocalizedString(@"Hide Filter Bar", "View menu -> Filter Bar"); if (![[menuItem title] isEqualToString: title]) [menuItem setTitle: title]; diff --git a/macosx/English.lproj/Localizable.strings b/macosx/English.lproj/Localizable.strings new file mode 100644 index 000000000..9065b4b38 --- /dev/null +++ b/macosx/English.lproj/Localizable.strings @@ -0,0 +1,362 @@ +/* Action context menu -> ratio stop */ +"Stop at Ratio (%.2f)" = "Stop at Ratio (%.2f)"; + +/* Action context menu -> upload/download limit + Action context menu -> upload limit + Action context menu -> download limit */ +"Limit (%d KB/s)" = "Limit (%d KB/s)"; + +/* Confirm Quit panel -> button */ +"Quit" = "Quit"; + +/* Confirm Quit panel -> message */ +"There are %d active transfers. Do you really want to quit?" = "There are %d active transfers. Do you really want to quit?"; + +/* Confirm Quit panel -> message */ +"There is an active transfer. Do you really want to quit?" = "There is an active transfer. Do you really want to quit?"; + +/* Confirm Quit panel -> title */ +"Confirm Quit" = "Confirm Quit"; + +/* File size (beware of leading space) */ +" GB" = " GB"; + +/* File size (beware of leading space) */ +" KB" = " KB"; + +/* File size (beware of leading space) */ +" MB" = " MB"; + +/* File size */ +"%lld bytes" = "%lld bytes"; + +/* Filter toolbar item -> label */ +"Filter" = "Filter"; + +/* Filter toolbar item -> palette label */ +"Toggle Filter" = "Toggle Filter"; + +/* Filter toolbar item -> tooltip */ +"Toggle the filter bar" = "Toggle the filter bar"; + +/* Growl notification description */ +"Bandwidth settings changed" = "Bandwidth settings changed"; + +/* Growl notification title */ +"Download Complete" = "Download Complete"; + +/* Growl notification title */ +"Seeding Complete" = "Seeding Complete"; + +/* Growl notification title */ +"Speed Limit Auto Disabled" = "Speed Limit Auto Disabled"; + +/* Growl notification title */ +"Speed Limit Auto Enabled" = "Speed Limit Auto Enabled"; + +/* Growl notification title */ +"Torrent File Auto Added" = "Torrent File Auto Added"; + +/* Inspector -> Activity -> detailed pieces view tooltip */ +"Piece Availability" = "Piece Availability"; + +/* Inspector -> Activity -> detailed pieces view tooltip */ +"Piece Progress" = "Piece Progress"; + +/* Inspector -> Files tab -> bottom text (number of files) */ +"%d file" = "%d file"; + +/* Inspector -> Files tab -> bottom text (number of files) */ +"%d files" = "%d files"; + +/* Inspector -> Files tab -> bottom text (number of files) */ +"info not available" = "info not available"; + +/* Inspector -> Files tab -> table row tooltip */ +" bytes" = " bytes"; + +/* Inspector -> Peers tab -> connected */ +"%d (%d incoming)" = "%1$d (%2$d incoming)"; + +/* Inspector -> Peers tab -> table row tooltip */ +"From incoming connection" = "From incoming connection"; + +/* Inspector -> Peers tab -> table row tooltip */ +"From outgoing connection" = "From outgoing connection"; + +/* Inspector -> above tabs -> selected torrents */ +"%d Torrents Selected" = "%d Torrents Selected"; + +/* Inspector -> above tabs -> selected torrents */ +"No Torrents Selected" = "No Torrents Selected"; + +/* Inspector -> above tabs -> total size (several torrents selected) */ +"%@ Total" = "%@ Total"; + +/* Inspector toolbar item -> label */ +"Inspector" = "Inspector"; + +/* Inspector toolbar item -> palette label */ +"Toggle Inspector" = "Toggle Inspector"; + +/* Inspector toolbar item -> tooltip */ +"Toggle the torrent inspector" = "Toggle the torrent inspector"; + +/* Main window -> 1st bottom left button (action) tooltip */ +"Shortcuts for changing global settings." = "Shortcuts for changing global settings."; + +/* Main window -> 2nd bottom left button (turtle) tooltip */ +"Speed Limit overrides the total bandwidth limits with its own limits." = "Speed Limit overrides the total bandwidth limits with its own limits."; + +/* Open toolbar item -> label */ +"Open" = "Open"; + +/* Open toolbar item -> palette label */ +"Open Torrent Files" = "Open Torrent Files"; + +/* Open toolbar item -> tooltip */ +"Open torrent files" = "Open torrent files"; + +/* Open torrent -> select destination folder */ +"Select the download folder for \"%@\"" = "Select the download folder for \"%@\""; + +/* Pause All toolbar item -> label */ +"Pause All" = "Pause All"; + +/* Pause All toolbar item -> tooltip */ +"Pause all transfers" = "Pause all transfers"; + +/* Pause toolbar item -> label */ +"Pause" = "Pause"; + +/* Pause toolbar item -> palette label */ +"Pause Selected" = "Pause Selected"; + +/* Pause toolbar item -> tooltip */ +"Pause selected transfers" = "Pause selected transfers"; + +/* Preferences -> Bandwidth toolbar item title */ +"Bandwidth" = "Bandwidth"; + +/* Preferences -> General toolbar item title */ +"General" = "General"; + +/* Preferences -> Network -> port map status */ +"Error mapping port" = "Error mapping port"; + +/* Preferences -> Network -> port map status */ +"Port successfully mapped" = "Port successfully mapped"; + +/* Preferences -> Network -> port status */ +"Checking port status" = "Checking port status"; + +/* Preferences -> Network -> port status */ +"Port is closed" = "Port is closed"; + +/* Preferences -> Network -> port status */ +"Port is open" = "Port is open"; + +/* Preferences -> Network -> port status */ +"Port is stealth" = "Port is stealth"; + +/* Preferences -> Network -> port status */ +"Unable to check port status" = "Unable to check port status"; + +/* Preferences -> Network toolbar item title */ +"Network" = "Network"; + +/* Preferences -> Transfers toolbar item title */ +"Transfers" = "Transfers"; + +/* Removal confirm panel -> button + Confirm Quit panel -> button */ +"Cancel" = "Cancel"; + +/* Removal confirm panel -> button + Remove toolbar item -> label */ +"Remove" = "Remove"; + +/* Removal confirm panel -> message */ +"This transfer is active. Once removed, continuing the transfer will require the torrent file. Do you really want to remove it?" = "This transfer is active. Once removed, continuing the transfer will require the torrent file. Do you really want to remove it?"; + +/* Removal confirm panel -> message part 1 */ +"There are %d active transfers." = "There are %d active transfers."; + +/* Removal confirm panel -> message part 1 */ +"There are %d transfers (%d active)." = "There are %1$d transfers (%2$d active)."; + +/* Removal confirm panel -> message part 2 */ +" Once removed, continuing the transfers will require the torrent files. Do you really want to remove them?" = " Once removed, continuing the transfers will require the torrent files. Do you really want to remove them?"; + +/* Removal confirm panel -> title */ +"Comfirm Removal of %d Transfers" = "Comfirm Removal of %d Transfers"; + +/* Removal confirm panel -> title */ +"Comfirm Removal of \"%@\"" = "Comfirm Removal of \"%@\""; + +/* Remove toolbar item -> palette label */ +"Remove Selected" = "Remove Selected"; + +/* Remove toolbar item -> tooltip */ +"Remove selected transfers" = "Remove selected transfers"; + +/* Resume All toolbar item -> label */ +"Resume All" = "Resume All"; + +/* Resume All toolbar item -> tooltip */ +"Resume all transfers" = "Resume all transfers"; + +/* Resume toolbar item -> label */ +"Resume" = "Resume"; + +/* Resume toolbar item -> palette label */ +"Resume Selected" = "Resume Selected"; + +/* Resume toolbar item -> tooltip */ +"Resume selected transfers" = "Resume selected transfers"; + +/* Save log alert panel -> button + Torrent file copy alert -> button + Torrent file disk space alert -> button */ +"OK" = "OK"; + +/* Save log alert panel -> message */ +"There was a problem creating the file \"%@\"." = "There was a problem creating the file \"%@\"."; + +/* Save log alert panel -> title */ +"Log Could Not Be Saved" = "Log Could Not Be Saved"; + +/* Save log panel -> default file name */ +"untitled" = "untitled"; + +/* Status bar -> total download */ +"Total DL: " = "Total DL: "; + +/* Status bar -> total upload */ +"Total UL: " = "Total UL: "; + +/* Status bar transfer count */ +"%d Transfer" = "%d Transfer"; + +/* Status bar transfer count */ +"%d Transfers" = "%d Transfers"; + +/* Torrent -> location */ +"Transmission Support Folder" = "Transmission Support Folder"; + +/* Torrent -> progress string */ +" - %@ remaining" = " - %@ remaining"; + +/* Torrent -> progress string */ +" - remaining time unknown" = " - remaining time unknown"; + +/* Torrent -> progress string */ +"%@ of %@ (%.2f%%)" = "%1$@ of %2$@ (%3$.2f%%)"; + +/* Torrent -> progress string */ +"%@, uploaded %@ (Ratio: %@)" = "%1$@, uploaded %2$@ (Ratio: %3$@)"; + +/* Torrent -> remaining time */ +"%d day %d hr" = "%1$d day %2$d hr"; + +/* Torrent -> remaining time */ +"%d days %d hr" = "%1$d days %2$d hr"; + +/* Torrent -> remaining time */ +"%d hr %02d min" = "%1$d hr %2$d min"; + +/* Torrent -> remaining time */ +"%d min %02d sec" = "%1$d min %2$d sec"; + +/* Torrent -> remaining time */ +"%d sec" = "%d sec"; + +/* Torrent -> remaining time */ +"Unknown" = "Unknown"; + +/* Torrent -> status string */ +"Checking existing files" = "Checking existing files"; + +/* Torrent -> status string */ +"DL: %@, " = "DL: %@, "; + +/* Torrent -> status string */ +"Downloading" = "Downloading"; + +/* Torrent -> status string */ +"Downloading from %d of %d peer" = "Downloading from %1$d of %2$d peer"; + +/* Torrent -> status string */ +"Downloading from %d of %d peers" = "Downloading from %1$d of %2$d peers"; + +/* Torrent -> status string */ +"Error: " = "Error: "; + +/* Torrent -> status string */ +"N/A" = "N/A"; + +/* Torrent -> status string */ +"Paused" = "Paused"; + +/* Torrent -> status string */ +"Ratio: " = "Ratio: "; + +/* Torrent -> status string */ +"Ratio: %@, " = "Ratio: %@, "; + +/* Torrent -> status string */ +"Seeding" = "Seeding"; + +/* Torrent -> status string */ +"Seeding complete" = "Seeding complete"; + +/* Torrent -> status string */ +"Seeding to %d of %d peer" = "Seeding to %1$d of %2$d peer"; + +/* Torrent -> status string */ +"Seeding to %d of %d peers" = "Seeding to %1$d of %2$d peers"; + +/* Torrent -> status string */ +"Stopping" = "Stopping"; + +/* Torrent -> status string */ +"UL: " = "UL: "; + +/* Torrent -> status string */ +"Waiting to start" = "Waiting to start"; + +/* Torrent file copy alert -> message */ +"The torrent file (%@) cannot be found." = "The torrent file (%@) cannot be found."; + +/* Torrent file copy alert -> title */ +"Copy of \"%@\" Cannot Be Created" = "Copy of \"%@\" Cannot Be Created"; + +/* Torrent file disk space alert -> button */ +"Download Anyway" = "Download Anyway"; + +/* Torrent file disk space alert -> message */ +"The transfer will be paused. Clear up space on %@ to continue." = "The transfer will be paused. Clear up space on %@ to continue."; + +/* Torrent file disk space alert -> title */ +"Not enough remaining disk space to download \"%@\" completely." = "Not enough remaining disk space to download \"%@\" completely."; + +/* Transfer speed (Bytes per second) */ +"B/s" = "B/s"; + +/* View menu -> Filter Bar */ +"Hide Filter Bar" = "Hide Filter Bar"; + +/* View menu -> Filter Bar */ +"Show Filter Bar" = "Show Filter Bar"; + +/* View menu -> Inspector */ +"Hide Inspector" = "Hide Inspector"; + +/* View menu -> Inspector */ +"Show Inspector" = "Show Inspector"; + +/* View menu -> Status Bar */ +"Hide Status Bar" = "Hide Status Bar"; + +/* View menu -> Status Bar */ +"Show Status Bar" = "Show Status Bar"; diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index 7d5a38aef..ace638579 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -122,7 +122,7 @@ { if (numberSelected > 0) { - [fNameField setStringValue: [NSString stringWithFormat: @"%d Torrents Selected", numberSelected]]; + [fNameField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d Torrents Selected", "Inspector -> above tabs -> selected torrents"), numberSelected]]; uint64_t size = 0; NSEnumerator * enumerator = [torrents objectEnumerator]; @@ -130,13 +130,13 @@ while ((torrent = [enumerator nextObject])) size += [torrent size]; - [fSizeField setStringValue: [[NSString stringForFileSize: size] stringByAppendingString: @" Total"]]; + [fSizeField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ Total", "Inspector -> above tabs -> total size (several torrents selected)"), [NSString stringForFileSize: size]]]; } else { - [fNameField setStringValue: @"No Torrents Selected"]; + [fNameField setStringValue: NSLocalizedString(@"No Torrents Selected", "Inspector -> above tabs -> selected torrents")]; [fSizeField setStringValue: @""]; - + [fDownloadedValidField setStringValue: @""]; [fDownloadedTotalField setStringValue: @""]; [fUploadedTotalField setStringValue: @""]; @@ -241,12 +241,14 @@ NSEnumerator * enumerator = [fTorrents objectEnumerator]; while ((torrent = [enumerator nextObject])) [fFiles addObjectsFromArray: [torrent fileList]]; - - [fFileTableStatusField setStringValue: [NSString stringWithFormat: @"%d file%s", [fFiles count], - [fFiles count] == 1 ? "" : "s"]]; + + if ([fFiles count] > 1) + [fFileTableStatusField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> Files tab -> bottom text (number of files)"), [fFiles count]]]; + else + [fFileTableStatusField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d file", "Inspector -> Files tab -> bottom text (number of files)"), [fFiles count]]]; } else - [fFileTableStatusField setStringValue: @"info not available"]; + [fFileTableStatusField setStringValue: NSLocalizedString(@"info not available", "Inspector -> Files tab -> bottom text (number of files)")]; [fFileTable deselectAll: nil]; [fFileTable reloadData]; @@ -311,7 +313,7 @@ [fLeechersField setStringValue: leechers < 0 ? @"" : [NSString stringWithInt: leechers]]; BOOL active = [torrent isActive]; - [fConnectedPeersField setStringValue: active ? [NSString stringWithFormat: @"%d (%d incoming)", + [fConnectedPeersField setStringValue: active ? [NSString stringWithFormat: NSLocalizedString(@"%d (%d incoming)", "Inspector -> Peers tab -> connected"), [torrent totalPeers], [torrent totalPeersIncoming]]: @""]; [fDownloadingFromField setStringValue: active ? [NSString stringWithInt: [torrent peersUploading]] : @""]; [fUploadingToField setStringValue: active ? [NSString stringWithInt: [torrent peersDownloading]] : @""]; @@ -525,13 +527,17 @@ { NSDictionary * file = [fFiles objectAtIndex: row]; if ([[column identifier] isEqualToString: @"Size"]) - return [[[file objectForKey: @"Size"] stringValue] stringByAppendingString: @" bytes"]; + return [[[file objectForKey: @"Size"] stringValue] stringByAppendingString: NSLocalizedString(@" bytes", "Inspector -> Files tab -> table row tooltip")]; else return [file objectForKey: @"Name"]; } else if (tableView == fPeerTable) - return [NSString stringWithFormat: @"From %@ connection", - [[[fPeers objectAtIndex: row] objectForKey: @"Incoming"] boolValue] ? @"incoming" : @"outgoing"]; + { + if ([[[fPeers objectAtIndex: row] objectForKey: @"Incoming"] boolValue]) + return NSLocalizedString(@"From incoming connection", "Inspector -> Peers tab -> table row tooltip"); + else + return NSLocalizedString(@"From outgoing connection", "Inspector -> Peers tab -> table row tooltip"); + } else return nil; } diff --git a/macosx/MessageWindowController.m b/macosx/MessageWindowController.m index d55eaaa5d..e08e78e3e 100644 --- a/macosx/MessageWindowController.m +++ b/macosx/MessageWindowController.m @@ -174,7 +174,7 @@ [panel setRequiredFileType: @"txt"]; [panel setCanSelectHiddenExtension: YES]; - [panel beginSheetForDirectory: nil file: @"untitled" modalForWindow: [self window] modalDelegate: self + [panel beginSheetForDirectory: nil file: NSLocalizedString(@"untitled", "Save log panel -> default file name") modalForWindow: [self window] modalDelegate: self didEndSelector: @selector(writeToFileSheetClosed:returnCode:contextInfo:) contextInfo: string]; } @@ -185,10 +185,10 @@ if (![string writeToFile: [panel filename] atomically: YES encoding: NSUTF8StringEncoding error: nil]) { NSAlert * alert = [[NSAlert alloc] init]; - [alert addButtonWithTitle: @"OK"]; - [alert setMessageText: [NSString stringWithFormat: @"Log Could Not Be Saved"]]; + [alert addButtonWithTitle: NSLocalizedString(@"OK", "Save log alert panel -> button")]; + [alert setMessageText: [NSString stringWithFormat: NSLocalizedString(@"Log Could Not Be Saved", "Save log alert panel -> title")]]; [alert setInformativeText: [NSString stringWithFormat: - @"There was a problem creating the file \"%@\".", [[panel filename] lastPathComponent]]]; + NSLocalizedString(@"There was a problem creating the file \"%@\".", "Save log alert panel -> message"), [[panel filename] lastPathComponent]]]; [alert setAlertStyle: NSWarningAlertStyle]; [alert runModal]; diff --git a/macosx/PiecesView.m b/macosx/PiecesView.m index 40da0fd1c..d1132b456 100644 --- a/macosx/PiecesView.m +++ b/macosx/PiecesView.m @@ -135,7 +135,8 @@ [fBluePiece unlockFocus]; [fImageView setToolTip: [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"] - ? @"Piece Availability" : @"Piece Progress"]; + ? NSLocalizedString(@"Piece Availability", "Inspector -> Activity -> detailed pieces view tooltip") + : NSLocalizedString(@"Piece Progress", "Inspector -> Activity -> detailed pieces view tooltip")]; //actually draw the box [self setTorrent: nil]; @@ -382,7 +383,8 @@ [defaults setBool: showAvailability forKey: @"PiecesViewShowAvailability"]; - [fImageView setToolTip: showAvailability ? @"Piece Availability" : @"Piece Progress"]; + [fImageView setToolTip: showAvailability ? NSLocalizedString(@"Piece Availability", "Inspector -> Activity -> detailed pieces view tooltip") + : NSLocalizedString(@"Piece Progress", "Inspector -> Activity -> detailed pieces view tooltip")]; [self updateView: YES]; } diff --git a/macosx/PortChecker.m b/macosx/PortChecker.m index eeb838c3f..9a2ef0036 100644 --- a/macosx/PortChecker.m +++ b/macosx/PortChecker.m @@ -95,8 +95,15 @@ NSArray * nodes = [shieldsUpProbe nodesForXPath: @"/html/body/center/table[3]/tr/td[2]" error: nil]; if ([nodes count] != 1) { - NSLog(@"Unable to get port status: invalid (outdated) XPath expression"); - [self callBackWithStatus: PORT_STATUS_ERROR]; + NSArray * title = [shieldsUpProbe nodesForXPath: @"/html/head/title" error: nil]; + // This may happen when we probe twice too quickly + if ([title count] > 1 || ![[[title objectAtIndex: 0] stringValue] isEqualToString: + @"NanoProbe System Already In Use"]) + { + NSLog(@"Unable to get port status: invalid (outdated) XPath expression"); + [[shieldsUpProbe XMLData] writeToFile: @"/tmp/shieldsUpProbe.html" atomically: YES]; + [self callBackWithStatus: PORT_STATUS_ERROR]; + } } else { diff --git a/macosx/PrefsController.m b/macosx/PrefsController.m index 934c5903a..75e496057 100644 --- a/macosx/PrefsController.m +++ b/macosx/PrefsController.m @@ -37,10 +37,10 @@ #define UPDATE_WEEKLY 1 #define UPDATE_NEVER 2 -#define TOOLBAR_GENERAL @"General" -#define TOOLBAR_TRANSFERS @"Transfers" -#define TOOLBAR_BANDWIDTH @"Bandwidth" -#define TOOLBAR_NETWORK @"Network" +#define TOOLBAR_GENERAL NSLocalizedString(@"General", "Preferences -> General toolbar item title") +#define TOOLBAR_TRANSFERS NSLocalizedString(@"Transfers", "Preferences -> Transfers toolbar item title") +#define TOOLBAR_BANDWIDTH NSLocalizedString(@"Bandwidth", "Preferences -> Bandwidth toolbar item title") +#define TOOLBAR_NETWORK NSLocalizedString(@"Network", "Preferences -> Network toolbar item title") @interface PrefsController (Private) @@ -377,7 +377,7 @@ //NSXML features are unfortunately only available since Mac OS X v10.4 PortChecker * checker = [[PortChecker alloc] initWithDelegate: self]; - [fPortStatusField setStringValue: [@"Checking port status" stringByAppendingEllipsis]]; + [fPortStatusField setStringValue: [NSLocalizedString(@"Checking port status", "Preferences -> Network -> port status") stringByAppendingEllipsis]]; [fPortStatusProgress startAnimation: self]; [checker probePort: [fDefaults integerForKey: @"BindPort"]]; @@ -390,19 +390,19 @@ switch ([portChecker status]) { case PORT_STATUS_OPEN: - [fPortStatusField setStringValue: @"Port is open"]; + [fPortStatusField setStringValue: NSLocalizedString(@"Port is open", "Preferences -> Network -> port status")]; [fPortStatusImage setImage: [NSImage imageNamed: @"GreenDot.tiff"]]; break; case PORT_STATUS_STEALTH: - [fPortStatusField setStringValue: @"Port is stealth"]; + [fPortStatusField setStringValue: NSLocalizedString(@"Port is stealth", "Preferences -> Network -> port status")]; [fPortStatusImage setImage: [NSImage imageNamed: @"RedDot.tiff"]]; break; case PORT_STATUS_CLOSED: - [fPortStatusField setStringValue: @"Port is closed"]; + [fPortStatusField setStringValue: NSLocalizedString(@"Port is closed", "Preferences -> Network -> port status")]; [fPortStatusImage setImage: [NSImage imageNamed: @"RedDot.tiff"]]; break; case PORT_STATUS_ERROR: - [fPortStatusField setStringValue: @"Unable to check port status"]; + [fPortStatusField setStringValue: NSLocalizedString(@"Unable to check port status", "Preferences -> Network -> port status")]; [fPortStatusImage setImage: [NSImage imageNamed: @"YellowDot.tiff"]]; break; } @@ -427,12 +427,12 @@ if (status == 2) { - [fNatStatusField setStringValue: @"Port successfully mapped"]; + [fNatStatusField setStringValue: NSLocalizedString(@"Port successfully mapped", "Preferences -> Network -> port map status")]; [fNatStatusImage setImage: [NSImage imageNamed: @"GreenDot.tiff"]]; } else if (status == 3 || status == 4) { - [fNatStatusField setStringValue: @"Error mapping port"]; + [fNatStatusField setStringValue: NSLocalizedString(@"Error mapping port", "Preferences -> Network -> port map status")]; [fNatStatusImage setImage: [NSImage imageNamed: @"RedDot.tiff"]]; } else diff --git a/macosx/StringAdditions.m b/macosx/StringAdditions.m index 32fcf97b9..2753cc122 100644 --- a/macosx/StringAdditions.m +++ b/macosx/StringAdditions.m @@ -44,24 +44,24 @@ + (NSString *) stringForFileSize: (uint64_t) size { if (size < 1024) - return [NSString stringWithFormat: @"%lld bytes", size]; + return [NSString stringWithFormat: NSLocalizedString(@"%lld bytes", "File size"), size]; float convertedSize = (float) size; NSString * unit; if (size < 1048576) { convertedSize /= 1024.0; - unit = @" KB"; + unit = NSLocalizedString(@" KB", "File size (beware of leading space)"); } else if (size < 1073741824) { convertedSize /= 1048576.0; - unit = @" MB"; + unit = NSLocalizedString(@" MB", "File size (beware of leading space)"); } else { convertedSize /= 1073741824.0; - unit = @" GB"; + unit = NSLocalizedString(@" GB", "File size (beware of leading space)"); } NSString * sizeString; @@ -78,7 +78,7 @@ + (NSString *) stringForSpeed: (float) speed { - return [[self stringForSpeedAbbrev: speed] stringByAppendingString: @"B/s"]; + return [[self stringForSpeedAbbrev: speed] stringByAppendingString: NSLocalizedString(@"B/s", "Transfer speed (Bytes per second)")]; } + (NSString *) stringForSpeedAbbrev: (float) speed diff --git a/macosx/Torrent.m b/macosx/Torrent.m index cf3a4e647..c8c722612 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -193,10 +193,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 [fProgressString setString: @""]; if ([self progress] < 1.0) - [fProgressString appendFormat: @"%@ of %@ (%.2f%%)", [NSString stringForFileSize: + [fProgressString appendFormat: NSLocalizedString(@"%@ of %@ (%.2f%%)", "Torrent -> progress string"), [NSString stringForFileSize: [self downloadedValid]], [NSString stringForFileSize: [self size]], 100.0 * [self progress]]; else - [fProgressString appendFormat: @"%@, uploaded %@ (Ratio: %@)", [NSString stringForFileSize: + [fProgressString appendFormat: NSLocalizedString(@"%@, uploaded %@ (Ratio: %@)", "Torrent -> progress string"), [NSString stringForFileSize: [self size]], [NSString stringForFileSize: [self uploadedTotal]], [NSString stringForRatioWithDownload: [self downloadedTotal] upload: [self uploadedTotal]]]; @@ -206,11 +206,11 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 case TR_STATUS_PAUSE: if (fFinishedSeeding) - tempString = @"Seeding complete"; + tempString = NSLocalizedString(@"Seeding complete", "Torrent -> status string"); else if (fWaitToStart) - tempString = [@"Waiting to start" stringByAppendingEllipsis]; + tempString = [NSLocalizedString(@"Waiting to start", "Torrent -> status string") stringByAppendingEllipsis]; else - tempString = @"Paused"; + tempString = NSLocalizedString(@"Paused", "Torrent -> status string"); [fStatusString setString: tempString]; [fShortStatusString setString: tempString]; @@ -218,7 +218,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 break; case TR_STATUS_CHECK: - tempString = [@"Checking existing files" stringByAppendingEllipsis]; + tempString = [NSLocalizedString(@"Checking existing files", "Torrent -> status string") stringByAppendingEllipsis]; [fStatusString setString: tempString]; [fShortStatusString setString: tempString]; @@ -228,44 +228,52 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 case TR_STATUS_DOWNLOAD: [fStatusString setString: @""]; - [fStatusString appendFormat: - @"Downloading from %d of %d peer%s", [self peersUploading], [self totalPeers], - [self totalPeers] == 1 ? "" : "s"]; + if ([self totalPeers] > 1) + [fStatusString appendFormat: NSLocalizedString(@"Downloading from %d of %d peers", "Torrent -> status string"), [self peersUploading], [self totalPeers]]; + else + [fStatusString appendFormat: NSLocalizedString(@"Downloading from %d of %d peer", "Torrent -> status string"), [self peersUploading], [self totalPeers]]; [fRemainingTimeString setString: @""]; int eta = [self eta]; if (eta < 0) { - [fRemainingTimeString setString: @"Unknown"]; - [fProgressString appendString: @" - remaining time unknown"]; + [fRemainingTimeString setString: NSLocalizedString(@"Unknown", "Torrent -> remaining time")]; + [fProgressString appendString: NSLocalizedString(@" - remaining time unknown", "Torrent -> progress string")]; } else { if (eta < 60) - [fRemainingTimeString appendFormat: @"%d sec", eta]; + [fRemainingTimeString appendFormat: NSLocalizedString(@"%d sec", "Torrent -> remaining time"), eta]; else if (eta < 3600) //60 * 60 - [fRemainingTimeString appendFormat: @"%d min %02d sec", eta / 60, eta % 60]; + [fRemainingTimeString appendFormat: NSLocalizedString(@"%d min %02d sec", "Torrent -> remaining time"), eta / 60, eta % 60]; else if (eta < 86400) //24 * 60 * 60 - [fRemainingTimeString appendFormat: @"%d hr %02d min", eta / 3600, (eta / 60) % 60]; + [fRemainingTimeString appendFormat: NSLocalizedString(@"%d hr %02d min", "Torrent -> remaining time"), eta / 3600, (eta / 60) % 60]; else - [fRemainingTimeString appendFormat: @"%d day%s %d hr", - eta / 86400, eta / 86400 == 1 ? "" : "s", (eta / 3600) % 24]; + { + if (eta / 86400 > 1) + [fRemainingTimeString appendFormat: NSLocalizedString(@"%d days %d hr", "Torrent -> remaining time"), + eta / 86400, (eta / 3600) % 24]; + else + [fRemainingTimeString appendFormat: NSLocalizedString(@"%d day %d hr", "Torrent -> remaining time"), + eta / 86400, (eta / 3600) % 24]; + } - [fProgressString appendFormat: @" - %@ remaining", fRemainingTimeString]; + [fProgressString appendFormat: NSLocalizedString(@" - %@ remaining", "Torrent -> progress string"), fRemainingTimeString]; } break; case TR_STATUS_SEED: [fStatusString setString: @""]; - [fStatusString appendFormat: - @"Seeding to %d of %d peer%s", - [self peersDownloading], [self totalPeers], [self totalPeers] == 1 ? "" : "s"]; + if ([self totalPeers] > 1) + [fStatusString appendFormat: NSLocalizedString(@"Seeding to %d of %d peers", "Torrent -> status string"), [self peersDownloading], [self totalPeers]]; + else + [fStatusString appendFormat: NSLocalizedString(@"Seeding to %d of %d peer", "Torrent -> status string"), [self peersDownloading], [self totalPeers]]; break; case TR_STATUS_STOPPING: - tempString = [@"Stopping" stringByAppendingEllipsis]; + tempString = [NSLocalizedString(@"Stopping", "Torrent -> status string") stringByAppendingEllipsis]; [fStatusString setString: tempString]; [fShortStatusString setString: tempString]; @@ -275,7 +283,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 if (fStat->error & TR_ETRACKER) { - [fStatusString setString: [@"Error: " stringByAppendingString: [NSString stringWithUTF8String: fStat->trackerError]]]; + [fStatusString setString: [NSLocalizedString(@"Error: ", "Torrent -> status string") stringByAppendingString: [NSString stringWithUTF8String: fStat->trackerError]]]; if (!fError && [self isActive]) { fError = YES; @@ -294,7 +302,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 NSString * stringToAppend = @""; if ([self progress] < 1.0) { - stringToAppend = [NSString stringWithFormat: @"DL: %@, ", [NSString stringForSpeed: [self downloadRate]]]; + stringToAppend = [NSString stringWithFormat: NSLocalizedString(@"DL: %@, ", "Torrent -> status string"), [NSString stringForSpeed: [self downloadRate]]]; [fShortStatusString setString: @""]; } else @@ -302,11 +310,11 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 NSString * ratioString = [NSString stringForRatioWithDownload: [self downloadedTotal] upload: [self uploadedTotal]]; - [fShortStatusString setString: [NSString stringWithFormat: @"Ratio: %@, ", ratioString]]; - [fRemainingTimeString setString: [@"Ratio: " stringByAppendingString: ratioString]]; + [fShortStatusString setString: [NSString stringWithFormat: NSLocalizedString(@"Ratio: %@, ", "Torrent -> status string"), ratioString]]; + [fRemainingTimeString setString: [NSLocalizedString(@"Ratio: ", "Torrent -> status string") stringByAppendingString: ratioString]]; } - stringToAppend = [stringToAppend stringByAppendingString: [@"UL: " stringByAppendingString: + stringToAppend = [stringToAppend stringByAppendingString: [NSLocalizedString(@"UL: ", "Torrent -> status string") stringByAppendingString: [NSString stringForSpeed: [self uploadRate]]]]; [fStatusString appendFormat: @" - %@", stringToAppend]; @@ -467,12 +475,12 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 if (volume && remainingSpace <= torrentRemaining) { NSAlert * alert = [[NSAlert alloc] init]; - [alert setMessageText: [NSString stringWithFormat: @"Not enough remaining disk space to download \"%@\" completely.", + [alert setMessageText: [NSString stringWithFormat: NSLocalizedString(@"Not enough remaining disk space to download \"%@\" completely.", "Torrent file disk space alert -> title"), [self name]]]; [alert setInformativeText: [NSString stringWithFormat: - @"The transfer will be paused. Clear up space on %@ to continue.", volume]]; - [alert addButtonWithTitle: @"OK"]; - [alert addButtonWithTitle: @"Download Anyway"]; + NSLocalizedString(@"The transfer will be paused. Clear up space on %@ to continue.", "Torrent file disk space alert -> message"), volume]]; + [alert addButtonWithTitle: NSLocalizedString(@"OK", "Torrent file disk space alert -> button")]; + [alert addButtonWithTitle: NSLocalizedString(@"Download Anyway", "Torrent file disk space alert -> button")]; if ([alert runModal] == NSAlertFirstButtonReturn) { @@ -547,7 +555,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 - (NSString *) torrentLocationString { - return fPrivateTorrent ? @"Transmission Support Folder" : [fPublicTorrentLocation stringByAbbreviatingWithTildeInPath]; + return fPrivateTorrent ? NSLocalizedString(@"Transmission Support Folder", "Torrent -> location") : [fPublicTorrentLocation stringByAbbreviatingWithTildeInPath]; } - (NSString *) dataLocation @@ -570,27 +578,27 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 switch( fStat->status ) { case TR_STATUS_PAUSE: - return @"Paused"; + return NSLocalizedString(@"Paused", "Torrent -> status string"); break; case TR_STATUS_CHECK: - return [@"Checking existing files" stringByAppendingEllipsis]; + return [NSLocalizedString(@"Checking existing files", "Torrent -> status string") stringByAppendingEllipsis]; break; case TR_STATUS_DOWNLOAD: - return @"Downloading"; + return NSLocalizedString(@"Downloading", "Torrent -> status string"); break; case TR_STATUS_SEED: - return @"Seeding"; + return NSLocalizedString(@"Seeding", "Torrent -> status string"); break; case TR_STATUS_STOPPING: - return [@"Stopping" stringByAppendingEllipsis]; + return [NSLocalizedString(@"Stopping", "Torrent -> status string") stringByAppendingEllipsis]; break; default: - return @"N/A"; + return NSLocalizedString(@"N/A", "Torrent -> status string"); } }