2. 添加localisable.strings文件
3.选择这个文件,勾选多语言即可
4.打开localisable.strings文件,添加一些测试字符串:
localisable.strings (base)"LoginError" = "Error Login";"UsernameEmpty" = "Username Empty";"PasswordEmpty" = "Password Empty";"GetUserInfoError" = "Error Getting User Info";localisable.strings (english)"LoginError" = "Error Login";"UsernameEmpty" = "Username Empty";"PasswordEmpty" = "Password Empty";"GetUserInfoError" = "Error Getting User Info";localisable.strings (chinese)"LoginError" = "登录错误";"UsernameEmpty" = "用户名不能为空";"PasswordEmpty" = "密码不能为空";"GetUserInfoError" = "获取用户信息错误";
5. 添加helper函数 :
func localized() -> String{ return NSLocalizedString(self,comment: "") }
使用:
"LoginError".localized();
在mainlayout中字符串的本地化:
.../* Class = "UIbutton"; normalTitle = "button"; ObjectID = "oYr-T8-Q59"; */"oYr-T8-Q59.normalTitle" = "登录";/* Class = "UIbutton"; normalTitle = "CHANGE PASSWORD"; ObjectID = "pzP-ri-GfN"; */"pzP-ri-GfN.normalTitle" = "修改密码";...总结
以上是内存溢出为你收集整理的Swift中的本地化实现全部内容,希望文章能够帮你解决Swift中的本地化实现所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)