Implementation of new package with multi language
I am implementing one mac application.Its window version is already implemented.Now i am facing the following issue:
Implementation of new package with multi language (user could choose the language of the application while installing the app). ie For the windows version of the software, when executing the installation file user could choose the language in which the application should be installed. I want this feature to included in the mac version. ie the while installing the app using the package created the user should be able to choose the language of installation.(Currently in the mac version multilanguage is implemented using NSLocalizedString so that the app displays language according to the machine language and the installation package is localized). But i specifically want the user开发者_开发知识库s to be able to choose the installation language of the app, while installing.Pls help to solve this issue….
Use NSString *locString = NSLocalizedStringFromTable(@"key", @"Japanese", @"comment for key");
instead ;)
Explanation:
If you look at NSLocalizedString
macro definition you will find that it actually calls -[NSBundle localizedStringForKey:value:table:]
method in which the last parameter is the localization file (ie: Localizable.strings). You can get available localizations with-[NSBundle localizations];
method.
This means that you could use it to directly access a localization file like this:
// This gets the localized string found in Japanese.strings for the key @"key"
NSString *locString = [thisBundle localizedStringForKey:@"key"
value:@"No translation"
table:@"Japanese"];
Or use the macro (Which is almost equivalent)
NSString *locString = NSLocalizedStringFromTable(@"key", @"Japanese", @"comment for key");
The difference is what happens when the given key is not available:
- the former returns
@"No translation"
- the latter returns the default localization for
@"key"
Please see NSBundle class reference for more details
Hope it helps
精彩评论