Reputation: 11
I need to access to the Settings.bundle and get the descriptions and titles with the localized string.
Upvotes: 0
Views: 228
Reputation: 11
In the end I did it this way:
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"];
NSBundle *settingsBundle = [NSBundle bundleWithPath:resourcePath];
NSURL *url = [settingsBundle URLForResource:@"Root" withExtension:@"plist"];
NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfURL:url];
NSArray *preferences = dictionary[@"PreferenceSpecifiers"];
for (NSDictionary *dic in preferences){
NSString *localizedTitle = NSLocalizedStringWithDefaultValue(dic[@"Title"], @"Root", settingsBundle, dic[@"Title"], @"");
}
Upvotes: 1
Reputation: 3177
Use NSLocalizedStringFromTableInBundle function. Create an instance of NSBundle
with URL of your bundle and use it as bundle
argument. Use “Root” as the table name for tbl
argument.
For example:
NSBundle *bundle = [[NSBundle alloc] initWithURL: ...];
NSString *string = NSLocalizedStringFromTableInBundle("SOME_KEY", "Root", bundle, "Comment");
Upvotes: 1