@implementation NSBundle(NGLanguageResourceExtensions)
+static BOOL debugLanguageLookup = NO;
+
// locating resources
- (NSString *)pathForResource:(NSString *)_name ofType:(NSString *)_ext
inDirectory:(NSString *)_directory
languages:(NSArray *)_languages
{
- NSFileManager *fm = [NSFileManager defaultManager];
+ NSFileManager *fm;
NSString *path = nil;
int i, langCount;
id (*objAtIdx)(id,SEL,int);
- path = _directory
+ if (debugLanguageLookup) {
+ NSLog(@"LOOKUP: %@ | %@ | %@ | %@",
+ _name, _ext, _directory, [_languages componentsJoinedByString:@","]);
+ }
+
+ path = [_directory isNotNull]
? [[self bundlePath] stringByAppendingPathComponent:_directory]
: [self bundlePath];
+ if (debugLanguageLookup) NSLog(@" BASE: %@", path);
+
+ fm = [NSFileManager defaultManager];
if (![fm fileExistsAtPath:path])
return nil;
- if (_ext) _name = [_name stringByAppendingPathExtension:_ext];
+ if (_ext != nil) _name = [_name stringByAppendingPathExtension:_ext];
langCount = [_languages count];
objAtIdx = (langCount > 0)
if ([fm fileExistsAtPath:lpath])
return lpath;
}
+
+ if (debugLanguageLookup)
+ NSLog(@" no language matched, check base: %@", path);
/* now look into x.bundle/Resources/name.type */
if ([fm fileExistsAtPath:[path stringByAppendingPathComponent:_name]])