InfoPlist.strings file works only in Base language

I am trying to localize my info.plist, but InfoPlist.strings are working only when I use Base language, when I add russian language and start my app on device(simulator) with russian language I see a content of Base language or if it doesn't exist content of info.plist file. What shoud I do to fix this issue?

Replies

First things first, you should look at the structure of your built binary to make sure that you’re building it correctly. Do the following and see what you get back:

$ find /path/to/My.app -name "Info*"

I’d expect to see something like this:

$ find AirPort.app -name "Info*"
…
AirPort.app/en.lproj/InfoPlist.strings
…
AirPort.app/Info.plist
…
AirPort.app/ru.lproj/InfoPlist.strings
…

You can then investigate each file directly:

$ /usr/libexec/PlistBuddy -c "Print :NSContactsUsageDescription" AirPort.app/Info.plist 
AirPort Utility will access your information to name your network or device.
$ /usr/libexec/PlistBuddy -c "Print :NSContactsUsageDescription" AirPort.app/en.lproj/InfoPlist.strings 
AirPort Utility will access your information to name your network or device.
$ /usr/libexec/PlistBuddy -c "Print :NSContactsUsageDescription" AirPort.app/ru.lproj/InfoPlist.strings 
Утилита AirPort получит доступ к Вашей информации для присвоения имени Вашей сети или устройству.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Next step, please.This hypothesis refuted.


$ /usr/libexec/PlistBuddy -c "Print :NSLocationAlwaysAndWhenInUseUsageDescription" Ezway.app/ru.lproj/InfoPlist.strings
Текст на русском языке

You only showed the key for one localisation. Do you have any other localisations? Also, is the key also in your main

Info.plist
?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I have only english and russian localisation, english is a Base language, earlier it works, and i was trying to create an english InfoPlist.strings, it didn't works too

$ /usr/libexec/PlistBuddy -c "Print :NSLocationAlwaysAndWhenInUseUsageDescription" Ezway.app/info.plist
We use the determination of your geolocation to record the coordinates of your trip

I have only english and russian localisation, english is a Base language, earlier it works, and i was trying to create an english

InfoPlist.strings
, it didn't works too

I don’t understand what you’ve written here (sorry) so I sat down to test my own understanding of how this should work. Here’s the structure of my app.

$ # The app uses base localation and is localised for English and German.
$ 
$ ls -ld xxsix.app/*.lproj
drwxr-xr-x  4 quinn  staff  136  3 Oct 09:30 xxsix.app/Base.lproj
drwxr-xr-x  5 quinn  staff  170  3 Oct 09:30 xxsix.app/de.lproj
drwxr-xr-x  3 quinn  staff  102  3 Oct 09:28 xxsix.app/en.lproj
$ 
$ # With English as the development language.
$ 
$ /usr/libexec/PlistBuddy -c "print :CFBundleDevelopmentRegion" xxsix.app/Info.plist 
en
$
$ # In the master `Info.plist` the string is upper case, so I can see it if it ever shows up on screen.
$ 
$ /usr/libexec/PlistBuddy -c "print :NSLocationAlwaysAndWhenInUseUsageDescription" xxsix.app/Info.plist 
_SOME_ENGLISH_TEXT_
$
$ # And the string is 'appropriately' localised in each `InfoPlist.strings`.
$ 
$ /usr/libexec/PlistBuddy -c "print :NSLocationAlwaysAndWhenInUseUsageDescription" xxsix.app/en.lproj/InfoPlist.strings 
Some English always-and-when-in-use text.
$ /usr/libexec/PlistBuddy -c "print :NSLocationAlwaysAndWhenInUseUsageDescription" xxsix.app/de.lproj/InfoPlist.strings 
Some German always-and-when-in-use text.

Here’s how I tested this:

  1. I reset the simulator (Hardware > Erase All Content and Settings), which puts it in English.

  2. I ran the app.

  3. I saw “Some English always-and-when-in-use text.” in the alert.

  4. I stopped the app.

  5. I reset the simulator again.

  6. I used Settings to change the localisation to German (I apologise for using German and French here but my ability to deal with non-Latin scripts is very poor).

    IMPORTANT After making the switch I removed English from the Preferred Language Order list, leaving just German, because that’s how normal users have the system configured.

  7. I ran the app.

  8. I saw “Some German always-and-when-in-use text.” in the alert.

  9. I repeated steps 5 through 7, this time selecting French.

  10. I saw “Some English always-and-when-in-use text.” in the alert, indicating that, in the absence of an appropriate localisation, the app has run in the development region.

This all seems to be working as I expected. Can you work through these steps and let me know where things are going wrong for you?

ps This is Xcode 9.0 with the iOS 11.0 simulator.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"