How to set default language to Arabic ios swift?

心不动则不痛 提交于 2019-12-11 00:11:14

问题


I'm working on a app that is 2 languages namely english and Arabic. I've written the app in english and then localized the app in Arabic. The App needs to restart when changing the Language. My only question is that how can I set the default language to arabic when installing the app for the first time.I've Tried setting the Language to arabic in Edit schemes section, But it only works for the development build not for the Distribution builds. It may be duplicate question but I've tried and not succeeded.


回答1:


For change language "on the fly" you can use L10n-swift pod.

But to rtl you need set semanticContentAttribute appearance for UIView

let isRTL = Locale.characterDirection(forLanguage: yourLanguageIdentifier) == .rightToLeft

UIView.appearance().semanticContentAttribute = isRTL 
    ? .forceRightToLeft  
    : .forceLeftToRight



回答2:


According to the documentation, this is basically what happens:

1) iOS will search your app for the preferred languages it has on the Settings. So if your device is set to Arabic, it should go for Arabic laguage first.

2) If no languages are found, iOS will turn to the language of the app's development region, so you should set it also.

Here you can find more information on how to set your app's development region (CFBundleDevelopmentRegion) on Plist file.



来源:https://stackoverflow.com/questions/44048510/how-to-set-default-language-to-arabic-ios-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!