How to localise a string inside the iOS info.plist file?

后端 未结 12 1844
难免孤独
难免孤独 2020-11-22 17:13

As you might know the iOS 8 requires NSLocationWhenInUseUsageDescription key for using user\'s location. I have added this key and some gen

12条回答
  •  庸人自扰
    2020-11-22 17:28

    In addition to the accepted answer (the project is on Flutter but it's basically the same as native):

    I do have folders Base.lproj, en.lproj, xx.kproj. etc. with InfoPlist.strings in each. This file has lines like this (no quotes around the key and with a semicolon at the end):

    NSLocationWhenInUseUsageDescription = "My explanation why I need this";

    Check that you have your languages in your YourProject > Info:

    Also, check the project.pbxproj file, it is in XXX.xcodeproj/project.pbxproj: it should have all your languages in codes (en, fr, etc.)

    But even then it didn't work. Finally, I noticed the CFBundleLocalizations key in the Info.plist file. (to open it as raw key-values in XCode - right mouse button on the Info.plist file -> Open As -> Source Code) Make sure that the values in array are codes rather than complete words, for example fr instead of French etc.

    CFBundleLocalizations
    
        en
        ru
        lv
    
    

    And double-check that your device is set to the language you're testing. Cheers

    P.S. "Development Language" doesn't affect your issue, don't bother changing it.

提交回复
热议问题