6

I understood that I can have localized NSLocationAlwaysUsageDescription text using standard iOS localization mechanism. Since we are using our custom dynamic localisation mechanism I wonder if there is another way to translate that string. I thought of editing application info.plist file on app start, but it seems to be read only.

Can I change this value from withing the app?

Misha
  • 5,260
  • 6
  • 35
  • 63

3 Answers3

13

There is a way. Add a new Strings file called "InfoPlist". Then localize it using a Localize button in attributes inspector and add localizations to the InfoPlist's keys. To localize CLLocation premission's description add in every version proper key and loacalised value.

//English file
"NSLocationAlwaysUsageDescription" = "English description";

_

//Polish file
"NSLocationAlwaysUsageDescription" = "Polski opis";
Kubba
  • 3,390
  • 19
  • 34
  • 1
    That's exactly what I do not want to do - I do not want to use standard localization mechanism. – Misha Jul 12 '15 at 08:16
  • This is correct but just a duplicate, Kyle Howells already provided the correct answer. – albertodebortoli Apr 24 '20 at 17:30
  • @Misha if you don't want to use the standard, find a way to override the content of the info.plist at build time, but you need multiple targets for country/language, which I really hope you don't have. – albertodebortoli Apr 24 '20 at 17:33
11

There's no way to use a custom localisation system with the info.plist strings.

That part of your app will have to use iOS's default localisation mechanism.

This is how to localise the location request description with iOS's built in strings file localisation system.

// English.strings file
"NSLocationAlwaysUsageDescription" = "English description";

// AnotherLanguage.strings
"NSLocationAlwaysUsageDescription" = "ajbdknfuied wibnrf";

EDIT: At everyone down voting me. The question asked about using a custom "custom localisation system". They explicitly said they did not want to use the built in localisation system, but instead their own custom one. That is why I said it was impossible.

Localising NSLocationAlwaysUsageDescription is completely possible. Using your own custom localisation system to do it is not.

Kyle Howells
  • 3,008
  • 1
  • 25
  • 35
  • Actually there is. Please check my answer. – Kubba Jul 10 '15 at 10:28
  • Also, sometimes it's easier to check the official documentation. Paragraph "Localizing Property List Values" https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html – albertodebortoli Apr 24 '20 at 17:40
0

I tried using the answers above, but had no luck until I used the information in this much more helpful thread.

jon
  • 3,202
  • 3
  • 23
  • 35