1. dwt
  2. Murky

Commits

Jens Alfke  committed 5c9d2c4

Made strings in source code localizable:
*Wrapped user-visible string constants with NSLocalizedString(...) calls.
*Added build phase to run genstrings.
*Added generated Localizable.strings file to project.

  • Participants
  • Parent commits 7ea1699
  • Branches default

Comments (0)

Files changed (10)

File English.lproj/Localizable.strings

  • Ignore whitespace
Binary file added.

File Murky.xcodeproj/project.pbxproj

View file
  • Ignore whitespace
 		27C657AA0FAEA82300CFB909 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 27C657A70FAEA82300CFB909 /* MainMenu.xib */; };
 		27D124F60C8F501B0075446A /* URLFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 27D124F50C8F501B0075446A /* URLFormatter.m */; };
 		27D918810C890F5500D53A8D /* xmlminimal.style in Resources */ = {isa = PBXBuildFile; fileRef = 27D918800C890F5500D53A8D /* xmlminimal.style */; };
+		27E396FA10E88314009F99ED /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 27E396F810E88314009F99ED /* Localizable.strings */; };
 		27E771CC0FB01124006504EF /* BitbucketFavIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 27E771CB0FB01124006504EF /* BitbucketFavIcon.png */; };
 		27E772930FB09EA7006504EF /* MYWindowUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 27E772920FB09EA7006504EF /* MYWindowUtils.m */; };
 		27FEB46D0FBB200600290049 /* toolbar_add.png in Resources */ = {isa = PBXBuildFile; fileRef = 27FEB4640FBB200600290049 /* toolbar_add.png */; };
 		27D124F40C8F501B0075446A /* URLFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLFormatter.h; sourceTree = "<group>"; };
 		27D124F50C8F501B0075446A /* URLFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = URLFormatter.m; sourceTree = "<group>"; };
 		27D918800C890F5500D53A8D /* xmlminimal.style */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = xmlminimal.style; sourceTree = "<group>"; };
+		27E396F910E88314009F99ED /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = SOURCE_ROOT; };
 		27E771CB0FB01124006504EF /* BitbucketFavIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = BitbucketFavIcon.png; sourceTree = "<group>"; };
 		27E772910FB09EA7006504EF /* MYWindowUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MYWindowUtils.h; sourceTree = "<group>"; };
 		27E772920FB09EA7006504EF /* MYWindowUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYWindowUtils.m; sourceTree = "<group>"; };
 		29B97317FDCFA39411CA2CEA /* Resources */ = {
 			isa = PBXGroup;
 			children = (
+				27E396F810E88314009F99ED /* Localizable.strings */,
 				8D1107310486CEB800E47090 /* Info.plist */,
 				27FEB4840FBB209D00290049 /* InfoPlist.strings */,
 				27FEB4630FBB200600290049 /* Icons */,
 				8D1107290486CEB800E47090 /* Resources */,
 				8D11072C0486CEB800E47090 /* Sources */,
 				8D11072E0486CEB800E47090 /* Frameworks */,
+				27E396E710E87CAC009F99ED /* genstrings */,
 			);
 			buildRules = (
 			);
 				7300A4F910DA29E2009C0BE4 /* toolbar_addremove.png in Resources */,
 				7300A4FA10DA29E2009C0BE4 /* toolbar_quicklook.png in Resources */,
 				7300A4FB10DA29E2009C0BE4 /* toolbar_tag.png in Resources */,
+				27E396FA10E88314009F99ED /* Localizable.strings in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 /* End PBXResourcesBuildPhase section */
 
+/* Begin PBXShellScriptBuildPhase section */
+		27E396E710E87CAC009F99ED /* genstrings */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 2147483647;
+			comments = "Taken from Wil Shipley's blog post:\nhttp://wilshipley.com/blog/2009/10/pimp-my-code-part-17-lost-in.html";
+			files = (
+			);
+			inputPaths = (
+			);
+			name = genstrings;
+			outputPaths = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+			shellPath = /bin/zsh;
+			shellScript = "# -q silences duplicate comments with same key warning\ngenstrings -o ${SRCROOT}/English.lproj ${SRCROOT}/**/*.[hm]\n";
+			showEnvVarsInLog = 0;
+		};
+/* End PBXShellScriptBuildPhase section */
+
 /* Begin PBXSourcesBuildPhase section */
 		8D11072C0486CEB800E47090 /* Sources */ = {
 			isa = PBXSourcesBuildPhase;
 			name = MainMenu.xib;
 			sourceTree = "<group>";
 		};
+		27E396F810E88314009F99ED /* Localizable.strings */ = {
+			isa = PBXVariantGroup;
+			children = (
+				27E396F910E88314009F99ED /* English */,
+			);
+			name = Localizable.strings;
+			sourceTree = "<group>";
+		};
 		27FEB4840FBB209D00290049 /* InfoPlist.strings */ = {
 			isa = PBXVariantGroup;
 			children = (

File Source/HgRepository.m

View file
  • Ignore whitespace
         NSString *dstPath = dstURL.path;
         if( [[NSFileManager defaultManager] fileExistsAtPath: dstPath] ) {
             NSError *error;
-            MYMiscError(&error, @"The path to clone into already exists");
+            MYMiscError(&error, @"", 
+                        NSLocalizedString(@"The path to clone into already exists",
+                                          @"Error message for failed hg clone"));
             return [[HgOperation alloc] initWithError: error];
         }
         NSString *root = [[self class] findRootOf: dstPath localPath: NULL];
         if( root ) {
             NSError *error;
-            MYMiscError(&error, @"The path to clone into is already inside a Mercurial repository at %@",root);
+            MYMiscError(&error, NSLocalizedString(@"The path to clone into is already inside a Mercurial repository at %@",
+                                                  @"Error message for failed hg clone"),
+                        root);
             return [[HgOperation alloc] initWithError: error];
         }
     }

File Source/HgRevision.m

View file
  • Ignore whitespace
         if( comment ) {
             NSMutableString *c = [comment mutableCopy];
             if( c.length >= kShortLength )
-                [c replaceCharactersInRange: NSMakeRange(kShortLength-3,c.length-(kShortLength-3)) withString: @"..."];
+                [c replaceCharactersInRange: NSMakeRange(kShortLength-3,c.length-(kShortLength-3)) 
+                                 withString: NSLocalizedString(@"...", 
+                                                               @"Appended to truncated comment string in revision table")];
             [c replaceOccurrencesOfString: @"\n" withString: @" " options: 0  range: NSMakeRange(0,c.length)];
             _shortComment = c;
         } else

File Source/HgUncommittedRevision.m

View file
  • Ignore whitespace
 
 - (BOOL) isUncommitted              {return YES;}
 
-- (NSString*) localString           {return @"current";}
+- (NSString*) localString           {return NSLocalizedString(@"current", 
+                                                              @"Revision 'number' displayed for current revision in table");}
 
 - (NSString*) identifierString      {return nil;}
 
     if (_comment.length)
         return _comment;
     else if (_root.isUncommitted)
-        return @"--locally modified--";
+        return NSLocalizedString(@"--locally modified--", 
+                                 @"Default comment for current revision");
     else
-        return @"(no changes)";
+        return NSLocalizedString(@"(no changes)", 
+                                 @"Comment for unchanged current revision");
 }
 
 - (void) setComment: (NSString*)str
                error: (NSError**)outError
 {
     if( message.length==0 )
-        return MYMiscError(outError, @"Missing commit message");
+        return MYMiscError(outError, 
+                           @"",
+                           NSLocalizedString(@"Missing commit message",
+                                             @"Error message for hg commit"));
     if( ! [self applyCommand: @"commit" 
                     arguments: [NSArray arrayWithObjects: @"--message", message, nil]
                       toFiles: files

File Source/ImageAndTextCell.m

View file
  • Ignore whitespace
  redistribute this Apple software.
  
  In consideration of your agreement to abide by the following terms, and subject to these 
- terms, Apple grants you a personal, non-exclusive license, under Apples copyrights in 
+ terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in 
  this original Apple software (the "Apple Software"), to use, reproduce, modify and 
  redistribute the Apple Software, with or without modifications, in source and/or binary 
  forms; provided that if you redistribute the Apple Software in its entirety and without 

File Source/MercurialApp.m

View file
  • Ignore whitespace
         if( dstURL.isFileURL )
             [self openRepository: dstURL.path remember: YES];
         else
-            NSRunInformationalAlertPanel(@"Cloned Repository",
-                                         @"Successfully created a cloned repository at \n\n%@",
+            NSRunInformationalAlertPanel(NSLocalizedString(@"Cloned Repository", 
+                                                           @"Title of post-clone success alert"),
+                                         NSLocalizedString(@"Successfully created a cloned repository at \n\n%@", 
+                                                           @"Body of post-clone success alert"),
                                          nil, nil, nil,
                                          dstURL.absoluteString);
     }
     HgOperation *op = [[HgOperation alloc] initWithDirectory: NSHomeDirectory() command: @"--version", nil];
     NSError *error;
     if( ! [op run: &error] ) {
-        NSRunCriticalAlertPanel(@"Can't call Mercurial",
-                                @"Unable to find or run the 'hg' command.\n\n%@",
-                                @"Sorry", nil, nil,
+        NSRunCriticalAlertPanel(NSLocalizedString(@"Can't call Mercurial", 
+                                                  @"Title of fatal error alert"),
+                                NSLocalizedString(@"Unable to find or run the 'hg' command.\n\n%@",
+                                                  @"Body of fatal error alert"),
+                                NSLocalizedString(@"Sorry", @"Button in fatal error alert"), nil, nil,
                                 error.localizedDescription);
         [NSApp terminate: self];
         return;

File Source/ProjectsController.m

View file
  • Ignore whitespace
             _exists = YES;
         } else {
             _root = [HgProject projectWithName: @"Projects"];   // not itself visible
-            [_root addChild: [HgProject projectWithName: @"untitled project"]];
+            [_root addChild: [HgProject projectWithName: NSLocalizedString(@"untitled project", 
+                                                                           @"Default name of new project (group) created in Projects window")]];
         }
                 
         [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(save)
 
 - (IBAction) addProject: (id)sender
 {
-    [_root addChild: [HgProject projectWithName: @"untitled project"]];
+    [_root addChild: [HgProject projectWithName: NSLocalizedString(@"untitled project", 
+                                                                   @"Default name of new project (group) created in Projects window")]];
     [self changed];
 }
 

File Source/RepoController.m

View file
  • Ignore whitespace
 {
     BOOL isDir;
     if( ! [[NSFileManager defaultManager] fileExistsAtPath: path isDirectory: &isDir] ) {
-        MYMiscError(error, @"No such directory %@",path);
+        MYMiscError(error, 
+                    NSLocalizedString(@"No such directory %@", 
+                                      @"Error message from Open command"),
+                    path);
         return nil;
     } else if( ! isDir ) {
-        MYMiscError(error, @"%@ is not a directory",path);
+        MYMiscError(error,
+                    NSLocalizedString(@"%@ is not a directory", 
+                                      @"Error message from Open command"),
+                    path);
         return nil;
     }
     HgRepository *repo = [[HgRepository alloc] initWithPath: path localPath: NULL];
     if( ! repo ) {
-        int result = NSRunAlertPanel(@"Convert to Mercurial repository?", 
-                                     @"The directory <%@> is not already a Mercurial repository. "
-                                     "Would you like to make it one?",
-                                     @"Convert", @"Cancel", nil,
+        int result = NSRunAlertPanel(NSLocalizedString(@"Convert to Mercurial repository?", 
+                                                       @"Title of conversion alert from Open command"), 
+                                     NSLocalizedString(@"The directory <%@> is not already a Mercurial repository. Would you like to make it one?", 
+                                                       @"Body of conversion alert from Open command"),
+                                     NSLocalizedString(@"Convert", 
+                                                       @"Button of conversion alert from Open command"), 
+                                     NSLocalizedString(@"Cancel", @"Button"), nil,
                                      path);
         if( result != NSOKButton ) {
             if (error) *error = nil;
     NSString *title = _repo.webName;
     HgRevision *rev = self.selectedRevision;
     if( rev && !rev.isUncommitted )
-        title = [NSString stringWithFormat: @"%@ [rev %i]", title, rev.localNumber];
+        title = [NSString stringWithFormat: NSLocalizedString(@"%@ [rev %i]", 
+                                                              @"Repository window title format"),
+                                            title, rev.localNumber];
     self.window.title = title;
 }
 

File Source/RepoController_Actions.m

View file
  • Ignore whitespace
 {
     if( ! file.isFile ) {
         //FIX: Can't compare directories yet
-        return MYMiscError(outError, @"Can't compare directories yet, sorry!");
+        return MYMiscError(outError, @"%@", 
+                           NSLocalizedString(@"Can't compare directories yet, sorry!", 
+                                             @"Error from Compare command"));
     }
     NSString *pathOld = [revOld getPathToFileContents: file inTempDir: self.tempDir error: outError];
     if( ! pathOld ) return NO;
     }
     
     HgFile *file = self.selectedFile;
-    NSString *filename = [NSString stringWithFormat: @"%@ (%@ vs %@).diff", 
+    NSString *filename = [NSString stringWithFormat: NSLocalizedString(@"%@ (%@ vs %@).diff",
+                                                                       @"Name of temp file generated by Diff command"), 
                           file.name, revNew.localString,revOld.localString];
     NSError *error = nil;
     NSString *diff = [revNew diffFile: file withRevision: revOld error: &error];
         return;
     }
     _progressMessageField.stringValue = message;
-    _progressStopButton.title = @"Stop";
+    _progressStopButton.title = NSLocalizedString(@"Stop", @"Button in progress sheet");
     NSView *superview = _progressStopButton.superview;
     [_progressStopButton removeFromSuperview];
     _progressStopButton.keyEquivalent = @"\033"; // esc
 
 
 - (void) _currentOperationStopped {
-    _progressStopButton.title = @"Close";
+    _progressStopButton.title = NSLocalizedString(@"Close", @"Button in progress sheet");
     _progressStopButton.keyEquivalent = @"\r";
 }
 
                 [_outline selectRow: row byExtendingSelection: YES];
         }
         
-        NSBeginCriticalAlertSheet(@"Some files aren't in the repository",
-                                  @"OK", @"Cancel", nil,
+        NSBeginCriticalAlertSheet(NSLocalizedString(@"Some files aren't in the repository", 
+                                                    @"Title of alert from Commit command"),
+                                  NSLocalizedString(@"OK", @"Button"), 
+                                  NSLocalizedString(@"Cancel", @"Button"), nil,
                                   self.window, self,
                                   @selector(_endCommitWarnSheet:resultCode:context:),NULL,
                                   files, 
-                                  @"%i file(s) you're trying to check in have not yet "
-                                  "been added to the repository (status is '?'). These won't be checked in. Proceed anyway?",
+                                  NSLocalizedString(@"%i file(s) you're trying to check in have not yet been added to the repository (status is '?'). These won't be checked in. Proceed anyway?", 
+                                                    @"Body of alert from Commit command"),
                                   unknown.count);
     }
 }
 }
 
 
-static NSString* kTransferOpTitle[] = {@"Pull",@"Push",@"Clone"};
-
-
 - (IBAction) pushPullRevisions: (id)sender
 {
     HgTransferOp op = [sender tag];
-    NSString *defaultURL, *desc;
+    NSString *defaultURL, *desc, *buttonTitle;
     switch( op ) {
         case kHgPush: 
-            desc = @"Push revisions to repository at URL/file:";
+            desc = NSLocalizedString(@"Push revisions to repository at URL/file:", 
+                                     @"Prompt in Push sheet");
+            buttonTitle = NSLocalizedString(@"Push", @"Default button in Push sheet");
             defaultURL = [_repo.configFile valueForKey: @"default-push" inStanza: @"paths"];
             if( ! defaultURL )
                 defaultURL = [_repo.configFile valueForKey: @"default" inStanza: @"paths"];
             break;
         case kHgPull: 
-            desc = @"Pull revisions from repository at URL/file:";
+            desc = NSLocalizedString(@"Pull revisions from repository at URL/file:", 
+                                     @"Prompt in Pull sheet");
+            buttonTitle = NSLocalizedString(@"Pull", @"Default button in Pull sheet");
             defaultURL = [_repo.configFile valueForKey: @"default" inStanza: @"paths"];
             break;
         case kHgClone:
-            desc = @"Clone repository to URL/file:";
+            desc = NSLocalizedString(@"Clone repository to URL/file:", 
+                                     @"Prompt in Clone sheet");
+            buttonTitle = NSLocalizedString(@"Clone", @"Default button in Clone sheet");
             defaultURL = _repo.absolutePath;
             if( [defaultURL hasSuffix: @"/"] )
                 defaultURL = [defaultURL substringToIndex: defaultURL.length-1];
     [_pushURLField addItemsWithObjectValues: [_repo.configFile URLsForStanza: @"paths"]];
     
     [_pushDescriptionField setObjectValue: desc];
-    [_pushButton setTitle: kTransferOpTitle[op] ];
+    [_pushButton setTitle: buttonTitle];
     [_pullUpdateCheckbox setHidden: (op==kHgPush)];
     
     [NSApp beginSheet: _pushSheet
     }    
     
     static NSString* const kMessage[] = {@"Pulling from <%@>", @"Pushing to <%@>", @"Cloning to <%@>"};
-    
+    // NSLocalizedString(@"Pulling from <%@>", @"Progress message during Pull command")
+    // NSLocalizedString(@"Pushing to <%@>", @"Progress message during Push command")
+    // NSLocalizedString(@"Cloning to <%@>", @"Progress message during Clone command")}
+    NSString *msgFormat = [[NSBundle mainBundle] localizedStringForKey: kMessage[xferOp]
+                                                                 value: @""
+                                                                 table:nil];
     [self _startProgressForOperation: op
-                             message: [NSString stringWithFormat: kMessage[xferOp], url.absoluteString]
+                             message: [NSString stringWithFormat: msgFormat, url.absoluteString]
                       didEndSelector: didEnd
                              context: url];
 }
 {
     NSArray *files = self._uncommittedSelectedFiles;
     if( files )
-        NSBeginCriticalAlertSheet(@"Remove files from repository?",
-                                  @"Remove", @"Cancel", nil,
+        NSBeginCriticalAlertSheet(NSLocalizedString(@"Remove files from repository?",
+                                                    @"Title of Remove alert"),
+                                  NSLocalizedString(@"Remove", @"Default button of Remove alert"), 
+                                  NSLocalizedString(@"Cancel", @"Button"), nil,
                                   self.window,self,
                                   @selector(_removeSheetDidEnd:returnCode:context:), NULL, files,
-                                  @"Are you sure you want to remove the selected files from the repository?");
+                                  NSLocalizedString(@"Are you sure you want to remove the selected files from the repository?", 
+                                                    @"Body of Remove alert"));
 }
 
 - (void) _removeSheetDidEnd: (NSPanel*)sheet returnCode: (int)returnCode context: (void*)context
 {
     NSArray *files = self._uncommittedSelectedFiles;
     if( files )
-        NSBeginCriticalAlertSheet(@"Discard file changes?",
-                                  @"Discard", @"Cancel", nil,
+        NSBeginCriticalAlertSheet(NSLocalizedString(@"Discard file changes?", 
+                                                    @"Title of Discard alert"),
+                                  NSLocalizedString(@"Discard", 
+                                                    @"Default button of Discard alert"),
+                                  NSLocalizedString(@"Cancel", @"Button"), nil,
                                   self.window,self,
                                   @selector(_discardSheetDidEnd:returnCode:context:), NULL, files,
-                                  @"Are you sure you want to discard all uncommitted changes to the selected files?");
+                                  NSLocalizedString(@"Are you sure you want to discard all uncommitted changes to the selected files?", 
+                                                    @"Body of Discard alert"));
 }
 
 - (void) _discardSheetDidEnd: (NSPanel*)sheet returnCode: (int)returnCode context: (void*)context
     NSString *output;
     if( [_repo updateToRevision: rev output: &output error: &error] ) {
         if( ! output ) output = @"";
-        NSBeginInformationalAlertSheet(@"Update Completed",
+        NSBeginInformationalAlertSheet(NSLocalizedString(@"Update Completed", 
+                                                         @"Confirmation message after Update"),
                                        nil, nil, nil, self.window, nil, NULL, NULL, NULL,
                                        @"%@", output);
     } else        
         NSBeep();
         return;
     }
-    NSBeginCriticalAlertSheet(@"Update to revision?",
-                              @"Update", @"Cancel", nil,
+    NSBeginCriticalAlertSheet(NSLocalizedString(@"Update to revision?", 
+                                                @"Title of Update alert"),
+                              NSLocalizedString(@"Update", 
+                                                @"Default button of Update alert"),
+                              NSLocalizedString(@"Cancel", @"Button"), nil,
                               self.window,self,
                               @selector(_updateSheetDidEnd:returnCode:context:), NULL, rev,
-                              @"Are you sure you want to update the source tree to revision %i?",
+                              NSLocalizedString(@"Are you sure you want to update the source tree to revision %i?", 
+                                                @"Body of Update alert"),
                               rev.localNumber);
 }