FORUMS
Remove All Ads from XDA
H10 Turbo

[DEV][TOOL][PROJECT] Android APK Translation [CMD + GUI]

389 posts
Thanks Meter: 492
 
By Aternus, Senior Member on 22nd May 2012, 03:41 AM
Post Reply Email Thread
22nd May 2012, 05:29 PM |#11  
SifJar's Avatar
Senior Member
Thanks Meter: 267
 
More
Ah I think I got you now. This seems a LOT more complicated than what the app I posted already does. I might be able to do this, but I most likely won't I'm afraid. I will see what I can do though.

I have some ideas of stuff that might work. I'll start working on a few of them now.

EDIT: I have modified my previous script to now delete elements with duplicate "name" attributes, regardless of position in file. i.e. if an element with attribute is found a second time, it will be ignored. The next step is to modify the app to do this for two files, and then attempt to make it merge the results. I will look into nodes following that. I have made more progress than I had expected to be able to, I am now more hopeful about the chances of being successful.
 
 
22nd May 2012, 07:22 PM |#12  
SifJar's Avatar
Senior Member
Thanks Meter: 267
 
More
OK, here is a new, updated EXE. This one takes two inputs, an original XML and a translated XML. It deletes duplicates from both (from anywhere, don't have to be line after each other), then merges all translated strings into the original XML, and saves it. You need to run it from the command line, something like this:

Code:
apk-trans.exe trans.xml orig.xml dest.xml
Gives this output with the two shortened XML fragments you posted: dest.xml (even with me manually duplicating some lines, in random places)

Here's the EXE: apk-trans.exe

I'll work on removing duplicate nodes next, then make it a little more user friendly (e.g. usage instructions built it, some sort of sign it is doing something, maybe an optional GUI [it would appear if app was run with no parameters, so command line usage would still work]).

I reckon removing duplicate nodes could be the hardest part. I may now stop working on this for today and resume tomorrow.

EDIT: At this point, this should work for files like strings.xml. plurals.xml and arrays.xml will both not work. Not actually sure how it would handle files like that. The duplicate deletion stuff shouldn't change them at all. Not sure what the merging will do. Probably also nothing. I'll test now though. EDIT: I tested, spits out the original (untranslated) XML, almost unchanged (spacing at start of line is slightly different, but that shouldn't matter at all)

EDIT: Updated the EXE, noticed it output XMLs with the wrong encoding, fixed that.

EDIT: Saw updated first post - this EXE does pretty much what the command line tool described at the start describes, for strings.xml. It doesn't sort, but it automatically deletes duplicates and those not not present in the original XML.
The Following User Says Thank You to SifJar For This Useful Post: [ View ] Gift SifJar Ad-Free
22nd May 2012, 08:13 PM |#13  
Aternus's Avatar
OP Senior Member
Thanks Meter: 492
 
Donate to Me
More
Exclamation
I've updated the first post with the most recent info and examples so that newcomers can easily get all the info they need.

Hopefully we can turn this into a serious project, next thing I'm going to create a couple of GUI images to better portray how and what the application should do.

@SifJar

Thanks a lot for your help so far my dear friend. I'm hopeful that we can achieve all the required features and make Android translation process an easier experience No doubt that it will catch a lot of attention as soon as its done!

EDIT:
I've tried the tool with the following files and I think I found a bug, the tool hangs...

Please see attached file.
Attached Files
File Type: zip apk-trans.zip - [Click for QR Code] (418.0 KB, 206 views)
23rd May 2012, 10:15 AM |#14  
Aternus's Avatar
OP Senior Member
Thanks Meter: 492
 
Donate to Me
More
First post have been updated again to better fit the new section

Thanks to the mods for moving it!
23rd May 2012, 04:11 PM |#15  
SifJar's Avatar
Senior Member
Thanks Meter: 267
 
More
Huh. Dunno why it doesn't work with those files. I will look into it more a bit later on.

EDIT: It does work. It just takes a while and there is no visible sign the program is running. That is one of the things I mentioned above as needing to work on. I was focusing more on the functionality for the time being.
The Following User Says Thank You to SifJar For This Useful Post: [ View ] Gift SifJar Ad-Free
23rd May 2012, 04:30 PM |#16  
Aternus's Avatar
OP Senior Member
Thanks Meter: 492
 
Donate to Me
More
Quote:
Originally Posted by SifJar

Huh. Dunno why it doesn't work with those files. I will look into it more a bit later on.

EDIT: It does work. It just takes a while and there is no visible sign the program is running. That is one of the things I mentioned above as needing to work on. I was focusing more on the functionality for the time being.

Hmm weird, I'm on a Quad-Core Q6600 and I let it run for 10min but it didn't finish yet How much time did it take on your machine?

Thanks!
23rd May 2012, 04:44 PM |#17  
SifJar's Avatar
Senior Member
Thanks Meter: 267
 
More
I didn't time it, but it took a while. I added some command line output to reassure that it is doing something, here's an updated binary:

{see below}

Usage is as before, only now you must add |more to the end of the command, or you won't get any command line output. (Limitation of the scripting language I use seemingly).

EDIT: Seems to take less than 10 mins on my computer, which is lower spec than yours. I'll add a GUI with a progress bar now to show proper progress.

EDIT: OK, here's a new .exe (again). This time, if you add a fourth parameter (can be anything, but I use "gui"), a progress bar will be shown, to show how the tool is progressing. Seems to work nicely for me. Usage is something like this:

Code:
apk-trans.exe t_strings.xml s_strings.xml dest.xml gui |more
The |more gives command line output, the "gui" parameter gives progress bar. You can have both. |more is not necessary if you just want the progress bar (has info on what is currently being done under progress bar on window, same info as is output to cmd line).

Here's the EXE: http://d.pr/f/VmwC

Obviously I will improve the GUI in future, this is just a quick thing thrown together in a few minutes.
The Following User Says Thank You to SifJar For This Useful Post: [ View ] Gift SifJar Ad-Free
23rd May 2012, 07:08 PM |#18  
Aternus's Avatar
OP Senior Member
Thanks Meter: 492
 
Donate to Me
More
Thumbs up
Can you please make it so it will generate a proper exit code (0) and get rid of the pop-up if not in GUI mode?

Since it will be used mainly in bash a graphical GUI will be rarely used...

Btw, which language are you using?

EDIT:
Perhaps you could create a GIT for it on Github or similar so others can share their input...
23rd May 2012, 07:40 PM |#19  
SifJar's Avatar
Senior Member
Thanks Meter: 267
 
More
Quote:
Originally Posted by Aternus

Can you please make it so it will generate a proper exit code (0) and get rid of the pop-up if not in GUI mode?

Since it will be used mainly in bash a graphical GUI will be rarely used...

Btw, which language are you using?

EDIT:
Perhaps you could create a GIT for it on Github or similar so others can share their input...

There should be no pop up if not in GUI mode. And no, I can't change the way it exits, sorry.

I am using AutoHotKey (AHK). Maybe I'll stick up the source somewhere. Give me a minute.

https://github.com/SifJar/apk-trans
Post Reply Subscribe to Thread

Tags
android, apk, translate, xml

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes