IOS 8 NSLocationAlwaysUsageDescription custom translation
Asked Answered
H

3

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?

Heliozoan answered 30/10, 2014 at 14:37 Comment(1)
try to COPY the info.plist file in different ".lprj" folders ... and change the message accordinglySyphon
R
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.

Rioux answered 2/4, 2015 at 14:46 Comment(2)
Actually there is. Please check my answer.Cavin
Also, sometimes it's easier to check the official documentation. Paragraph "Localizing Property List Values" developer.apple.com/library/archive/documentation/General/…Vertical
C
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";
Cavin answered 10/7, 2015 at 10:27 Comment(3)
That's exactly what I do not want to do - I do not want to use standard localization mechanism.Heliozoan
This is correct but just a duplicate, Kyle Howells already provided the correct answer.Vertical
@Heliozoan 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.Vertical
R
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.

Rioux answered 2/4, 2015 at 14:46 Comment(2)
Actually there is. Please check my answer.Cavin
Also, sometimes it's easier to check the official documentation. Paragraph "Localizing Property List Values" developer.apple.com/library/archive/documentation/General/…Vertical
D
0

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

Dialectal answered 24/2, 2021 at 20:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.