简体   繁体   中英

iOS Localization using Xib & Swift: Can someone help me to make an multilingual app using XIB (not Storyboard) and Swift?

I searched for tutorials for localization but all are for storyboard, my app is made up in xib. I also want to make the language change option inside my app using buttons, instead of changing it from Settings.

You can use XMLParser for this feature.

  • Place all your string inside an XML file and then read data from a file for the selected language.
  • In delegate get a dictionary or key-value pair for string and then assign it to the label.

在此处输入图片说明

Ex:

    let xmlParser: XMLParser = XMLParser()
    xmlParser.delegate = self
    xmlParser.parseXml(withLanguageIndex: baseIndex)

// In delegate XMLParserDelegate

func getValues(_ valueDict: [AnyHashable: Any]) {
    stringsXMLDict = valueDict
}

Hope it will help you. Happy Coddling:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM