我可以将我的iOS应用程序本地化为西班牙语或德语,而将其余电话保留为英语吗? [英] can I localize my iOS app to Spanish or German while keeping the rest of the phone in English?

查看:97
本文介绍了我可以将我的iOS应用程序本地化为西班牙语或德语,而将其余电话保留为英语吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户希望将我们的iOS应用语言设置与用户的iPhone语言完全分开.基本上,在应用程序内部,用户选择应用程序的语言,然后,应用程序的UI和文本都会更改为所选语言.这比Apple的本地化标准更灵活,并且它们不能解决这种情况.是否有一些关于如何做到这一点的最佳实践?

users want to keep our iOS app language setting totally separate from the user's iPhone language. Basically, inside the app itself, the user selects the App's language, and then the app's UI and text all changes to the selected language. This is more flexible than Apple's localization standards, and they don't address this situation. Is there some agreed upon best practice as to how to do accomplish this?

具体来说,用户可能希望使用西班牙语的应用程序界面,但电话的其余部分仍为英语.

Specifically, a user might want the app's interface in Spanish, but the rest of the phone remains in English.

谢谢!

推荐答案

首先创建这样的语言代码和语言名称的字典

First create a dictionary of language code and language names like this

let applicationLanguages = ["de":"German","es":"Spanish"]

然后,当用户可以选择特定语言,然后在单击任何按钮后,调用此功能并终止该应用.

then when user can select particular language then after clicking on any button call this function and kill the app.

func setLanguage(languageCode: String){
        let languageArray = NSArray(objects: languageCode)
        UserDefaults.standard.set(languageArray, forKey: "AppleLanguages")
        UserDefaults.standard.synchronize()
        UserDefaults.standard.set(true, forKey: "changedLanguage")
        UserDefaults.standard.set(languageCode, forKey: "AppLanguage")

    }

然后显示所选语言的警报,然后单击确定以终止应用程序.

Then show alert of selected language, then on the click of ok kill the app.

 func endBackgroundTask() {
     exit(0)
  }

这篇关于我可以将我的iOS应用程序本地化为西班牙语或德语,而将其余电话保留为英语吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆