//
//  Localization.h
//  DevonAppKit
//
//  Created by Christian Grunenberg on 02.03.07.
//

#import <Cocoa/Cocoa.h>

#define LOCALIZATION_H

@interface NSObject (DevonLocalizationExtensions)

-(NSArray *)localizableStrings;
-(NSDictionary *)localizableDictionary;
-(BOOL)writeLocalizableStringsToFile:(NSString *)file atomically:(BOOL)useAuxiliaryFile;

@end

// Localizes title, toolTip and submenus

@interface NSMenu (DevonLocalizationExtensions)

-(void)addLocalizableStringsToArray:(NSMutableArray *)strings;
-(NSUInteger)numberOfObjects;

-(void)localize;
-(void)localizeUsingTable:(NSString *)table;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;

-(void)localizeKeyEquivalents;
-(void)localizeKeyEquivalentsUsingTable:(NSString *)table;
-(void)localizeKeyEquivalentsUsingTable:(NSString *)table bundle:(NSBundle *)bundle;

-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Localizes title and toolTip

@interface NSMenuItem (DevonLocalizationExtensions)

-(void)addLocalizableStringsToArray:(NSMutableArray *)strings;

-(void)localize;
-(void)localizeUsingTable:(NSString *)table;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;

-(void)localizeKeyEquivalent;
-(void)localizeKeyEquivalentUsingTable:(NSString *)table;
-(void)localizeKeyEquivalentUsingTable:(NSString *)table bundle:(NSBundle *)bundle;

-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Localizes title and subviews

@interface NSWindow (DevonLocalizationExtensions)

-(void)addLocalizableStringsToArray:(NSMutableArray *)strings;
-(NSUInteger)numberOfObjects;

-(void)localize;
-(void)localizeUsingTable:(NSString *)table;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;

-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Localizes toolbar items

@interface NSToolbar (DevonLocalizationExtensions)

-(void)localize;
-(void)localizeUsingTable:(NSString *)table;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;
-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Localizes label, paletteLabel and toolTip

@interface NSToolbarItem (DevonLocalizationExtensions)

-(void)localize;
-(void)localizeUsingTable:(NSString *)table;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;
-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Localizes subviews

@interface NSDrawer (DevonLocalizationExtensions)

-(void)addLocalizableStringsToArray:(NSMutableArray *)strings;
-(NSUInteger)numberOfObjects;

-(void)localize;
-(void)localizeUsingTable:(NSString *)table;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;
-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Localizes toolTip, title, string and menu

@interface NSView (DevonLocalizationExtensions)

-(void)addLocalizableStringsToArray:(NSMutableArray *)strings;
-(NSUInteger)numberOfObjects;

-(void)localize;
-(void)localizeUsingTable:(NSString *)table;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;
-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Localizes title only if visible

@interface NSBox (DevonLocalizationExtensions)

-(void)addLocalizableStringsToArray:(NSMutableArray *)strings;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;
-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Localizes alternateTitle too

@interface NSButton (DevonLocalizationExtensions)

-(void)sizeToFitAndReposition;
-(void)addLocalizableStringsToArray:(NSMutableArray *)strings;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;
-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Doesn't localize title

@interface NSPopUpButton (DevonLocalizationExtensions)

-(void)addLocalizableStringsToArray:(NSMutableArray *)strings;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;
-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Localizes stringValue and placeholderString too

@interface NSTextField (DevonLocalizationExtensions)

-(void)addLocalizableStringsToArray:(NSMutableArray *)strings;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;
-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Localizes tableColumns and menus of data cells too

@interface NSTableView (DevonLocalizationExtensions)

-(void)addLocalizableStringsToArray:(NSMutableArray *)strings;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;
-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Localizes title and placeholderString of cells too

@interface NSMatrix (DevonLocalizationExtensions)

-(void)addLocalizableStringsToArray:(NSMutableArray *)strings;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;
-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

// Localizes label and view of tabViewItems too

@interface NSTabView (DevonLocalizationExtensions)

-(void)addLocalizableStringsToArray:(NSMutableArray *)strings;
-(void)localizeUsingTable:(NSString *)table bundle:(NSBundle *)bundle;
-(void)replaceString:(NSString *)oldStr withString:(NSString *)newStr;

@end

@interface NSNib (DevonLocalizationExtensions)

// All localizations
+ (void)writeLocalizableStringsOfMainNibFileOfBundle:(NSBundle *)bundle;
+ (void)writeLocalizableStringsOfNibsNamed:(NSString *)nibName;
+ (void)writeLocalizableStringsOfNibsNamed:(NSString *)nibName bundle:(NSBundle *)bundle;

// Current localization
+ (BOOL)writeLocalizableStringsOfNibNamed:(NSString *)nibName;
+ (BOOL)writeLocalizableStringsOfNibNamed:(NSString *)nibName bundle:(NSBundle *)bundle;

+ (BOOL)writeLocalizableStringsOfInstantiatedTopLevelObject:(id)aTopLevelObject ofNibNamed:(NSString *)nibName;
+ (BOOL)writeLocalizableStringsOfInstantiatedTopLevelObject:(id)aTopLevelObject ofNibNamed:(NSString *)nibName bundle:(NSBundle *)bundle;

+ (BOOL)writeLocalizableStringsOfInstantiatedTopLevelObjects:(NSArray *)topLevelObjects ofNibNamed:(NSString *)nibName;
+ (BOOL)writeLocalizableStringsOfInstantiatedTopLevelObjects:(NSArray *)topLevelObjects ofNibNamed:(NSString *)nibName bundle:(NSBundle *)bundle;

+ (BOOL)writeLocalizableStrings:(NSArray *)strings keys:(NSArray *)keys toFile:(NSString *)file atomically:(BOOL)useAuxiliaryFile;

// Return number of used top level objects
+ (NSUInteger)addLocalizableStringsOfInstantiatedTopLevelObjects:(NSArray *)topLevelObjects toArray:(NSMutableArray *)strings;
- (NSUInteger)instantiateAndAddLocalizableStringsToArray:(NSMutableArray *)strings;

@end
