Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,741,682 Members 43,113 Now Online
XDA Developers Android and Mobile Development Forum

[Guide][WIN-Utility] Porting, adding languages from ROM apk files to another (19/Jul)

Tip us?
 
majdinj
Old
(Last edited by majdinj; 19th July 2013 at 02:14 PM.) Reason: update utility to v1.05
#1  
majdinj's Avatar
Recognized Contributor / Themer - OP
Thanks Meter 2922
Posts: 980
Join Date: Nov 2006
Location: AlAhsa
Prompt [Guide][WIN-Utility] Porting, adding languages from ROM apk files to another (19/Jul)


This tutorial is going to help ROM chiefs on how to add and integrate different languages and csc codes from different regions in their cooked custom ROM


Have you ever wanted to port your language across custom ROMs but you don't know how?
Yes after searching the xda, you knew that you need to integrate your language value folder in each ROM apk in order to have your language ported to the custom ROM; however heh, it will be very long journey of decompiling and compiling, making integrating your language value folder in each ROM apk is like a hell..!!

So from this side, I decided to make a tool that will decompile and extract languages values folders and after extracting all values folders from all apks of the same name (e.g, SystemUI.apk) from all ROMs' different regions, you can integrate all languages in one multi-languages apk; making the whole process a much less painful than the manual way..!!
So in short, this tool will add languages from ROM's apk files to another of the same name..

How to use:
1. Run apk-lang-extractor.bat file; this will create all needed folders.
2. Install your ROM dependencies (Only once) by putting them in "put-dependencies-here" folder and choose option #0.
3. Put all same apks from different region ROM's releases in "put-apk-here" folder; you can give them numbers in order to not get confused; ensure no space in apk name (e.g, SystemUI1.apk, SystemUI2.apk, SystemUI3.apk... etc).
4. Set Current-apk for one of them (option #1), and start extracting job (option #2) and do the same for the rest of apk files.
5. Let the apk file that you will integrate all languages in to be the last apk to extract the languages from; this is important to ensure the least error during compiling.
6. After you extracted all languages from all apk files, and being the last extracted apk is set as Current-apk, start languages integrating process (option #3) that will result in one apk file that contains all extracted languages.




Credits:
1. Igor Pavlov: for 7za command line.
2. Brut.all & iBotPeaches: for the awesome apktool.jar
3. atomicdryad: for SignApk.jar
4. Google: for android SDK

and to dedicate the contribution of such elite developers, the credits are shown in the utility splash screen..






- apk-languages-Extractor-Integrator_v1.05 @19/July/2013 - [the most recent]
- apk-languages-Extractor-Integrator_v1.00 @ 17/July/2013 - [old]


Change-log:
@ 19/July/2013 (v1.05):
- Fixed error message during language integration "The process cannot access the file because it is being used by another process".
- Fixed compression function. Now the whole final apk file is compressed by level specified, instead of signature only (my bad!!).
- Fixed open "finished-apk" folder delay after language integrating process.
- Deleting existing signed file apk of same name before signing (no more overlapping).
- New option added in the main menu to link the utility with this thread page (you can check update anytime now).

@ 17/July/2013 (v1.00):
- First release.


You just finished integrating languages values folders in each apk file in your custom ROM; however, we haven't finish porting languages yet..!! Continue with the next post


The Following 12 Users Say Thank You to majdinj For This Useful Post: [ Click to Expand ]
 
majdinj
Old
(Last edited by majdinj; 17th July 2013 at 12:14 PM.)
#2  
majdinj's Avatar
Recognized Contributor / Themer - OP
Thanks Meter 2922
Posts: 980
Join Date: Nov 2006
Location: AlAhsa

<<In this post, we will concentrate on making the added languages visible and usable in your cooked ROM. Also we will learn how to add different CSC code regions in the cooked ROM>>


How to add languages to language display and language input:
1. Navigate to system\csc\common\system\csc folder and open language.xml file. Here we will concentrate in this section:
Code:
Select Code
   <LanguageSet>
          <Display>   <!-- This section is for displayed languages
          en_GB;en_US;fr_FR;
          ar_AE;fa_FA;ur_PK;
          </Display>
          <Input>   <!-- This section is for input languages
                <SupportList>
        	en_GB;en_US;fr;ar;fa;ur;
                </SupportList>
                <EnableList>
                </EnableList>
          </Input>
   </LanguageSet>
for each section you can add iso code language for each region. Here is the code again after applying iso code languages:
Code:
Select Code
   <LanguageSet>
          <Display>
		  en_GB;ar_AE;az_AZ;bg_BG;ca_ES;cs_CZ;da_DK;de_AT;de_CH;de_DE;
		  el_GR;en_AU;en_IE;en_NZ;en_PH;en_US;en_ZA;es_ES;es_US;et_EE;
		  eu_ES;f_FI;fa_FA;fr_CH;fr_FR;ga_IE;gl_ES;hr_HR;hu_HU;hy_AM;
		  in_ID;is_IS;it_IT;ka_GE;kk_KZ;ko_KR;lt_LT;lv_LV;mk_MK;ms_MY;
		  nb_NO;nl_BE;nl_NL;pl_PL;pt_BR;pt_PT;ro_RO;ru_RU;sk_SK;sl_SI;
		  sr_RS;sv_SE;th_TH;tr_TR;ur_PK;uk_UA;uz_UZ;vi_VN;zh_CN;zh_HK;
		  zh_TW;
          </Display>
          <Input>
                <SupportList>
				en_GB;ar;az;bg;bn;ca;cs;da;de;el;
				en_US;es;et;eu;fa;fi;fr;gl;gu;hi;
				hr;hu;hy;id;is;it;ka;kk;kn;ko;
				lt;lv;ml;ms;mr;nb;nl;pa;pl;pt;
				ro;ru;sk;sl;sr;sv;ta;te;th;tr;
				uk;ur;vi;zh_CN;
                </SupportList>
                <EnableList>
                </EnableList>
          </Input>
   </LanguageSet>
of course after extracting a lot of ROMs from specific regions, you can just add their iso code language in your cooked ROM language.xml after having the iso codes from their language.xml files
2. Now copy this modified language.xml and paste it on system\csc directory
3. Now to display language name in your device, you need to decompile ResourceManager.apk and navigate to res\values folder and open strings.xml and add new languages resources strings there in this form:
Code:
Select Code
    <string name="vo_rm_authority">com.visionobjects.resourcemanager</string>
    <string name="en_GB">English(UK)</string>
    <string name="en_US">English(US)</string>
    <string name="az">Azərbaycan</string>
    <string name="ca">Catalā</string>
    <string name="cs">Čeština</string>
    <string name="da">Dansk</string>
    <string name="de">Deutsch</string>
    <string name="et">Eesti</string>
    <string name="es">Espaņol</string>
..
..
and so on
Here the red texts are regional iso codes for the added language, and the blue texts are the displayed language name in your device (you can decompile ResourceManager.apk from different ROMs' regions in order to have the iso codes and the corresponding languages strings).
4. Now you need to add input database for different languages. After extracting different ROMs' regions, copy all the content of system\T9DB and paste it in same directory of the ROM that you will make it support different languages.
Quote:
N.B: To have all input languages activated, you need to add all values folder in the ROM keyboard app for the specific language you want to activate.
5. Now you will need to integrate languages data base; after extracting different ROMs' regions, copy all the content of system\hdic folder and paste it in same directory of the ROM that you will make it support different languages.

How to set default language in initial setup wizard:
Go to system\csc folder and open customer.xml and edit this section:
Code:
Select Code
      <Phone>
        <DefLanguage>ar_AE</DefLanguage>
        <DefLanguageNoSIM>ar_AE</DefLanguageNoSIM>
        <DateTimeFormat>
          <DateFormat>ddmmyyyy</DateFormat>
        </DateTimeFormat>
        <VisiblePassword>off</VisiblePassword>
      </Phone>
Just change the blue colored iso code and substitute it with your favorite one from language.xml display section

CSC codes:
How to set default csc code:
Go to system\csc\%yourCSCfolder%\system\csc folder and copy all its content (usually contents.db, customer.xml, others.xml, and sales_code.dat) and paste it on system\csc directory.

Alternatively, you can edit the files in system\csc folder that includes:
customer.xml
Code:
Select Code
    <SalesCode>KSA</SalesCode>
change it to your csc iso code (that is the csc folder name in system\csc folder).
language.xml:
Code:
Select Code
   <SalesCode>KSA</SalesCode>
the same as change in customer.xml
sales_code.dat
Code:
Select Code
KSA
the same as change in customer.xml

How to add extra CSC codes:
After extracting all CSC folders from different ROMs region, first copy and paste them in system\csc folder then you need to go to system directory and open SW_Configuration.xml and add all CSC folders you just paste:
Code:
Select Code
	<NbCustomer>67</NbCustomer>   <!-- Here enter how many csc code folders you have in system\csc
	<CustomerData src="/Customer/ABS/customer.xml" />   |
	<CustomerData src="/Customer/AFG/customer.xml" />   |
	<CustomerData src="/Customer/AFR/customer.xml" />   |--- Here add CSC folders
	<CustomerData src="/Customer/ALO/customer.xml" />   |
	<CustomerData src="/Customer/ARB/customer.xml" />   |

..
..
and so on


And now you are ready to create your multi-languages and multi-csc ROM,,


The Following 7 Users Say Thank You to majdinj For This Useful Post: [ Click to Expand ]
 
majdinj
Old
(Last edited by majdinj; 19th July 2013 at 02:19 AM.)
#3  
majdinj's Avatar
Recognized Contributor / Themer - OP
Thanks Meter 2922
Posts: 980
Join Date: Nov 2006
Location: AlAhsa
For developers only..!!

Here is all codes I used to build up this utility, any suggestion for improvement is welcomed.. !!
Real CMD codes language used in the utility (v1.05):
 

Code:
Select Code
@echo off
setlocal enabledelayedexpansion
COLOR 0A
title [APK LANGUAGES EXTRACTOR TOOL - majdinj - xda]
if (%1)==(0) goto logo
mode con:cols=64 lines=55
echo.
echo.
echo        **************************************************
echo        **************************************************
echo        **                                              **
echo        **           Checking java version...           **
echo        **                                              **
echo        **************************************************
echo        **************************************************
echo.
java -version
IF errorlevel 1 goto errjava
echo.
echo.
echo              Java is installed on your machine...
echo.
echo.
ECHO.
ECHO.
ECHO.
echo        **************************************************
echo        **************************************************
echo        **                                              **
echo        **       USED TOOLS, VERSIONS AND CREDITS       **
echo        **                                              **
echo        **************************************************
echo        **************************************************
ECHO.
cd "%~dp0tools"
type versions.txt
echo.
echo  WELCOME TO ANDROID APK LANGUAGES EXTRACTOR AND INTEGRATOR TOOL
ECHO                 BY: majdinj - XDA-DEVELOPERS.COM
echo.
echo.
echo.
echo.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
PAUSE

cd "%~dp0"

set capp=None
set heap=1024
set comp=9

set /A count=0
FOR %%F IN (put-apk-here/*.apk) DO (
set /A count+=1
set tmpstore=%%~nF%%~xF
)

if %count%==1 (set capp=%tmpstore%)

IF NOT EXIST "%~dp0/put-apk-here" mkdir put-apk-here
IF NOT EXIST "%~dp0/put-dependencies-here" mkdir put-dependencies-here
IF NOT EXIST "%~dp0/extracted-languages" mkdir extracted-languages
IF NOT EXIST "%~dp0/finished-apk" mkdir finished-apk
IF NOT EXIST "%~dp0/temp" mkdir temp


echo. >> log.log
echo. >> log.log
echo   ---------------------------------------------------------------------------- >> log.log
echo   ^|%date%                         --                         %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2%^| >> log.log
echo   ---------------------------------------------------------------------------- >> log.log
apk-lang-extractor.bat 0 2>> log.log


:logo
cls
COLOR 0A
echo.
echo                 .-                                   .:`
echo                 .//.                               `/+- 
echo                   -/-                             .+/.  
echo                    .//`    ```..--------..```   `:+:    
echo                     `:/--://++++++++++++++++//:.--.     
echo                   `-://++++++++++++++++++++/:-`         
echo                `-://///++++++++++++++++++:.`            
echo              `:///////:://+++++++++++++:`     `..``     
echo            `:///////.    ./++++++++++:`      -/+++/.    
echo           -/////////      /++++++++/.        :/++++-    
echo          -//////////:.``.:++++++++/`         `-:/:-     
echo         -///////////////+++++++++/`                     
echo        .///////////////+++++++++/                      
echo        ////////////////++++++++.
echo        ////////////////+++++++:                       
echo        ////////////////++++++:
echo       `::::::::::::::::::::::.                    
echo.
echo    **********************************************************
echo    **********************************************************
echo      *                                                    *
echo      *   ANDROID APK LANGUAGES EXTRACTOR AND INTEGRATOR   *
echo      *                                                    *
echo      *                                                    *
echo      *                  BY majdinj - xda                  *
echo      *                                                    *
echo    **********************************************************
echo    **********************************************************
echo.
echo.
echo How to use:
echo -----------
echo   1- Install your ROM dependencies (Only once).
echo   2- Put all same apks from different region ROM's releases in
echo      "put-apk-here" folder; you can give them numbers in order
echo      to not get confused; ensure no space in apk name. 
echo   3- Set Current-apk for one of them, and start extracting job
echo      and do the same for the rest of apk files.
echo   4- Let the apk file that you will integrate all languages in
echo      to be the last apk to extract the languages from; this is
echo      important to ensure the least error during compiling.
echo   5- After you extracted all languages from all apk files, and
echo      being the last extracted apk is set as Current-apk, start
echo      languages integrating process that will result in one apk
echo      file that contains all extracted languages.
echo.
echo Note:
echo -----
echo    There is an option to sign your finished apk file, this is
echo    an extra step for non system apk ONLY, so you will be able
echo    to install the apk on your device.
echo.
PAUSE



:restart
COLOR 0E
cls
cd "%~dp0"
echo Date: %date%
echo Time: %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2%
echo.
echo Java Heap Memory Size: %heap% MB
echo 7za Compression Level: %comp%
echo.
echo Current-apk: %capp%
echo.
echo  --------------------------------------------------------------
echo.
echo       ANDROID APK LANGUAGES EXTRACTOR AND INTEGRATOR v1.05
echo.
echo  --------------------------------------------------------------
echo.
echo     0 - Install Dependencies From "put-dependencies-here"
echo     1 - Set Current-apk From "put-apk-here"
echo.
echo     2 - Extract Language Folders From Current-apk File
echo     3 - Integrate Extracted Languages With Current-apk File
echo     4 - Sign Finished apk (Don't do this if it's a system apk)
echo.
echo     5 - Set Maximum Java Heap Memory Size
echo     6 - Set 7za Archiver Compression Level
echo.
echo     7 - Read Log File
echo     8 - Clean Folders
echo     U - Open XDA Utility Thread Page To Check For Update
echo     X - Exit
echo.
echo  --------------------------------------------------------------
echo.
SET /P menu=Please make your decision: %=%
IF %menu%==0 (goto Install)
IF %menu%==1 (goto SetCapk)

IF %menu%==2 (goto Extract)
IF %menu%==3 (goto Inegrate)
IF %menu%==4 (goto Sign)

IF %menu%==5 (goto heapsize)
IF %menu%==6 (goto compression)

IF %menu%==7 (goto log)
IF %menu%==8 (goto clean)
IF %menu%==U (goto update)
IF %menu%==u (goto update)
IF %menu%==X (goto exit)
IF %menu%==x (goto exit)
::If you got here, it wasn't valid key
echo.
echo         ************************************************
echo         *    Are you crazy.. choose something exist    *
echo         ************************************************
echo.
pause
goto restart

:Install
cls
cd "%~dp0"
echo Date: %date%
echo Time: %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2%
echo.
echo Java Heap Memory Size: %heap% MB
echo App Compression Level: %comp%
echo.
echo Current-apk: %capp%
echo.
echo  --------------------------------------------------------------
echo.
echo           WHICH FILE DEPENDENCY DO YOU WANT TO INSTALL
echo.
echo  --------------------------------------------------------------
echo.
ECHO             1 - Install framework-res.apk
ECHO             2 - Install twframework-res.apk
ECHO             3 - Install com.htc.resources.apk
ECHO             4 - Install SystemUI.apk
ECHO             5 - Install SemcGenericUxpRes.apk
ECHO             6 - Install lidroid-res.apk
ECHO.
ECHO             7 - Install Other Dependency
ECHO.
ECHO             M - Go Back to the MAIN MENU
echo.
echo  --------------------------------------------------------------
ECHO.
SET /P menud=Please make your decision: %=%
IF %menud%==1 (goto d1)
IF %menud%==2 (goto d2)
IF %menud%==3 (goto d3)
IF %menud%==4 (goto d4)
IF %menud%==5 (goto d5)
IF %menud%==6 (goto d6)
IF %menud%==7 (goto d7)
IF %menud%==M (goto restart)
IF %menud%==m (goto restart)
::If you got here, it wasn't valid key
echo.
echo         ************************************************
echo         *                                              *
echo         *    Are you crazy.. choose something exist    *
echo         *                                              *
echo         ************************************************
echo.
pause
goto Install
:d1
IF NOT EXIST "%~dp0put-dependencies-here/framework-res.apk" (goto Pd1)
IF EXIST "%~dp0put-dependencies-here/framework-res.apk" (goto Yd1)
:Pd1
ECHO.
echo framework-res.apk was not found in "put-dependencies-here"
echo folder. Do you want to pull it from your device?
set /P INPUTP1=Any key for YES or n, no for NO: %=%
IF %INPUTP1%==n (goto Install)
IF %INPUTP1%==no (goto Install)
IF %INPUTP1%==nO (goto Install)
IF %INPUTP1%==N (goto Install)
IF %INPUTP1%==No (goto Install)
IF %INPUTP1%==NO (goto Install)
echo.
cd "%~dp0tools"
ECHO Waiting for device USB connection...
adb kill-server
adb wait-for-device
ECHO.
ECHO Pulling framework-res.apk from device,,
adb pull system/framework/framework-res.apk "../put-dependencies-here/framework-res.apk"
if errorlevel 1 (goto err_adb)
ECHO.
echo System pull complete.. Killing ADB..
adb kill-server
ECHO.
echo ADB killed.. Retrying framework-res.apk installation
goto d1
:Yd1
echo.
cd "%~dp0tools"
echo Installing dependencies,,
java -Xmx%heap%M -jar apktool.jar if %~dp0put-dependencies-here/framework-res.apk
echo.
echo framework-res.apk was installed successfully..
timeout 3 > nul
goto Install

:d2
IF NOT EXIST "%~dp0put-dependencies-here/twframework-res.apk" (goto Pd2)
IF EXIST "%~dp0put-dependencies-here/twframework-res.apk" (goto Yd2)
:Pd2
ECHO.
echo twframework-res.apk was not found in "put-dependencies-here"
echo folder. Do you want to pull it from your device?
set /P INPUTP2=Any key for YES or n, no for NO: %=%
IF %INPUTP2%==n (goto Install)
IF %INPUTP2%==no (goto Install)
IF %INPUTP2%==nO (goto Install)
IF %INPUTP2%==N (goto Install)
IF %INPUTP2%==No (goto Install)
IF %INPUTP2%==NO (goto Install)
echo.
cd "%~dp0tools"
ECHO Waiting for device USB connection...
adb kill-server
adb wait-for-device
ECHO.
ECHO Pulling twframework-res.apk from device,,
adb pull system/framework/twframework-res.apk "../put-dependencies-here/twframework-res.apk"
if errorlevel 1 (goto err_adb)
ECHO.
echo System pull complete.. Killing ADB..
adb kill-server
ECHO.
echo ADB killed.. Retrying twframework-res.apk installation
goto d2
:Yd2
echo.
cd "%~dp0tools"
echo Installing dependencies,,
java -Xmx%heap%M -jar apktool.jar if %~dp0put-dependencies-here/twframework-res.apk
echo.
echo twframework-res.apk was installed successfully..
timeout 3 > nul
goto Install

:d3
IF NOT EXIST "%~dp0put-dependencies-here/com.htc.resources.apk" (goto Pd3)
IF EXIST "%~dp0put-dependencies-here/com.htc.resources.apk" (goto Yd3)
:Pd3
ECHO.
echo com.htc.resources.apk was not found in "put-dependencies-here"
echo folder. Do you want to pull it from your device?
set /P INPUTP3=Any key for YES or n, no for NO: %=%
IF %INPUTP3%==n (goto Install)
IF %INPUTP3%==no (goto Install)
IF %INPUTP3%==nO (goto Install)
IF %INPUTP3%==N (goto Install)
IF %INPUTP3%==No (goto Install)
IF %INPUTP3%==NO (goto Install)
echo.
cd "%~dp0tools"
ECHO Waiting for device USB connection...
adb kill-server
adb wait-for-device
ECHO.
ECHO Pulling com.htc.resources.apk from device,,
adb pull system/framework/com.htc.resources.apk "../put-dependencies-here/com.htc.resources.apk"
if errorlevel 1 (goto err_adb)
ECHO.
echo System pull complete.. Killing ADB..
adb kill-server
ECHO.
echo ADB killed.. Retrying com.htc.resources.apk installation
goto d3
:Yd3
echo.
cd "%~dp0tools"
echo Installing dependencies,,
java -Xmx%heap%M -jar apktool.jar if %~dp0put-dependencies-here/com.htc.resources.apk
echo.
echo com.htc.resources.apk was installed successfully..
timeout 3 > nul
goto Install

:d4
IF NOT EXIST "%~dp0put-dependencies-here/SystemUI.apk" (goto Pd4)
IF EXIST "%~dp0put-dependencies-here/SystemUI.apk" (goto Yd4)
:Pd4
ECHO.
echo SystemUI.apk was not found in "put-dependencies-here"
echo folder. Do you want to pull it from your device?
set /P INPUTP4=Any key for YES or n, no for NO: %=%
IF %INPUTP4%==n (goto Install)
IF %INPUTP4%==no (goto Install)
IF %INPUTP4%==nO (goto Install)
IF %INPUTP4%==N (goto Install)
IF %INPUTP4%==No (goto Install)
IF %INPUTP4%==NO (goto Install)
echo.
cd "%~dp0tools"
ECHO Waiting for device USB connection...
adb kill-server
adb wait-for-device
ECHO.
ECHO Pulling SystemUI.apk from device,,
adb pull system/app/SystemUI.apk "../put-dependencies-here/SystemUI.apk"
if errorlevel 1 (goto err_adb)
ECHO.
echo System pull complete.. Killing ADB..
adb kill-server
ECHO.
echo ADB killed.. Retrying SystemUI.apk installation
goto d4
:Yd4
echo.
cd "%~dp0tools"
echo Installing dependencies,,
java -Xmx%heap%M -jar apktool.jar if %~dp0put-dependencies-here/SystemUI.apk
echo.
echo SystemUI.apk was installed successfully..
timeout 3 > nul
goto Install

:d5
IF NOT EXIST "%~dp0put-dependencies-here/SemcGenericUxpRes.apk" (goto Pd5)
IF EXIST "%~dp0put-dependencies-here/SemcGenericUxpRes.apk" (goto Yd5)
:Pd5
ECHO.
echo SemcGenericUxpRes.apk was not found in "put-dependencies-here"
echo folder. Do you want to pull it from your device?
set /P INPUTP5=Any key for YES or n, no for NO: %=%
IF %INPUTP5%==n (goto Install)
IF %INPUTP5%==no (goto Install)
IF %INPUTP5%==nO (goto Install)
IF %INPUTP5%==N (goto Install)
IF %INPUTP5%==No (goto Install)
IF %INPUTP5%==NO (goto Install)
echo.
cd "%~dp0tools"
ECHO Waiting for device USB connection...
adb kill-server
adb wait-for-device
ECHO.
ECHO Pulling SemcGenericUxpRes.apk from device,,
adb pull system/framework/SemcGenericUxpRes.apk "../put-dependencies-here/SemcGenericUxpRes.apk"
if errorlevel 1 (goto err_adb)
ECHO.
echo System pull complete.. Killing ADB..
adb kill-server
ECHO.
echo ADB killed.. Retrying SemcGenericUxpRes.apk installation
goto d5
:Yd5
echo.
cd "%~dp0tools"
echo Installing dependencies,,
java -Xmx%heap%M -jar apktool.jar if %~dp0put-dependencies-here/SemcGenericUxpRes.apk
echo.
echo SemcGenericUxpRes.apk was installed successfully..
timeout 3 > nul
goto Install

:d6
IF NOT EXIST "%~dp0put-dependencies-here/lidroid-res.apk" (goto Pd6)
IF EXIST "%~dp0put-dependencies-here/lidroid-res.apk" (goto Yd6)
:Pd6
ECHO.
echo lidroid-res.apk was not found in "put-dependencies-here"
echo folder. Do you want to pull it from your device?
set /P INPUTP6=Any key for YES or n, no for NO: %=%
IF %INPUTP6%==n (goto Install)
IF %INPUTP6%==no (goto Install)
IF %INPUTP6%==nO (goto Install)
IF %INPUTP6%==N (goto Install)
IF %INPUTP6%==No (goto Install)
IF %INPUTP6%==NO (goto Install)
echo.
cd "%~dp0tools"
ECHO Waiting for device USB connection...
adb kill-server
adb wait-for-device
ECHO.
ECHO Pulling lidroid-res.apk from device,,
adb pull system/framework/lidroid-res.apk "../put-dependencies-here/lidroid-res.apk"
if errorlevel 1 (goto err_adb)
ECHO.
echo System pull complete.. Killing ADB..
adb kill-server
ECHO.
echo ADB killed.. Retrying lidroid-res.apk installation
goto d6
:Yd6
echo.
cd "%~dp0tools"
echo Installing dependencies,,
java -Xmx%heap%M -jar apktool.jar if %~dp0put-dependencies-here/lidroid-res.apk
echo.
echo lidroid-res.apk was installed successfully..
timeout 3 > nul
goto Install

:d7
echo.
echo Type the dependency file name without apk extension.
set /P OTHER=Type Entery: %=%
IF NOT EXIST "%~dp0put-dependencies-here/%OTHER%.apk" (goto Pd7)
IF EXIST "%~dp0put-dependencies-here/%OTHER%.apk" (goto Yd7)
:Pd7
ECHO.
echo %OTHER%.apk was not found in "put-dependencies-here"
echo folder. Do you want to pull it from your device?
set /P INPUTP7=Any key for YES or n, no for NO: %=%
IF %INPUTP7%==n (goto Install)
IF %INPUTP7%==no (goto Install)
IF %INPUTP7%==nO (goto Install)
IF %INPUTP7%==N (goto Install)
IF %INPUTP7%==No (goto Install)
IF %INPUTP7%==NO (goto Install)
echo.
echo From which system folder you want to pull it from?
set /P INPUTP8=Type any key for FRAMEWORK, or type (a) for APP folder: %=%
IF %INPUTP8%==a (goto Pd7a)
IF %INPUTP8%==A (goto Pd7a)
IF %INPUTP8%==(a) (goto Pd7a)
IF %INPUTP8%==(A) (goto Pd7a)
echo.
cd "%~dp0tools"
ECHO Waiting for device USB connection...
adb kill-server
adb wait-for-device
ECHO.
ECHO Pulling %OTHER%.apk from device,,
adb pull system/framework/%OTHER%.apk "../put-dependencies-here/%OTHER%.apk"
if errorlevel 1 (goto err_adb)
ECHO.
echo System pull complete.. Killing ADB..
adb kill-server
ECHO.
echo ADB killed.. Retrying %OTHER%.apk installation
goto Yd7
:Pd7a
echo.
cd "%~dp0tools"
ECHO Waiting for device USB connection...
adb kill-server
adb wait-for-device
ECHO.
ECHO Pulling %OTHER%.apk from device,,
adb pull system/app/%OTHER%.apk "../put-dependencies-here/%OTHER%.apk"
if errorlevel 1 (goto err_adb)
ECHO.
echo System pull complete.. Killing ADB..
adb kill-server
ECHO.
echo ADB killed.. Retrying %OTHER%.apk installation
goto Yd7
:Yd7
echo.
cd "%~dp0tools"
echo Installing dependencies,,
java -Xmx%heap%M -jar apktool.jar if %~dp0put-dependencies-here/%OTHER%.apk
echo.
echo %OTHER%.apk was installed successfully..
timeout 3 > nul
goto Install


:Extract
if %capp%==None goto noproject1
::to ensure having empty temp folder
cd "%~dp0"
rmdir /S /Q temp
mkdir temp
echo.
echo         ************************************************
echo         *                                              *
echo         *        Extracting Languages Process,,        *
echo         *                                              *
echo         ************************************************
echo.
cd "%~dp0tools"
echo A. Decompiling %capp%,,
java -Xmx%heap%M -jar apktool.jar d "../put-apk-here/%capp%" "../temp/%capp%"
IF errorlevel 1 (goto error)
timeout 2 > nul
echo.
echo B. Extracting languages values from %capp%,,
::Extracting all folders that start with value name
cd "%~dp0"
FOR /d %%a in (temp\%capp%\res\value*) Do XCOPY %%a "extracted-languages\%%a" /S /Y /I /Q > nul
xcopy "%~dp0extracted-languages\temp\%capp%\res\*" "%~dp0extracted-languages\" /S /Y /I /Q > nul
rmdir /S /Q %~dp0extracted-languages\temp > nul
timeout 2 > nul
rmdir /S /Q temp
mkdir temp
echo.
goto OpenExtract

:eek:penExtract
echo.
echo Finished %capp% languages extracting...
echo All extracted values-folder from the apk file are saved in:
echo "extracted-languages" folder.
echo.
echo Do you want to open the "extracted-languages" folder?
set /P INPUT4=Any key for YES or n, no for NO: %=%
IF %INPUT4%==n (goto :restart)
IF %INPUT4%==no (goto :restart)
IF %INPUT4%==nO (goto :restart)
IF %INPUT4%==N (goto :restart)
IF %INPUT4%==No (goto :restart)
IF %INPUT4%==NO (goto :restart)
start "" "%~dp0/extracted-languages/"
goto restart



:Inegrate
if %capp%==None goto noproject1
IF EXIST "%~dp0/finished-apk/system_%capp%" (del /Q "%~dp0\finished-apk\system_%capp%")
::to ensure having empty temp folder
cd "%~dp0"
rmdir /S /Q temp
mkdir temp
echo.
echo         ************************************************
echo         *                                              *
echo         *   Integrating Languages Into apk Process,,   *
echo         *                                              *
echo         ************************************************
echo.
cd "%~dp0tools"
echo A. Decompiling %capp%,,
java -Xmx%heap%M -jar apktool.jar d "../put-apk-here/%capp%" "../temp/%capp%"
IF errorlevel 1 (goto error)
timeout 2 > nul
echo.
echo B. Integrating extracted languages into %capp%,,,
xcopy "..\extracted-languages" "..\temp\%capp%\res" /S /Y /I /Q > nul
timeout 2 > nul
echo.
echo C. Compiling the new %capp%,,
java -Xmx%heap%M -jar apktool.jar b "../temp/%capp%" "..\temp\New_%capp%"
if errorlevel 1 (goto error)
timeout 2 > nul
echo.
echo D. Copying original signature and compressing the final apk,,,
:::::Extracting signature from original apk file:::::
7za x -o"../temp/tempOr" "../put-apk-here/%capp%" META-INF -r > nul
7za x -o"../temp/tempOr" "../put-apk-here/%capp%" AndroidManifest.xml -r > nul
:::::Extracting the new apk file for original signature integration and compression:::::
:::::1.Extracting the new apk...
7za x -o"../temp/tempAPK" "../temp/New_%capp%" -r > nul
:::::2.Copying original signature from tempOr to tempAPK...
xcopy "..\temp\tempOr" "..\temp\tempAPK" /S /Y /I /Q > nul
:::::3.Compressing the whole tempAPK folder into new2 compressed apk file...
7za a -tzip "../temp/New2_%capp%" "../temp/tempAPK/*" -mx%comp% -r > nul
if errorlevel 1 (goto error)
timeout 2 > nul
echo.
ECHO E. Zipaligning the final %capp%,,
zipalign -f 4 "%~dp0temp\New2_%capp%" "%~dp0finished-apk\system_%capp%" > nul
if errorlevel 1 (goto error)
cd "%~dp0"
rmdir /S /Q temp
mkdir temp
echo.
echo DONE.. Your file is saved in "finished-apk" Folder as:
echo system_%capp%
goto OpenFinish


:eek:penFinish
echo.
echo Do you want to open the "finished-apk" folder?
set /P INPUT2=Any key for YES or n, no for NO: %=%
IF %INPUT2%==n (goto :restart)
IF %INPUT2%==no (goto :restart)
IF %INPUT2%==nO (goto :restart)
IF %INPUT2%==N (goto :restart)
IF %INPUT2%==No (goto :restart)
IF %INPUT2%==NO (goto :restart)
start "" "%~dp0/finished-apk/"
goto restart


:Sign
if %capp%==None goto noproject1
IF NOT EXIST "%~dp0/finished-apk/system_%capp%" (goto :SignError)
IF EXIST "%~dp0/finished-apk/signed_%capp%" (del /Q "%~dp0\finished-apk\signed_%capp%")
echo.
echo         ************************************************
echo         *                                              *
echo         *   Signing Finished apk With New Signature.   *
echo         *                                              *
echo         ************************************************
echo.
cd "%~dp0tools"
echo Signing system_%capp%,,
java -Xmx%heap%M -jar signapk.jar -w testkey.x509.pem testkey.pk8 "../finished-apk/system_%capp%" "../finished-apk/signed_%capp%"
if errorlevel 1 (goto error)
echo.
echo DONE.. Your file is saved in "finished-apk" Folder as:
echo signed_%capp%
goto OpenFinish


:SetCapk
cls
echo.
echo  --------------------------------------------------------------
echo           Please select a file from the list bellow to
echo          be set as Current-apk in "put-apk-here" folder
echo  --------------------------------------------------------------
echo.
set /A count=0
FOR %%F IN (put-apk-here/*.apk) DO (
set /A count+=1
set a!count!=%%F
if /I !count! LEQ 9 (echo ^- !count!  - %%F )
if /I !count! GTR 9 (echo ^- !count! - %%F )
)

echo.
echo.
echo  --------------------------------------------------------------
echo     (Any letter or other number to return back to MAIN MENU)
echo  --------------------------------------------------------------
ECHO.
set /P INPUT3=Please Enter The File Number: %=%
if /I %INPUT3% GTR !count! (goto non1)
if /I %INPUT3% LSS 1 (goto non1)
set capp=!a%INPUT3%!
set jar=0
set ext=jar
IF "!capp:%ext%=!" NEQ "%capp%" set jar=1
goto restart
:non1
set capp=None
goto restart


:clean
cls
cd "%~dp0"
echo Date: %date%
echo Time: %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2%
echo.
echo Java Heap Memory Size: %heap% MB
echo App Compression Level: %comp%
echo.
echo Current-apk: %capp%
echo.
echo  --------------------------------------------------------------
echo.
echo                          CLEANING MENU
echo.
echo  --------------------------------------------------------------
echo.
echo           1 - Clean "put-apk-here" Folder
echo           2 - Clean "put-dependencies-here" Folder
echo           3 - Clean "extracted-languages" Folder
echo           4 - Clean "finished-apk" Folder
echo           5 - Clean "temp" Folder
echo.
echo           6 - Clean All Working Folders
echo.
echo           M - Go Back To The MAIN MENU
echo.
echo.
echo  --------------------------------------------------------------
echo.
SET /P menuc=Please make your decision: %=%
IF %menuc%==1 (goto pfhf)
IF %menuc%==2 (goto fd)
IF %menuc%==3 (goto el)
IF %menuc%==4 (goto ff)
IF %menuc%==5 (goto tf)
IF %menuc%==6 (goto allf)
IF %menuc%==M (goto restart)
IF %menuc%==m (goto restart)

    @Rem If you got here, it wasn't valid key
echo.
echo         ************************************************
echo         *                                              *
echo         *    Are you crazy.. choose something exist    *
echo         *                                              *
echo         ************************************************
echo.
pause
goto clean

:pfhf
rmdir /S /Q put-apk-here
mkdir put-apk-here
echo.
echo "put-apk-here" folder is cleaned.
echo.
pause
set capp=None
goto clean
:fd
rmdir /S /Q put-dependencies-here
mkdir put-dependencies-here
echo.
echo "put-dependencies-here" folder is cleaned.
echo.
pause
goto clean
:el
rmdir /S /Q extracted-languages
mkdir extracted-languages
echo.
echo "extracted-languages" folder is cleaned.
echo.
pause
goto clean
:ff
rmdir /S /Q finished-apk
mkdir finished-apk
echo.
echo "finished-apk" folder is cleaned.
echo.
pause
goto clean
:tf
rmdir /S /Q temp
mkdir temp
echo.
echo "temp" folder is cleaned.
echo.
pause
goto clean
:allf
rmdir /S /Q put-apk-here
rmdir /S /Q put-dependencies-here
rmdir /S /Q extracted-languages
rmdir /S /Q finished-apk
rmdir /S /Q temp
mkdir put-apk-here
mkdir put-dependencies-here
mkdir extracted-languages
mkdir finished-apk
mkdir temp
echo.
echo All working folders are cleaned.
echo.
pause
set capp=None
goto clean


:heapsize
echo.
echo Enter maximum java heap size in megabytes (16-1400) 
set /P INPUTH=(default 1024): %=%
set heap=%INPUTH%
if "%INPUTH%"=="" (set heap=1024)
if /I %INPUTH% GTR 1400 (set heap=1400)
if /I %INPUTH% LSS 16 (set heap=16)
goto restart

:compression
echo.
echo Enter Compression Level For 7za Archiver (0-9)
set /P INPUTCO=(default 9): %=%
set comp=%INPUTCO%
if "%INPUTCO%"=="" (set comp=9)
if /I %INPUTCO% GTR 9 (set comp=9)
if /I %INPUTCO% LSS 0 (set comp=0)
goto restart



:noproject1
echo.
echo                          *************
echo                          *   ERROR   *
echo                          *************
echo.
echo                Please Set Current-apk. (Option 1)
echo.
echo.
PAUSE
goto restart

:SignError
echo.
echo                          *************
echo                          *   ERROR   *
echo                          *************
echo.
echo There is no system_%capp% file in "finished-apk" folder
echo.
echo.
PAUSE
goto restart


:error
echo.
echo "An Error Occured, Check The log File (option 7)"
cd "%~dp0"
rmdir /S /Q temp
mkdir temp
echo.
PAUSE
goto restart

:err_adb
echo.
adb kill-server
adb kill-server
ECHO "An Error Occured, Please Check The Log (option 7)"
echo.
cd "%~dp0"
rmdir /S /Q temp
mkdir temp
PAUSE
goto restart

:errjava
COLOR 0C
CLS
echo.
echo.
echo.
echo        **************************************************
echo        **************************************************
echo        **                                              **    
ECHO        **            Java was not found,,,,            **
echo        **    You will not be able to use this tool,    **
echo        **      until you install Java environment      **
echo        **                                              **  
echo        **************************************************
echo        **************************************************
echo.
echo.
echo.
PAUSE
goto logo


:log
cd "%~dp0/tools"
Start "[APK LANGUAGES EXTRACTOR TOOL - majdinj - xda] READING LOG FILE FROM" logscript 1
goto restart


:update
echo.
echo Opening XDA Utility Thread Page,,, Please Wait,,,
timeout 2 > nul
start http://forum.xda-developers.com/showthread.php?p=43669667#post43669667
goto restart


:exit
echo.
echo.
echo.
echo.
echo                   Bye Bye, see ya later :)
echo.
echo.
echo.
timeout 3
EXIT
The Following User Says Thank You to majdinj For This Useful Post: [ Click to Expand ]
 
ezaechiel
Old
#4  
ezaechiel's Avatar
Senior Member
Thanks Meter 644
Posts: 565
Join Date: Mar 2013
Location: Issou

 
DONATE TO ME
Nice tool, I'll test it for a next release. ^_^
Samsung Galaxy Note 3 running tkari4 Multix rom:
 
majdinj
Old
#5  
majdinj's Avatar
Recognized Contributor / Themer - OP
Thanks Meter 2922
Posts: 980
Join Date: Nov 2006
Location: AlAhsa
It seems there is error code in the script that throw some error messages in the utility,,
I will look at it very soon,,
At work on the moment,,, but within hours hopefully, the fix will be online
 
majdinj
Old
#6  
majdinj's Avatar
Recognized Contributor / Themer - OP
Thanks Meter 2922
Posts: 980
Join Date: Nov 2006
Location: AlAhsa
New update added:
@ 19/July/2013 (v1.05) change-log:
- Fixed error message during language integration "The process cannot access the file because it is being used by another process".
- Fixed compression function. Now the whole final apk file is compressed by level specified, instead of signature only (my bad!!).
- Fixed open "finished-apk" folder delay after language integrating process.
- Deleting existing signed file apk of same name before signing (no more overlapping).
- New option added in the main menu to link the utility with this thread page (you can check update anytime now).
The Following User Says Thank You to majdinj For This Useful Post: [ Click to Expand ]
 
afifth
Old
#7  
afifth's Avatar
Senior Member
Thanks Meter 20
Posts: 194
Join Date: Jun 2011
Location: jepara

 
DONATE TO ME
so so so..thank you so much, i need this tool at a long time..
 
wawan999
Old
#8  
wawan999's Avatar
Member
Thanks Meter 26
Posts: 57
Join Date: Jun 2013

 
DONATE TO ME
sir, in my rom nothing language.xml file.
how to fixed that?
my device SGY Duos.
Thanks.

||~~My Work~~||

 
majdinj
Old
#9  
majdinj's Avatar
Recognized Contributor / Themer - OP
Thanks Meter 2922
Posts: 980
Join Date: Nov 2006
Location: AlAhsa
Quote:
Originally Posted by wawan999 View Post
sir, in my rom nothing language.xml file.
how to fixed that?
my device SGY Duos.
Thanks.
You need to search the corresponding xml that contains all languages in system\csc folder.. It could be named with different name..!!
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes