2015年6月3日 星期三

[Corona SDK] How to localize your APP title - Android part

In [Corona SDK] How to localize your APP title - iOS part, we have learn how to localize the APP title for iOS system.
For Android APP, such function is available in Enterprise version.
However, I think most people are using free version.
So..how should we do?

The Android apk file is just a compressed format.
First, we need to prepare two tools, one is apktool, the other is zipalign.
These two tools should be found in Android SDK.
If you don't have, please search them on internet.

We can put the apk file and related tools in the same folder.

myAndroidApp.apk is the target apk we want to modify.
For convenience, I create some bat files.
Let's look at their contents.
(The following actions are done in Windows environment)

apktool.bat
if "%PATH_BASE%" == "" set PATH_BASE=%PATH%
set PATH=%CD%;%PATH_BASE%;
java -jar -Duser.language=en "%~dp0\apktool.jar" %1 %2 %3 %4 %5 %6 %7 %8 %9
unpack.bat
apktool d %1
pack.bat
apktool b %1 -o %2
sign.bat
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore "my.keystore" %1 yourPassword
zipalign -v 4 %1 zip-%1 
del %1 
ren zip-%1 %1
Remember to change yourPassword as yours in sign.bat

1. In command shell, input unpack "myAndroidApp.apk"
It will unpack myAndroidApp.apk to the folder myAndroidApp
2. Enter the folder myAndroidApp\res\values, if the file strings.xml is there, open it.
If not, create a new one. 
Modify its content as:
<resources>
    <string name="appTitle">Your Title</string>
</resources>
3. If we want to add other languages, say French.
We need to create a new folder values-fr under myAndroidApp\res.
Again, create strings.xml under folder values-fr.
The content of  strings.xml is the same as what we do in step, except for that Your Title should be translated into French or any other titles you want.
4. For supporting a new language, we just repeat step 3, except for that the folder names are different.
For example, values-ja is for Japanese, while values-it is for Italian.
5. Return to the folder myAndroidApp, open file AndroidManifest.xml.
Search android:label="xxx" and change it to be android:label="@string/appTitle".
There should have two places. Both of them need to be modified.
Someone said that FileContentProvider should be modified as well.
However, if you do it, you will get run time error when you start the  APP.
6. In command shell, input  pack myAndroidApp  newApp.apk
7. In command shell, input  sign newApp.apk

Done...




沒有留言:

張貼留言