Reputation: 557
I'm using Apples Photos Framework to load PHAssetCollections into my app. I Always get the english name of the smart collections. For instance I get 'Favorites' instead of 'Favoriter' (Swedish). I thought the localizedTitle property would return the language the Simulator or the iPhone ran. (Running on a iPhone with Swedish language and region).
Has anyone else encountered this? Example code:
NSArray *collectionsFetchResults;
NSMutableArray *localizedTitles = [[NSMutableArray alloc] init];
PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum
subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
PHFetchResult *syncedAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum
subtype:PHAssetCollectionSubtypeAlbumSyncedAlbum options:nil];
PHFetchResult *userCollections = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil];
// Add each PHFetchResult to the array
collectionsFetchResults = @[smartAlbums, userCollections, syncedAlbums];
for (int i = 0; i < collectionsFetchResults.count; i ++) {
PHFetchResult *fetchResult = collectionsFetchResults[i];
for (int x = 0; x < fetchResult.count; x ++) {
PHCollection *collection = fetchResult[x];
localizedTitles[x] = collection.localizedTitle;
NSLog(@"%@", collection.localizedTitle); //<= Always prints english names
}
}
Upvotes: 8
Views: 2007
Reputation: 1
ProJect -> Localizations -> "+ Chinese(simplified)"enter image description here
Upvotes: -1
Reputation: 12719
The reason for why collection.localizedTitle
doesn't return any other language because your app has only one Localization that is English
. This is definitely an Apple Bug, but here is a hack follow these steps.
sv.lproj
apart from en.lproj
folder that you already have.Update
If you want to add more languages easily after adding the blank text, you can add like showed in other answer by selecting Project, and in Localization section add language and choose blank file again, as we don't want to localize other files.
Hope it helps, if doubt ask here.
Cheers.
Upvotes: 5
Reputation: 126
I think you should just make sure you app support Swedish. Add the language you want to support Swedish for example
Upvotes: 3
Reputation: 126107
Your problem might be that none of your fetches explicitly or implicitly return the built-in Favorites smart album. (Also, it'd help with diagnosis to get your code down to examining the results of only one fetch, so you could figure out which one contains the non-localizing "Favorites".)
If you explicitly want the Favorites collection, search for it with the PHAssetCollectionSubtypeSmartAlbumFavorites
collection subtype. (It shouldn't result from a search for regular album or synced album, and I'd be surprised to see it in top level user collections, since that's documented to return only user-created collections.)
If either explicitly requesting the Favorites smart album is returning a non-localizing version, or one of your other fetches is returning the Favorites smart album and it isn't localizing, that's probably an Apple bug — I'd recommend telling them about it.
Upvotes: 0