项目作者: HazemKhaled

项目描述 :
Appcelerator Titanium RTL/RTL application
高级语言: JavaScript
项目地址: git://github.com/HazemKhaled/Titanium_RTL_guide.git
创建时间: 2016-01-18T09:45:48Z
项目社区:https://github.com/HazemKhaled/Titanium_RTL_guide

开源协议:MIT License

下载


Steps for Titanium RTL Application:

1 - Use this module to force language change, it’ll load correct strings link
2 - Add android:supportsRtl="true" to tag in tiapp.xml

  1. <android xmlns:android="http://schemas.android.com/apk/res/android">
  2. <manifest>
  3. <application android:supportsRtl="true" ></application>
  4. </manifest>
  5. </android>

3 - Use if in .tss file to switch RTL & LTR

  1. // alloy.js
  2. Alloy.Globals.isRTL = Ti.Locale.currentLanguage === 'ar';
  1. '#exampleLabel' : {
  2. color: red'
  3. }
  4. '#exampleLabel[if=Alloy.Globals.isRTL]' : {
  5. right: 5
  6. }
  7. '#exampleLabel[if=!Alloy.Globals.isRTL]' : {
  8. left: 5
  9. }

4 - Set iOS 9+ is minimum in tiapp.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <ti:app xmlns:ti="http://ti.appcelerator.org">
  3. <ios>
  4. <min-ios-ver>9.0</min-ios-ver>
  5. </ios>
  6. </ti:app>

5 - Set Android 4.2 as minimum

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <ti:app xmlns:ti="http://ti.appcelerator.org">
  3. <android xmlns:android="http://schemas.android.com/apk/res/android">
  4. <manifest android:versionCode="17">
  5. <uses-sdk android:minSdkVersion="17"></uses-sdk>
  6. </manifest>
  7. </android>
  8. </ti:app>

This items flip from/to RTL/LTR fine

iOS 9+

  1. LeftNavButton & RightNavButton
  2. Default ListView/TableView templates
  3. Window open transition come from right with RTL and left with LTR
  4. CollectionView list items from top right with RTL and top left with LTR

Android 4.2+

  1. ActionBar and menus items flip RTL/LTR with zero code
  2. Drawer layout come from right instead of left

Current Titanium issues RTL support issues

  1. linearlayout (horizontal/vertical layout) will not flip, Titanium calculate positions manually, same with autolayout in iOS. ref
  2. Natural direction for the text supported nativly in both iOS and Android, while Titanium has only right, left and center allignment. Android iOS
  3. Titanium has no API to change local, but we can use this module
  4. Titanium has an issue to re-open the hole UI stack on iOS, so change loal will load strings from the new selected file but will not wich RTL/LTR till you close the app and open it again.