How to Localize NSPhotoLibraryUsageDescription key (ALAssets)
There is a file you can create (which may be created for you when you create a project) called InfoPlist.strings
. This file is used and localized much like the file Localizable.strings
.
In it you would have and entry something like:
NSPhotoLibraryUsageDescription = "Test of new Photos warnings";
Note that there are no quotation marks around the key
I think as long as the key is included in info.plist
, it will localized using the value in InfoPlist.string
if it is available for the language. Otherwise it will use whatever is defined in info.plist.
The only way to make this work for me was in Xcode to:
1) Go to Project target -> Info-> Localization-> Add localization
Added language there. This operation created the <projectName>/<LanguageInitials>.lproj
folder.
2) I created file InfoPlist.strings inside the folder <projectName>/<LanguageInitials>.lproj
;
3) I added the text:
NSPhotoLibraryUsageDescription = "<Add your translated text here>";
inside that InfoPlist.strings
file.
4) I then added that folder to the project with File -> add new files to the project
or drag and drop.
Note: to test this I:
Cleaned cache, set the language on simulator to be the new one, edited the language in scheme to be the new one at running on simulator and restarted the simulator.
I have my note here https://github.com/onmyway133/notes/issues/290, or you will get
Missing Info.plist key - This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data. Once these issues have been corrected, you can then redeliver the corrected binary.
Make sure
- You declare the keys in Info.plist
- You localize it in InfoPlist.strings
- You don't need double quotes, like
"NSPhotoLibraryUsageDescription" = "Test of new Photos warnings";
, you can just useNSPhotoLibraryUsageDescription = "Test of new Photos warnings";