How can I translate location purpose strings?

How will I be able to translate location purpose strings? Will it use InfoPlist.strings, or Localizable.strings? I assume that the purpose key will not be shown to the user.

If I have my Info.plist set up as such:

Code Block
<key>NSLocationTemporaryUsageDescriptionDictionary</key>
<dict>
<key>Purpose1</key>
<string>Purpose1TranslatedPhrase</string>
<key>Purpose2</key>
<string>Purpose2TranslatedPhrase</string>
</dict>


Should my InfoPlistStrings file look like?:

Code Block
"Purpose1TranslatedPhrase" = "We use your location to do a thing";
"Purpose2TranslatedPhrase" = "We use your location to do something very different";


Thanks
It would be best if it could be done via InfoPlist.strings, similar to other permission strings, like this:

Code Block
"NSLocationTemporaryUsageDescriptionDictionary.Purpose1" = "We use your location to do a thing";
"NSLocationTemporaryUsageDescriptionDictionary.Purpose2" = "We use your location to do something very different";

I just noticed in the docs for requestTemporaryFullAccuracyAuthorizationwithPurposeKey:

To localize a usage description, add an entry to your InfoPlist.strings file with the same key you provide for this parameter.

So for following structure of the plist:
Code Block
<key>NSLocationTemporaryUsageDescriptionDictionary</key>
<dict>
<key>TempLocationPurposeYetis</key>
<string>We use your location to find Yetis nearby</string>
<key>TempLocationPurposeHaunted</key>
<string>We use the temporary location to display nearby haunted houses</string>
</dict>

Your InfoPlist.strings should be:
Code Block
"TempLocationPurposeYetis" = "We use your location to find Yetis nearby";
"TempLocationPurposeHaunted" = "We use the temporary location to display nearby haunted houses";

Tested on Xcode 12 beta 2 + iOS 14 beta 3


This doesn't seem to be working on Xcode 12 beta 6 and iOS 14 beta 6.
Does anybody know of an alternative method?
@yusuffromnull

It does work on Xcode 12.0.1.
  • Make sure you add the keys in InfoPlist.strings

  • Change device language for testing (not from Xcode).

How can I translate location purpose strings?
 
 
Q