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

@ -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);
}