NSBundle not yet loaded for existing path

I am trying to implement a way to change the language inside an application.

I think I understood all this, but for some reason the folder is not loaded as a package

I have a folder named kh.lproj

NSString *path = [[NSBundle mainBundle] pathForResource:newLanguage ofType:@"lproj"]; if ([[NSFileManager defaultManager] fileExistsAtPath:path]) { bundle = [NSBundle bundleWithPath:path]; DLOG(@"Language: %@ from path %@ (%@)", newLanguage, path, bundle); } 

Output of my dlog

Language: kh from the path ........ / F 1AA1E74-A014-4331-BD1B-D05D0E54AFF3 / console.app / kh.lproj (NSBundle <....... / F1AA1E74-A014-4331-BD1B -D05D0E54AFF3 / console.app / kh.lproj> (not yet loaded))

On the iPhone and in the simulator (with different paths, of course).

I checked in the .app folder and there is the kh.lproj folder. (Lowercase).

Does anyone have an idea why this is happening? If I try to download a file that does not exist, it simply ignores it and does not try to download it.

EDIT

If this is for any help, when I use loadAndReturnError: (NSError), I get the message:

NSLocalizedFailureReason = package executable cannot be located., NSLocalizedDescription = Package "kh.lproj" cannot be loaded because its executable cannot be located. NSBundlePath = ....... / A65E8399-6CDB-4CAE-9074-803125E78BBA / storeconsole.app / kh.lproj

What does this error message mean?

+4
source share
1 answer

Looks like I get what I want when I call

 [bundle localizedStringForKey:key value:NULL table:nil]; 
0
source

Source: https://habr.com/ru/post/1442588/


All Articles