Titanium中調用ios組件時語言不是本地化的解決方案

來源:互聯網
上載者:User

標籤: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組件時語言不是本地化的解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.