Extended NSBundle localizations method for Android.

This commit is contained in:
Frederik Seiffert 2019-05-24 10:56:34 +02:00
parent ca76053c8e
commit 409030a367
2 changed files with 23 additions and 8 deletions

View file

@ -6,11 +6,13 @@
* Headers/Foundation/NSBundle.h:
* Source/NSBundle.m:
Added methods for passing Android asset manager from Java to GNUstep
and for getting AAsset/AAssetDir for given path in main bundle. Skip
app bundle suffix check on Android. Extended bundle resource paths
backbone to check for known paths directly on Android as we can't
enumerate directories. Extracted path cache cleaning into separate
method.
and for getting AAsset/AAssetDir for given path in main bundle.
Skip app bundle suffix check on Android. Extended bundle resource
paths backbone to check for known paths directly on Android as we
can't enumerate directories.
Extended -localizations method to check for known localizations
directly (requires setting userLanguages in NSUserDefaults).
Extracted path cache cleaning into separate method.
* Source/GSFileHandle.h:
* Source/GSFileHandle.m:
Added file handle support for reading Android assets from main bundle.

View file

@ -2540,10 +2540,23 @@ IF_NO_GC(
locale = [[locale lastPathComponent] stringByDeletingPathExtension];
[array addObject: locale];
}
#ifdef __ANDROID__
// TODO: check known languages for existance directly, as AAssetDir and thereby
// NSDirectoryEnumerator doesn't list directories
#endif
// Android: Check known languages for localizations directly, as AAssetDir
// and thereby NSDirectoryEnumerator doesn't list directories and the above
// call to list lproj resources will therefore come up empty.
NSArray *languages = [[NSUserDefaults standardUserDefaults]
stringArrayForKey: @"NSLanguages"];
for (locale in languages) {
NSString *path = [self pathForResource:@"Localizable" ofType:@"strings"
inDirectory:nil forLocalization:locale];
if (path) {
[array addObject: locale];
}
}
#endif /* __ANDROID__ */
return GS_IMMUTABLE(array);
}