From 2776ee20e178628a7802a0fc603e06b5d1b24d0a Mon Sep 17 00:00:00 2001 From: dmoagx Date: Sat, 23 Jun 2012 22:37:03 +0000 Subject: * Fixes some cases of bad localizability * In Help viewer [HELP\nTOPIC] would not be recognized as link --- Source/SPCustomQuery.m | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'Source/SPCustomQuery.m') diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index e62c6c44..9cd81fe9 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -60,6 +60,7 @@ - (id)_resultDataItemAtRow:(NSInteger)row columnIndex:(NSUInteger)column; - (id)_convertResultDataValueToDisplayableRepresentation:(id)value whilePreservingNULLs:(BOOL)preserveNULLs truncateDataFields:(BOOL)truncate; ++ (NSString *)linkToHelpTopic:(NSString *)aTopic; @end @@ -3080,7 +3081,7 @@ // really nothing found? if (![theResult numberOfRows]) - return [NSString stringWithFormat:@"%@", NSLocalizedString(@"No results found.", @"No results found for a help search")]; + return [NSString stringWithFormat:@"%@", NSLocalizedString(@"No results found.", @"Mysql Help Viewer : Search : No results")]; } // Ensure rows are returned as strings to prevent data problems with older 4.1 servers @@ -3121,10 +3122,11 @@ } // Detect and generate cross-links. First, handle the old-style [HELP ...] text. - [desc replaceOccurrencesOfRegex:@"\\[HELP ([^\\]]*?)\\]" withString:[NSString stringWithFormat:@"[$1]", NSLocalizedString(@"Show MySQL help for", @"show mysql help for")]]; + [desc replaceOccurrencesOfRegex:@"(\\[HELP ([^\\]]*?)\\]" withString:[SPCustomQuery linkToHelpTopic:@"$1"]]; // Handle "see [...]" and "in [...]"-style 5.x links. - [desc replaceOccurrencesOfRegex:@"(See|see|In|in|and)\\s+\\[(?:HELP )?([^\\]]*?)\\]" withString:[NSString stringWithFormat:@"$1 [$2]", NSLocalizedString(@"Show MySQL help for", @"show mysql help for")]]; + //look-behind won't work here because of the \s+ + [desc replaceOccurrencesOfRegex:@"(See|see|In|in|and)\\s+\\[(?:HELP\\s+)?([^\\]]*?)\\]" withString:[NSString stringWithFormat:@"$1 $2",[SPCustomQuery linkToHelpTopic:@"$2"]]]; [theHelp appendFormat:@"
%@
", desc]; } @@ -3132,14 +3134,14 @@ if([tableDetails objectForKey:@"example"]){ NSString *examples = [[[tableDetails objectForKey:@"example"] copy] autorelease]; if([examples length]) - [theHelp appendFormat:@"
Example:
%@
", examples]; + [theHelp appendFormat:@"
%1$@
%2$@
",NSLocalizedString(@"Example:",@"Mysql Help Viewer : Help Topic: Example section title"), examples]; } } else { // list all found topics // check if HELP 'contents' is called if(![searchString isEqualToString:SP_HELP_TOC_SEARCH_STRING]) - [theHelp appendFormat:@"
%@ “%@”
", NSLocalizedString(@"Help topics for", @"help topics for"), searchString]; + [theHelp appendFormat:@"
%@
", [NSString stringWithFormat:NSLocalizedString(@"Help topics for “%@”", @"MySQL Help Viewer : Results list : Page title"), searchString]]; else [theHelp appendFormat:@"
%@:
", NSLocalizedString(@"MySQL Help – Categories", @"mysql help categories"), searchString]; @@ -3148,8 +3150,7 @@ [theResult setDefaultRowReturnType:SPMySQLResultRowAsArray]; for (NSArray *eachRow in theResult) { NSString *topic = [eachRow objectAtIndex:[eachRow count]-2]; - [theHelp appendFormat:@"
  • %@
  • ", - NSLocalizedString(@"Show MySQL help for", @"show mysql help for"), topic, topic, topic]; + [theHelp appendFormat:@"
  • %@
  • ",[SPCustomQuery linkToHelpTopic:topic]]; } [theHelp appendString:@""]; } @@ -3159,6 +3160,12 @@ return [NSString stringWithFormat:helpHTMLTemplate, theHelp]; } ++ (NSString *)linkToHelpTopic:(NSString *)aTopic +{ + NSString *linkTitle = [NSString stringWithFormat:NSLocalizedString(@"Show MySQL help for “%@”", @"MySQL Help Viewer : Results list : Link tooltip"),aTopic]; + return [NSString stringWithFormat:@"%1$@", aTopic, linkTitle]; +} + #pragma mark - #pragma mark WebView delegate methods -- cgit v1.2.3