Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to Localize Custom Keyboard iOS

I am trying to implement a keyboard extension, which can display keys depending upon the language chosen by the user in Settings of the device.

In Edit Scheme, I have correctly setup the Application Language and Application Region for both Container app and extension as shown:

enter image description here

But still my keyboard always open up in English(en-US) version.

In info.plist, I have already added mul for PrimaryLanguage:

<key>NSExtension</key>
    <dict>
        <key>NSExtensionAttributes</key>
        <dict>
            <key>IsASCIICapable</key>
            <false/>
            <key>PrefersRightToLeft</key>
            <false/>
            <key>PrimaryLanguage</key>
            <string>mul</string>
            <key>RequestsOpenAccess</key>
            <false/>
        </dict>

Moreover, I have localized key names.

enter image description here

I logged what language is being interpreted by app using:

    var lang : String = NSLocale.preferredLanguages()[0] as! String
    NSLog(lang)

Container app does detect correct language as ur. But keyboard Extension always picks up en-US. I am using xcode 6.4 and testing on Simulator iOS 8.4.

I am probably missing out a very small point here. Any suggestion is welcome. Thanks.

like image 720
NightFury Avatar asked Aug 27 '15 06:08

NightFury


1 Answers

Finally, found the solution. I was doing Localization in wrong way. Correct way is to keep English as First language for base, then other languages should follow along.

enter image description here

Moreover, in order to detect language correctly in simulator (for keyboard), you should also change Language and Region in the simulator along with Schema.

enter image description here

Hope it helps someone in future!

like image 87
NightFury Avatar answered Oct 21 '22 07:10

NightFury