iOS Localization in swift

改用 swift 寫 ios 比 objective-c 快很多,多國語言的處理這一部份也變簡單很多。

Step 1:

Before starting localization work, make sure you have “Use Base Internationalization” checkmark selected.

Step 2:

Adding New Localization

 

 

Access localization sample code:

let alertTitle = NSLocalizedString("Welcome", comment: "")
let alertMessage = NSLocalizedString("Thank you for trying this app, you are a great person!", comment: "")
let cancelButtonText = NSLocalizedString("Cancel", comment: "")
let signupButtonText = NSLocalizedString("Signup", comment: "")

let alert = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: UIAlertControllerStyle.Alert)
let cancelAction = UIAlertAction(title: cancelButtonText, style: UIAlertActionStyle.Cancel, handler: nil)
let signupAction = UIAlertAction(title: signupButtonText, style: UIAlertActionStyle.Default, handler: nil)
alert.addAction(cancelAction)
alert.addAction(signupAction)
presentViewController(alert, animated: true, completion: nil)

 

 

詳全文:

https://medium.com/lean-localization/ios-localization-tutorial-938231f9f881

相關文章

寫留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *