discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About internationalization, again


From: David Chisnall
Subject: Re: About internationalization, again
Date: Thu, 5 Feb 2009 19:31:17 +0000


On 5 Feb 2009, at 19:12, Germán Arias wrote:

Hi, after try many ways to internationalize my app, I do that with two
gorm files, one in English and other in Spanish. Then I add in the
main.m file this

 NSArray *lenguajes = [NSUserDefaults userLanguages] ;
 NSString *preferido = [lenguajes objectAtIndex: 0] ;

These lines are before you create the autorelease pool. Most GNUstep methods require an autorelease pool to exist.

 CREATE_AUTORELEASE_POOL (pool);

This line should be first.

 NSApp = [NSApplication sharedApplication];

 if([preferido hasSuffix: @"Spanish"])
 {
 [NSBundle loadNibNamed:@"Trad2_es.gorm" owner:NSApp];
 }
 else
 {
 [NSBundle loadNibNamed:@"Trad2.gorm" owner:NSApp];
 }

 [NSApp run] ;

None of this is required. If you put your resources in English.lproj/ Spanish.lproj/ (Espanol.lproj/ ?) and so on, and set them as localised resources in the GNUmakefile then the correct one will be picked from the user's preferences.

Note that your version will pick English even if the user's preferences are Portuguese then Spanish then English.

 [NSApp release] ;
 [pool realese] ;

You don't really need to do this. All memory will be cleaned up by the OS when the app exits. Things that need to do something before the app exits should listen for NSApplicationWillTerminateNotifications, rather than relying on - dealloc being called.

 return NSApplicationMain (argc, argv);

This line is entirely wrong. When the app exits, it will then enter NSApplicationMain, which creates NSApp and runs the app...

David



reply via email to

[Prev in Thread] Current Thread [Next in Thread]