/* ** ITViewLocalizer.m ** ** Copyright (c) 2002, 2003 ** ** Author: Fabian, Ujwal S. Setlur ** Initial code by Kiichi Kusama ** ** Project: iTerm ** ** Description: localizes a view. ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #import "ITViewLocalizer.h" @interface ITViewLocalizer (Private) - (NSString*)localizedString:(NSString*)string; - (void)localizeWindow:(NSWindow*)window; - (void)localizeView:(NSView*)view; @end @interface NSButtonCell (UndocumentedRoutine) - (NSButtonType)_buttonType; @end @implementation ITViewLocalizer - (id)initWithTable:(NSString*)table bundle:(NSBundle*)bundle { self = [super init]; _table = [table retain]; _bundle = [bundle retain]; return self; } - (void)dealloc; { [_table release]; [_bundle release]; [super dealloc]; } + (void)localizeWindow:(NSWindow*)window table:(NSString*)table bundle:(NSBundle*)bundle; { ITViewLocalizer* localizer = [[[ITViewLocalizer alloc] initWithTable:table bundle:bundle] autorelease]; [localizer localizeWindow:window]; } + (void)localizeView:(NSView*)view table:(NSString*)table bundle:(NSBundle*)bundle; { ITViewLocalizer* localizer = [[[ITViewLocalizer alloc] initWithTable:table bundle:bundle] autorelease]; [localizer localizeView:view]; } @end @implementation ITViewLocalizer (Private) - (void)localizeWindow:(NSWindow*)window; { // localize window title NSString *windowTitle = [self localizedString:[window title]]; if (windowTitle) [window setTitle:windowTitle]; // localize window contentView [self localizeView:[window contentView]]; } - (void)localizeView:(NSView*)inView; { NSArray *subviews = [inView subviews]; int x, xcnt = [subviews count]; for (x=0;x