標籤:resources iphone titanium 中文 英文
用Titanium開發的ios應用中,當調用系統組件時,儘管手機已經設定了系統語言為中文,但那些組件的介面卻仍為英文。比如調用iphone中的相簿組件,其介面為:
650) this.width=650;" title="螢幕快照 2013-12-18 下午2.26.28" border="0" alt="螢幕快照 2013-12-18 下午2.26.28" src="http://images.cnitblog.com/blog/130623/201312/18145410-bfbf4ba5ded241ec9403dd610e99ff09.png" width="324" height="484" style="border:0px;padding-top:0px;padding-left:0px;padding-right:0px;background-image:none;" />
那麼怎麼讓它跟系統語言保持一致呢?
在原生的ios開發中,只需要在info.plist中把 CFBundleAllowMixedLocalizations 設定為 true 就行了,代表Localized resources can be mixed,就是允許庫使用本地語言資源。
那麼在Titanium中該怎麼做呢?
其實也很簡單,Titanium中提供了配置info.plist的方法,在tiapp.xml中配置就行。文檔可以查看:http://docs.appcelerator.com/titanium/latest/#!/guide/tiapp.xml_and_timodule.xml_Reference-section-29004921_tiapp.xmlandtimodule.xmlReference-plist
簡單來說就是在tiapp.xml中添加ios標籤,然後再在它下面添加plist子標籤
比如:
650) this.width=650;" title="QQ20131218144258" border="0" alt="QQ20131218144258" src="http://images.cnitblog.com/blog/130623/201312/18145411-cb7c0160f0414be5bf957df23f6681eb.png" style="border:0px;" />
至於有哪些索引值可用,這些索引值又是什麼意思,可以去查閱蘋果的開發文檔。
我們需要使用的是CFBundleAllowMixedLocalizations 這個鍵,把它設定為true就行了:
650) this.width=650;" title="QQ20131218144258" border="0" alt="QQ20131218144258" src="http://images.cnitblog.com/blog/130623/201312/18145412-29b0be196307448ea2a55eddc901f314.png" width="433" height="157" style="border:0px;padding-top:0px;padding-left:0px;padding-right:0px;background-image:none;" />
好了,重新編譯運行,然後再在應用中調用相簿,介面變成了中文的:
650) this.width=650;" title="螢幕快照 2013-12-18 下午2.50.12" border="0" alt="螢幕快照 2013-12-18 下午2.50.12" src="http://images.cnitblog.com/blog/130623/201312/18145413-77231d8339064cd0bc5cdb17331dc8c8.png" width="324" height="484" style="border:0px;padding-top:0px;padding-left:0px;padding-right:0px;background-image:none;" />
Titanium中調用ios組件時語言不是本地化的解決方案