[HD2 Android NAND Development] langthang:
Use APKTool to Decompile, Edit, Translate and Recompile an APK

Please help me translate my ROM to your languages then send me all strings were translated, I'll add them to my ROM​

Source from MIUI-AU

APKTool is an application (made by Brut.all) which decompiles and recompiles android APKs. If you know what you are doing, it also allows you to debug the smali code step by step. In our case it will enable us to build a language pack by translating the .xml strings inside APK files.

You need to do the following preparations (the video outlines these steps anyway):

Download the prepackaged APKTool zip.

Extract them to a directory you will remember.

Extract framework-res.apk AND apk files you want to decompile from the NDT MIUI ROM and copy them to the root directory of APKTool.

This step must be completed every time you are dealing with APKTool:

Open a command window

Navigate to the root directory of APKtool and type the following command:

apktool if framework-res.apk

The output should be:

I: Framework installed to: C:\Users\NDT\apktool\framework\1.apk

This step does the actual decompiling of the APK (I will assume that the chosen APK is Settings.apk):

apktool d Settings.apk

The output should be:

I: Loading resource table…

I: Decoding resources…

I: Copying assets and libs…

After doing that, a new directory with the name of the APK you decompiled should have been created. You need to:

Change into the newly created directory.

Change into the /res folder

Check to see if a values-xx folder exists, where xx is the two letter code of the target language to be translated into. For example, if you are aiming to translate into German, check for a values-de folder. If it does not exist (and chances are that if you are translating into a new language, that it will not exist), you need to create it. Then, copy the arrays.xml and strings.xml files from the /values folder into the folder you just created.

Open these two files (in Notepad ++) and alter the strings (the text in BLACK ONLY). Look out for things that look like %d and %s /’ - Don’t edit these, as they are variables. Also, if you see &, it represents the ‘&’ sign, so feel free to change it. Finally, you MUST be sure to place a backslash ‘\’ before an apostrophe, for example Proxy\’s would be the equivalent of Proxy’s.

Once you have translated and edited your arrays.xml and strings.xml files, save them, and return to the root directory of APKTool.

Open a command prompt to that directory

Enter the following command to recompile your edited and translated APK (assuming that Settings.apk is the chosen APK):

apktool b Settings

The output should be:

I: Checking whether sources has changed…

I: Smaling…

I: Checking whether resources has changed…

I: Building resources…

I: Building apk file…

You may get a couple of these messages:

aapt: warning: string ‘app_killed_message’ has no default translation in C:\Users\Josh\Desktop\NF\framework-res\res; found: fr it ja

aapt: warning: string ‘global_action_reboot’ has no default translation in C:\Users\Josh\Desktop\NF\framework-res\res; found: fr it ja

aapt: warning: string ‘reboot_system’ has no default translation in C:\Users\Josh\Desktop\NF\framework-res\res; found: fr it ja

aapt: warning: string ‘toast_reboot_recommend’ has no default translation in C:\Users\Josh\Desktop\NF\framework-res

However, it will build the apk anyway. These messages mean that some strings don’t have values. It is only an issues if the text im blue includes your translation language.

Open the new .apk by 7zip or winrar, then copy resources.arsc from it to old .apk file (overwite the old resources.arsc one with new one) and

Copy the resources.arsc from the /build directory into the original framework-res from the rom (just overwrite the old resources.arsc one with the new one) and you have a apk file was translate now