aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-07-05 21:30:00 +0000
committerrowanbeentje <rowan@beent.je>2010-07-05 21:30:00 +0000
commit081cc9ece186c7c097ee51617a73780e2228eeea (patch)
tree96c6304eab0d40fe3cdb8c3af7fa5bc1f67da306
parentaf0ae49785ce3a95b7dbd85b4d90b253b037d586 (diff)
downloadsequelpro-081cc9ece186c7c097ee51617a73780e2228eeea.tar.gz
sequelpro-081cc9ece186c7c097ee51617a73780e2228eeea.tar.bz2
sequelpro-081cc9ece186c7c097ee51617a73780e2228eeea.zip
- Add support for localising menu item tooltips
- Add support for localising NSTextView value bindings' no selection placeholders, nil placeholders, not applicable placeholders and multiple selection placeholders
-rw-r--r--Source/DMLocalizedNibBundle.m21
1 files changed, 21 insertions, 0 deletions
diff --git a/Source/DMLocalizedNibBundle.m b/Source/DMLocalizedNibBundle.m
index 15b05f85..1d5949ee 100644
--- a/Source/DMLocalizedNibBundle.m
+++ b/Source/DMLocalizedNibBundle.m
@@ -25,6 +25,7 @@
+ (void)_localizeLabelOfObject:(id)object table:(NSString *)table;
@end
+static NSMutableArray *deliciousBindingKeys = nil;
@implementation NSBundle (DMLocalizedNibBundle)
@@ -35,6 +36,12 @@
NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init];
if (self == [NSBundle class]) {
method_exchangeImplementations(class_getClassMethod(self, @selector(loadNibFile:externalNameTable:withZone:)), class_getClassMethod(self, @selector(deliciousLocalizingLoadNibFile:externalNameTable:withZone:)));
+ deliciousBindingKeys = [[NSMutableArray alloc] initWithObjects:
+ NSMultipleValuesPlaceholderBindingOption,
+ NSNoSelectionPlaceholderBindingOption,
+ NSNotApplicablePlaceholderBindingOption,
+ NSNullPlaceholderBindingOption,
+ nil];
}
[autoreleasePool release];
}
@@ -114,6 +121,7 @@
} else if ([object isKindOfClass:[NSMenuItem class]]) {
NSMenuItem *menuItem = object;
[self _localizeTitleOfObject:menuItem table:table];
+ [self _localizeToolTipOfObject:menuItem table:table];
[self _localizeStringsInObject:[menuItem submenu] table:table];
@@ -169,6 +177,19 @@
for (NSTableColumn *column in [view tableColumns]) {
[self _localizeStringValueOfObject:[column headerCell] table:table];
}
+
+ } else if ([view isKindOfClass:[NSTextField class]]) {
+ NSDictionary *vb;
+ if (vb = [view infoForBinding:@"value"]) {
+ NSMutableDictionary *lvb = [NSMutableDictionary dictionaryWithDictionary:[vb objectForKey:NSOptionsKey]];
+ for (NSString *bindingKey in deliciousBindingKeys) {
+ if ([lvb objectForKey:bindingKey] == [NSNull null]) continue;
+ NSString *localizedBindingString = [self _localizedStringForString:[lvb objectForKey:bindingKey] table:table];
+ if (localizedBindingString)
+ [lvb setObject:localizedBindingString forKey:bindingKey];
+ }
+ [view bind:@"value" toObject:[vb objectForKey:NSObservedObjectKey] withKeyPath:[vb objectForKey:NSObservedKeyPathKey] options:lvb];
+ }
} else
[self _localizeStringsInObject:[control cell] table:table];