|
Q: How can I get the localized name of my Cocoa application?A: There are several different versions of the application name, all of which are readily available as an The application's canonical "short" name is defined by Listing 1: Getting the application short name from the main bundle.
NSString *appName =
[[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:(NSString *)kCFBundleNameKey];
The application's canonical "display name" is typically longer and is used by the Finder to display the bundle. Listing 2: Obtaining the application's display name.
NSString *appName =
[[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"CFBundleDisplayName"];
Note that it is possible for both of these preceding methods to return Listing 3: Acquiring the process name.
NSString *appName = = [[NSProcessInfo processInfo] processName];
Probably the most general approach, however, is to ask the Listing 4: Obtaining a general display name from NSFileManager
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSString *appName = [[NSFileManager defaultManager] displayNameAtPath: bundlePath];
For more information, see File System Overview: Display Names and the section "Localizing Your Application Name" in Internationalization Programming Topics: Localizing Pathnames. Document Revision History
Posted: 2007-09-21 |
|