欢迎来到天天文库
浏览记录
ID:30768593
大小:207.36 KB
页数:8页
时间:2019-01-03
《ios应用内部切换语言,不跟随系统》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、网络上关于iOS国际化的文章很多,但基木上都是基于跟随系统语言的国际化,笔者就不赘述了・0-今天要讲的是不跟随系统的切换语言版本方案,即程序内部的切换语言版本方案。一、总则:应用内部语言不跟随系统语言,由应用自己进行控制,通过趾置多个语言文件,根据用户的选择动态获取不同文件夹下的语言文件,显示在界面上。最后把用户选择的语言持久化到本地,下次运行时读収。二、应用内的国际化1、新建工程新建SingleViewApplication工程,取名为MylnternationaLChooseoptionsf
2、oryournewproject:UseStoryboardsUxAutonit3、serInterfaceCoreDataCeoJSOSFileGPXFileResourceOtherI..;JPBbcocos2dv2.xAosx■1CocoaRichTextFileStringsFilecandC++UserInterfaceCc"Daia取名为hello(记得Targets要勾选项目)1JWhere:4、;i里用程序J'MylnternationalCroup_MylnternationalTargetsCancelCreate新建完成之后会生成helb.string文件,5、把它拖进SupportingFiles里。3、配置hello.string国际化首先配置刚才的helb.string文件。点击hello.strings文件,点击圈中的Makelocalized(本地化)。▼IdentityandTypeFileNamehello.stringsrlleTypeDefault-LocalizableStr...:LocationAbsolutePath:/Applications/hello.stringsFullPath/Applications/hello.6、stringsvLocalization▼TargetMembershipJMvlnternational只有English,没关系点击确定。。电祜Doyouwanttolocalizethisfile?hiThefilewillbemovedintotheIprojfolderforthefollowinglanguage.English:CancelLocalize4、配置项目国际化网络上很多配置方法不靠谱,因为新版的Xcode位置“+”号的位置换了。这里教大家正确的方法,点击项目一>选择7、Project->选择Info->点击“+”号。IiiISS©AEUu◄►'international八1target.iOSSDKh8、YCAppDcIcgatc.hmlYGAppDelegate.m川YCViewController.hm9、YCViewController.mYCViewController.Xib▼_SupportingFiles10、Mylnternational-lnfo.plistInfoPlist.stringsmmain.mhMylnternational-Prefix11、.pchxDefault.png•Default@2x.pngrDefault-568h@2x.png►Frameworks►_ProductsPROJECT▼Deployment!AMylntemationaliOSDep▼ConfiguratiorName►Debug►ReleaseUseReleast▼LocalizationsLanguageEnglishO匸r)UseBaseI当然也可以添加其他的语言。点击“+”号后,添加中文,弹出对话框,infoPlist是配置系统的国际化文件,可以12、配置图标之类的多语言环境,不属于本文范围。nib文件看需要配,这里选择不配。ResourceFileReferenceLanguage匚YCViewController.XibEnglish:Jhello.stringsEnglish:OInfoPlist.stringsEnglish:配置完成Z后,再看helb.string便分成了两个文件。▼hello.stringshello.strings(English)hello.strings(Chinese)完成上面的四步便完成了项冃内的多语言环
3、serInterfaceCoreDataCeoJSOSFileGPXFileResourceOtherI..;JPBbcocos2dv2.xAosx■1CocoaRichTextFileStringsFilecandC++UserInterfaceCc"Daia取名为hello(记得Targets要勾选项目)1JWhere:
4、;i里用程序J'MylnternationalCroup_MylnternationalTargetsCancelCreate新建完成之后会生成helb.string文件,
5、把它拖进SupportingFiles里。3、配置hello.string国际化首先配置刚才的helb.string文件。点击hello.strings文件,点击圈中的Makelocalized(本地化)。▼IdentityandTypeFileNamehello.stringsrlleTypeDefault-LocalizableStr...:LocationAbsolutePath:/Applications/hello.stringsFullPath/Applications/hello.
6、stringsvLocalization▼TargetMembershipJMvlnternational只有English,没关系点击确定。。电祜Doyouwanttolocalizethisfile?hiThefilewillbemovedintotheIprojfolderforthefollowinglanguage.English:CancelLocalize4、配置项目国际化网络上很多配置方法不靠谱,因为新版的Xcode位置“+”号的位置换了。这里教大家正确的方法,点击项目一>选择
7、Project->选择Info->点击“+”号。IiiISS©AEUu◄►'international八1target.iOSSDKh
8、YCAppDcIcgatc.hmlYGAppDelegate.m川YCViewController.hm
9、YCViewController.mYCViewController.Xib▼_SupportingFiles
10、Mylnternational-lnfo.plistInfoPlist.stringsmmain.mhMylnternational-Prefix
11、.pchxDefault.png•Default@2x.pngrDefault-568h@2x.png►Frameworks►_ProductsPROJECT▼Deployment!AMylntemationaliOSDep▼ConfiguratiorName►Debug►ReleaseUseReleast▼LocalizationsLanguageEnglishO匸r)UseBaseI当然也可以添加其他的语言。点击“+”号后,添加中文,弹出对话框,infoPlist是配置系统的国际化文件,可以
12、配置图标之类的多语言环境,不属于本文范围。nib文件看需要配,这里选择不配。ResourceFileReferenceLanguage匚YCViewController.XibEnglish:Jhello.stringsEnglish:OInfoPlist.stringsEnglish:配置完成Z后,再看helb.string便分成了两个文件。▼hello.stringshello.strings(English)hello.strings(Chinese)完成上面的四步便完成了项冃内的多语言环
此文档下载收益归作者所有