Unable to Localize Custom Keyboard iOS
Asked Answered
H

1

8

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.

Hypercorrect answered 27/8, 2015 at 6:0 Comment(0)
H
2

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!

Hypercorrect answered 31/8, 2015 at 6:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.