|
How to Translate ANY ROM to another language
|
|
|
|
|

You will need:
- A tool to decompile an apk's sources and resources, ie; ApkChanger (or APKTool - See our guide)
- A ROM
- A suitable text editor which can read UTF-encoding, ie; Notepad++
- A knowledge of what you're translating or Google Translate ;)
- Time and patience

Method
Every Android ROM has the same basic directory structure; they all contain an app, framework, bin, etc, xbin.... directories. But to translate the entire ROM all we need to look at are the app and framework folders, unless your ROM has /data/app directory in the root directory.
If your ROM does include a /data/app directory then aswell as looking in the /system/app and /system/framework directories you must also look there. To begin with, we will translate the framework, which contains many of the system strings such as the power off menu strings.
So to begin editing these strings we must first decompile the apk, which can be found in /system/framework/framework-res.apk. I am using Apk Changer so I will explain the steps I take from here on in assuming you do too. Copy the framework-res.apk (always have a backup) into the folder "place-apk-here-for-modding", run the apkchanger .bat file. This will give you some options to choose from the first time it's ran, I will include my settings so that you are able to start straight away, if you would like to change any of the settings then choose the option 20 before you get started.
For most apk's the option we choose when decompiling is option 1, there are times when you may have to choose option 2 but I suggest you only use that option if you know what you are doing, we then set our current project which will be the first apk as we only deal with 1 apk at a time to simplify things. Once we have set our project we must choose what the script will decompile. I always choose option 3 as it allows me to edit the apk in it's entirity. The script will then decompile the apk and return us to the main screen. At this point we open the folder in the "apkchanger" directory named out.
This is where all the apk's resources and sources are decompiled to, to begin editing the language strings. We open the folders as shown in the structure folder ("/out/res/res/values"). This will list a number of files but the only one with which we are concerned is the strings.xml. If you are using Notepad++ and you already have it installed, right-click it and choose "Edit with Notepad++".
At this point you must know which part of the code is a displayed string, I will provide an example below of which part we need to edit;
MB
Edit only the part inside the arrows eg; >MB< becomes >mb<
So our new string will be;
mb
Sometimes the string will have a variable contained within it if it is displaying something which cannot be pre-written, eg; Email %s, will display the number of emails in your inbox.
To modify the string containing the variable we only have to adjust the text before/after the variable.
eg; Email %s becomes Mail %s
After you have worked your way through the strings file and corrected all of the relevant translations, you can save your newly modified xml. The best way to do this is just by clicking save instead of save as, this means the text editor will use the encoding format that the original file used.
You will find that some "values" folders will also have a file called "arrays", if this file is present then you must edit this aswell in order to have a complete translation of the apk.
The code in here is a tiny bit different to what you find in the strings.xml but it is basically the same, this is a sample piece of code from the arrays.xml;
- Normal
- Medium Vibrate
- Long Vibrate
- Multiple Short
- Multiple Long
- @string/pref_mms_custom_option
Again all we have to edit is the part in between the left and right arrows, like so;
- Edit Here
- Medium Vibrate
- Long Vibrate
- Multiple Short
- Multiple Long
- @string/pref_mms_custom_option
Notice that the top line; will always stay the same, changing this will cause you a lot of headaches and more than likely a lot of FC's, so I suggest you leave that one alone. Now that we're finished editing the arrays.xml we're done!
All we have to do now is recompile the apk. So lets go back to our command line window and select option 3. It will build the apk and if you have no errors ask you a few questions to best determine how it should re-compile the apk.

FAQ
First question; Is this a system app?
Answer; If you have taken the app from /system/app then yes, hit y.
Second question; Aside from signatures, would you like to copy over files you didn't edit?
Answer; Yes we do, as this wwill minimise the number of errors we may get, hit y.
Third question; Optimize your apk?
Answer; It's your decision, I generally do but it's not a requirment.
Fourth question; Sign your apk?
Answer; No. Never sign system apks. HIT N
Fifth question; Zipalign your apk?
Answer; Again, your decision, I tend to always do this but it's not required.
Sixth and final question; Replace original file?
Answer; It's upto you, I hit no as I like to have a backup, but just remember to rename the outputted apk to that of the original when building your ROM.

!IMPORTANT!
The script and me will both tell you to delete the resources.arsc file in the keep folder before continuing, if you do not do this you will get errors. You have been warned, twice.
Once you have deleted the resources.arsc, hit any key and let the script do it's magic. Once it's finished collect your translated apk in the folder named "place-apks-here-for-modding"
And that's it!
Thanks to JieeHD from the VillainROM team for this excellent guide!
|
|
|