dimanche 25 janvier 2015

[Guide]How to add custom local in localized device topic






Hello.

In this tutorial, I will try to explain how to add some language(s) in your phone when it's not implemented by the vendor (localized ROM).
I will not cover how to change the keyboard language (or layout) as there are a lot of free keyboards in the market with a lot of localizations. (In my case I need azerty French keyboard that is not implemented in my ROM).

I did it with KitKat (4.4.2) but should be ok with almost any version.

I'm French and living in Japan, I recently bought a Samsung Galaxy S4 who is restricted by Japanese vendor (DOCOMO) to only English, Japanese & Korean languages.
I've read a lot of things before I could add a language (French in my case) to system apps, and I could'nt find any good tutorial. Some people say you can't, some say you have to recompile your ROM :eek:, etc...
First, you could install something like "applocal2" for add your language in already translated apps, but of course, it will not work for the non-already translated apps (usually system apps).

As I'm new here, I coudn't post link, so google for them !

What you need :
In your device :
  • Your device must be rooted.

  • Root Browser or equivalent.

  • USB debugging turned on.

In your PC :
  • A Rom for your device with the language you want inside in the same version of Android. (Find it in sammobile.com site for Samsung devices).

  • sgs2toext4.jar. (Transform the system.img.ext4 from the extracted ROM to a readable format for the next tool)

  • ext2explorer. (Extract the files from the system.img.ext4)

  • Virtuous Ten Studio. (Don't have to present it !! The must have tool !!)

  • 7zip or equivalent.


What you have to know :
  • This is always dangerous to play with system files ! I'm not responsible if you broke your device !!

  • Always do a backup of the file you will modify ! I suggest you copy them on your PC and you keep them in the original folder with a modified name, as this you could maybe try to restore them via ADB if something is wrong.

  • You don't have to bother with the signature mode when recompiling system (only) apk (any of them are ok). But you should copy the "META-INF" folder & "AndroidManifest.xml" file from the original apk to the newly repacked apk. (First erase them from the newly created apk inside 7zip, then open the original apk with 7zip and copy and paste to the new apk).

  • When copying new apk from PC to device, first copy them in the /system/ folder, then change permission to 644 (rw-r--r--) before finally moving them to the original folder.


How it's work :
The principe, as you should understand, is to extract both your apks and the apks from the dowloaded ROM, copy the ressources in your language from it to your apks and then rebuild them.
In our case (at least mine :) ) these apks are in the folders :
  • /system/app/

  • /system/framework/

  • /system/priv-app/


Ok, here we GO !
  • 1st phase : extract the files from the downloaded ROM with the language you want.
    • Extract the ROM (.zip) with 7zip, and then extract again the resulting file (.tar.md5) with 7zip (you should have an error : don't care of it).

    • Open sgs2toext4.jar and past in it the file system.img.ext4. Wait it take time. It will produce a new file named : system.img.ext4.img

    • Open ext2explorer and choose open the previously created file. Then right click on it and save. Create a new folder (I named it sys), and press ok. Wait it take time.

    You now should have the /system/ directory extracted inside the sys directory with the apks who have your language in them.

  • 2nd phase : Find the apks you need to modify. This is actually the most harder part !
    There are a lot of apks in the 3 directories I say earlier. You don't have to translate all of them.
    The 1st one you should change is /system/framework/framework-res.apk. That give you the option of your language in the settings.
    • Launch VTS (Virtual Ten Studio) and click New Solution

    • Choose the file you want to open, then Import.

    • Project-Type must be Apk-Project.

    • Choose a Solution Name (for example Original_name_of_apk or Translated_name_of_apk), then Click Next.

    • Should be Basic Theming. Click Next.

    • Click Next.

    What I did is to open some of them one by one to see if there are localized languages in it.
    Here a non-exhaustive list of what I found :
    Some of them are the overlay by Samsung (TouchWizz), and some of them are Japanese version of app.
    Try to find yours (for example JContacts.apk could be SecContacts_OSup.apk in the downloaded ROM) by opening both versions and comparing the file /res/values/strings.xml.



    • /system/framework/twframework-res.apk

    • /system/framework/framework-res.apk

    • /system/priv-app/SystemUI.apk

    • /system/priv-app/Keyguard.apk

    • /system/priv-app/Jcontacts.apk

    • /system/priv-app/SecLauncher3.apk

    • /system/priv-app/SecPhone_JPN.apk

    • /system/priv-app/SecSafetyAssurance.apk

    • /system/priv-app/SecSettings.apk

    • /system/app/AccessControl.apk

    • /system/app/AssistantMenu.apk

    • /system/app/EasySettings.apk

    • /system/app/MultiWindowTrayService.apk

    • /system/app/SViewCoverService.apk




  • 3rd phase : Copy the language from one apk to another.
    Now you have found some apk to "translate", we must copy the /res/ folders we want from the decompiled apk of the ROM who contain your language to your original apk.
    Look in the /res/ folder in VTS and find the differents languages : they are /res/value-xx/ but you could have in some case /res/raw-xx & /res/xml-xx.
    Anyway,
    • Copy from the folder created by VTS all the directories who have the language you want (in Windows Seven it's : \Documents\Virtuous Ten Studio\Projects\Translated_name_of_apk\name_of_apk \Data\res) and copy them to the VTS directory of your original apk ( \Documents\Virtuous Ten Studio\Projects\Original_name_of_apk\name_of_apk\D ata\res).

    • In VTS, reopen or reload the original solution.

    • Click Build all in the top tab Home. Wait it finish.

    • Very important : As said before, open your original apk and the newly created apk ( \Documents\Virtuous Ten Studio\Projects\Original_name_of_apk\name_of_apk\B inary) with 7zip, and replace META-INF folder & AndroidManifest.xml file from the original one to the new one. This will sign your apk.

    • Copy the new apk on your device, and copy it in the /system/ folder.

    • Very important :Change permissions to 644 (rw-r--r--) with Root Browser in the device, and then move it to the original folder remplacing the original one.



That's it, now reboot, go settings, change language and see the changes !
I suggest you reboot after each change you made in case something goes wrong.

Notes :
  • In some case I had errors when decompiling apk. I had resolved that by remplacing the version of ApkTool in VTS by the last one (C:\Program Files (x86)\Virtuous Ten Studio\External\ApkTool) version apktool_2.0.0rc3.jar. Then remove the other 2.0.0 jar file.

  • In some case I couln't build the new apk because of errors in some layout files. I didn't manage to resolve that as the both ROM I have (mine and downloaded one) have the same issue.

  • If something goes wrong (but it shouldn't be), for example lot of messages "error xxx should close" just when you replace the apk before rebooting try to lanch an adb shell and to retrieve the original apk you had saved in the original dir by erasing the new one and rename the saved one. In some devices you have first to remount the system partion in rw as it's read only.







Aucun commentaire:

Enregistrer un commentaire