2012年6月29日 星期五

設定中文app name for Android


使用Titanium Studio設定中文app name

可依照 http://developer.appcelerator.com/blog/2012/02/internationalization-of-app-names.html

實作

但Android方面有點不同

首先 先發佈一次你的程式 發佈成功後

新建platform資料夾

platform裡 再新建 android資料夾

android內再新建res資料夾

並分別建立你想要對應的語系資料夾

中文則用values-zh 資料夾  英文則用values-en

再到build/android/AndroidManifest.xml (要先發佈過一次才會產生)  把此檔copy到

platform/android資料夾裡 (這是自己建立的資料夾)

與上面網址教學圖片不同  教學網站圖有誤

真正的路徑圖會變這樣



然後建立你的語系檔strings.xml為名

內容




<?xml version="1.0" encoding="UTF-8"?>

<resources>  

     <string name="app_name">中文測試</string>

</resources>





接下來 開啟AndroidMainifest.xml  修改成以下紅色地方



    <!-- TI_MANIFEST -->

    <application android:icon="@drawable/appicon"
        android:label=&quot;@string/app_name" android:name="TestApplication"
        android:debuggable="false">

        <!-- TI_APPLICATION -->

        <activity android:name=".TestActivity"
            android:label="@string/app_name" android:theme="@style/Theme.Titanium"
            android:configChanges="keyboardHidden|orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>



原本以為這樣就可以了  在Titanium Studio 1.8.2 記得是這樣的做法

但發現到Titanium Studio, build: 2.1.1.201206271720版本一直產生不出中文app name

後來 我到 tiapp.xml 內

將  的內容改成



<name>@string/app_name</name> 



就可以順利變中文囉

記得若用中文為名的話,在模擬器記得要去setting改語系才會顯示你對應的語系哦





================================================================
2012.12.18更新
若上述無法成功,

請試看看把build/android/AndroidManifest.xml 把此檔copy到

platform/android/res資料夾裡 (這是自己建立的資料夾)


此處要更新一下,在tiapp.xml內的



<name>是英文</name> 

不能改成最上面說的那樣,不然在distribute的時候會無正常發佈

沒有留言: