From 4b39e586b5c5625b275a78f0efbc0a50e27e6a61 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Thu, 16 Apr 2009 04:30:29 +0000 Subject: [Author: dmaclach] Fixed up GTMUILocalizer to work properly with popup menus and alternate titles. Fixed up UnitTesting code to check for it. R=thomasvl DELTA=3175 (3151 added, 14 deleted, 10 changed) --- AppKit/GTMUILocalizer.m | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'AppKit/GTMUILocalizer.m') diff --git a/AppKit/GTMUILocalizer.m b/AppKit/GTMUILocalizer.m index cfeb401..2f756d3 100644 --- a/AppKit/GTMUILocalizer.m +++ b/AppKit/GTMUILocalizer.m @@ -152,6 +152,17 @@ } } + // Must do the menu before the titles, or else this will screw up + // popup menus on us. + [self localizeMenu:[view menu] recursively:recursive]; + if (recursive) { + NSArray *subviews = [view subviews]; + NSView *subview = nil; + GTM_FOREACH_OBJECT(subview, subviews) { + [self localizeView:subview recursively:recursive]; + } + } + // Then do titles if ([view isKindOfClass:[NSTextField class]]) { NSString *title = [(NSTextField *)view stringValue]; @@ -168,6 +179,17 @@ [view performSelector:@selector(setTitle:) withObject:localizedTitle]; } } + if ([view respondsToSelector:@selector(alternateTitle)] + && [view respondsToSelector:@selector(setAlternateTitle:)]) { + title = [view performSelector:@selector(alternateTitle)]; + if (title) { + NSString *localizedTitle = [self localizedStringForString:title]; + if (localizedTitle) { + [view performSelector:@selector(setAlternateTitle:) + withObject:localizedTitle]; + } + } + } } else if ([view respondsToSelector:@selector(tabViewItems)]) { NSArray *items = [view performSelector:@selector(tabViewItems)]; NSEnumerator *itemEnum = [items objectEnumerator]; @@ -183,14 +205,6 @@ } } } - [self localizeMenu:[view menu] recursively:recursive]; - if (recursive) { - NSArray *subviews = [view subviews]; - NSView *subview = nil; - GTM_FOREACH_OBJECT(subview, subviews) { - [self localizeView:subview recursively:recursive]; - } - } } } -- cgit v1.2.3