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

Search This thread

Aternus

Senior Member
Feb 8, 2010
389
492
atern.us
Android APK Translation - CMD Line Tool

CMD Line - The Idea

Files involved: "strings.xml", "arrays.xml", "plurals.xml"

translated files:
strings.xml - http://pastebin.com/embed_iframe.php?i=5u40nHZP
arrays.xml - http://pastebin.com/embed_iframe.php?i=93v9vZUk
plurals.xml - http://pastebin.com/embed_iframe.php?i=GwBuFdmW

original files:
strings.xml - http://pastebin.com/embed_iframe.php?i=r2W4yYvh
arrays.xml - http://pastebin.com/embed_iframe.php?i=Lfff9Pur
plurals.xml - http://pastebin.com/embed_iframe.php?i=eSe8yf4S

1) Get translated files from a translator.

2) Sort & delete tags/nodes with duplicate attributes from the translated files.

3) Get original files from the ROM.

4) Sort & delete tags/nodes with duplicate attributes from the original files.

5) Merge translated files with original files

(Optional) Discard all XML tags/nodes with attributes that doesn't exist in the original XML

Suggested Tool Syntax
Code:
apktrans [OPTS] --i rom/strings.xml --t translated/strings.xml --o merged/strings.xml

OPTS:
-s - sort xml nodes
-d - delete duplicate xml nodes
-m - discard xml nodes not present in the source xml

Notes

  • The node is considered a duplicate if there is another node with the same attributes, no matter how many children it have inside of it.
  • The node with more children overwrites the node with less.

Needed Tool Features

  • sort xml tags by attribute name
  • delete duplicate xml tags by attribute name
  • preserve node properties - ability to work on any kind of tags (string & arrays - children) - see example
  • should work with UTF-8





Android APK Translation - GUI Tool

GUI - The Idea

Original idea and source code: APK Translation Wizard

For the purpose of explanation, its assumed we want to translate from English source files to Vietnamese without a region code


File Structure

Code:
/
/apks-compiled         - holds the apk files after encoding
/apks-frameworks      - holds the framework files
/apks-source            - holds the apk files for decoding/translation
/apks-translation       - holds the apk files after encoding (with the translated files)
/core                      - holds the application files (binaries, scripts, etc...)
/i18n-crowdin           - holds the translation files from the [URL="http://crowdin.net/project/miui-rom-translation"]MIUI translation project[/URL]
/i18n-other              - holds the other translation files (drawable, raw, xml, etc...)


Decode Window - APK Decoding

Selectbox: Select which APK files you want to decode - apk files should be present inside the "/apks-source" directory

Selectbox: Select which framework file to use for APK decoding - framework file should be present inside "/apks-frameworks" directory

Button: Decode APK files - using APKTool


Config Window - Tool Configuration

Button: Load original files - /res/values/strings.xml, /res/values/arrays.xml, /res/values/plurals.xml

Seletbox: Select destination locale - required - vi

Selectbox: Select destination region - optional - rVI

Button: Start Translation Process - set up /res/values-vi (and /res/values-vi-rVI if selected)


Translation - strings.xml

View: APK_NAME | ATTRIBUTE_NAME | ORIGINAL STRING | TRANSLATED STRING

APK_NAME - name of the decoded apk
ATTRIBUTE_NAME - name of the tag's attribute we are translating
ORIGINAL STRING - the original string for translation
TRANSLATED STRING - the translated string*

*as appears in the /res/values-vi/strings.xml file OR /res/values-vi-rVI/strings.xml file OR empty if none

Button: Sort all tags - sorts all tags by attribute name

Button: Delete duplicate tags - delete tags with duplicate attribute name

Button: Import an XML patch - imports an XML file and merges the tags that have the same attributes

Button: Commit Translation - writes the translated xml file - /res/values-vi(-rVI)/strings.xml

Description
  • The user will be able to edit the TRANSLATED STRING column only.
  • The use will be able to edit tags which present only inside the source xml file (the decoded file) so to avoid adding tags which doesn't exist in the application we are translating.
  • If a tag is present in the XML patch but is missing in the source file; it will be discarded.


Translation - arrays.xml

View: APK_NAME | ATTRIBUTE_NODE_NAME | ORIGINAL STRINGS LIST | TRANSLATED STRINGS LIST

APK_NAME - name of the decoded apk
ATTRIBUTE_NODE_NAME - name of the tag/node's attribute we are translating
ORIGINAL STRINGS LIST - a list of the node's children which includes the original strings for translation
TRANSLATED STRINGS LIST - a list of the node's children which includes the translated strings*

*as appears in the /res/values-vi/arrays.xml file OR /res/values-vi-rVI/arrays.xml file OR empty if none

Button: Sort all nodes - sorts all nodes by attribute name - should NOT sort the children b/c their order is important!

Button: Delete duplicate nodes - delete nodes with duplicate attribute names

Button: Import an XML patch - imports an XML file and merges the nodes that have the same attributes

Button: Commit Translation - writes the translated xml file - /res/values-vi(-rVI)/arrays.xml

Description
  • ORIGINAL STRINGS LIST & TRANSLATED STRINGS LIST column will have a list of all properties (children) which belong to a specific ATTRIBUTE_NODE_NAME.
  • The user will be able to edit the TRANSLATED STRINGS LIST column only.
  • The user will be able to edit nodes which present only inside the source xml file (the decoded file) so to avoid adding nodes which doesn't exist in the application we are translating.
  • If a node is present in the XML patch but is missing in the source file; it will be discarded.
  • If a node in the XML patch includes more children then a node in the source file; All additional children will be discarded.


Translation - plurals.xml

View: APK_NAME | PLURAL_ATTRIBUTE_NODE_NAME | ATTRIBUTE_NAME | ORIGINAL STRING | TRANSLATED STRING

APK_NAME - name of the decoded apk
PLURAL_ATTRIBUTE_NODE_NAME - name of the plural's node attribute we are translating
ATTRIBUTE_NAME - name of the plural's node tag attribute we are translating
ORIGINAL STRING - original string for translation
TRANSLATED STRING - translated string*

*as appears in the /res/values-vi/plurals.xml file OR /res/values-vi-rVI/plurals.xml file OR empty if none

Button: Sort all plural nodes - sorts all nodes by attribute name - should NOT sort the children b/c their order is important!

Button: Delete duplicate plural nodes - delete nodes with duplicate attribute names

Button: Import an XML patch - imports an XML file and merges the nodes that have the same attributes

Button: Commit Translation - writes the translated xml file - /res/values-vi(-rVI)/plurals.xml

Description
  • The user will be able to edit the TRANSLATED STRING column only.
  • The user will be able to edit nodes which present only inside the source xml file (the decoded file) so to avoid adding nodes which doesn't exist in the application we are translating.
  • If a node is present in the XML patch but is missing in the source file; it will be discarded.
  • If a node in the XML patch includes more children then a node in the source file; All additional children will be discarded.


Encode Window - APK Encoding

Selectbox: Select which APK files you want to encode - will be taken from the "/projects" directory

Selectbox: Select which framework file to use for APK encoding - framework file should be present inside "/apks-frameworks" directory

Checkbox: Replace "Resources.arsc" - after compilation, the compiled APK will be unzipped, the Resources.arsc file will be taken out and put inside the original APK*.

Button: Encode APK files - using APKTool

*this is to avoid signature issues within the APK files.





Android Localization - Useful Resources


Examples of Usage
Note: trimmed due to forum length limits, notice that the xml tags are not sorted.

translated strings.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
  <string name="common_minutes_ago">%s minutter siden</string>
  <string name="common_hours_ago">%s timer siden</string>
  <string name="common_days_ago">%s dage siden</string>
  <string name="app_name">Browser</string>
</resources>

original strings.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="common_minutes_ago">%s minutes ago</string>
    <string name="common_hours_ago">%s hours ago</string>
    <string name="common_days_ago">%s days ago</string>
    <string name="app_name">Browser</string>
    <string name="app_settings">Settings</string>
    <string name="urltitlebar_gotourl">GO</string>
    <string name="urltitlebar_hint">Search or type in a URL</string>
    <string name="search_description">Bookmarks, History, Google suggestions</string>
</resources>

final strings.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
  <string name="common_minutes_ago">%s minutter siden</string>
  <string name="common_hours_ago">%s timer siden</string>
  <string name="common_days_ago">%s dage siden</string>
  <string name="app_name">Browser</string>
  <string name="app_settings">Settings</string>
  <string name="urltitlebar_gotourl">GO</string>
  <string name="urltitlebar_hint">Search or type in a URL</string>
  <string name="search_description">Bookmarks, History, Google suggestions</string>
</resources>
 
Last edited:

SifJar

Senior Member
Jul 30, 2009
619
270
Duplicate lines are always right after each other, right? I could throw together a script to delete the second line I think. I don't have time right now, but if no one has posted anything by this afternoon, I'll give it a shot for you.
 

zach.antre

Senior Member
Mar 29, 2010
242
69
41
Athens
Duplicate lines are always right after each other, right? I could throw together a script to delete the second line I think. I don't have time right now, but if no one has posted anything by this afternoon, I'll give it a shot for you.

there is no need to create a script.
There are many text editors that can do that.

e.g. Notepad++

line 64-65

Code:
  <string name="car_mode_disable_notification_message">برای خروج از حالت خودرو انتخاب کنید.</string>
  <string name="car_mode_disable_notification_message">برای خروج از حالت خودرو انتخاب کنید</string>

in the above example there is a dot (.) more in 1st line, and for that reason a program will not recognise it as duplicate.
In notepad++ you can check for specific content, mark the duplicated and then delete the marked lines.
We need to delete a duplicate line of "<string name="car_mode_disable_notification_message">" so we make it in notepad++ to search for duplicates that have this pattern
Code:
<string name="   ">
and delete duplicate lines.

I am sure that this can be done because i have used it in the past (long ago).
I'll search some more to remember and post the way to do it.
 

SifJar

Senior Member
Jul 30, 2009
619
270
Well, I decided to go ahead and throw together this:

deldupe.exe

Basically, pass the XML to deldupe.exe (drag the XML and drop it on EXE, or run it from command line like this: "deldupe.exe example.xml"). It'll delete all the lines with the same "name" attribute. It'll leave the first one. I tested it on the example XML you posted in your first post, got this as a result:

test.xml

Seems about right I think.

Dunno if you actually need this or not anymore, but it only took a few minutes to make, so I figured I may as well.

EDIT: It's also probably easier than messing with a text editor's settings. Just drag and drop, job done.
 
Last edited:
  • Like
Reactions: Aternus

SifJar

Senior Member
Jul 30, 2009
619
270
I have to be honest, I'm not really sure what you mean. In the first file you linked, in reference to XML nodes, I can't see any duplication...

And the second part, I'm not really sure what you want. I understand you want to delete the duplicate lines from each version of each file. But I don't get the bit about merging. What is the final result you want to achieve?

I'm probably just being stupid here, but I can't really work out what it is you want the tool to do. If you could try and explain it in another way or something, I might be able to help.

EDIT: With the nodes stuff: Do you mean deleting a whole array when it is duplicated? If so, I think that could be trickier, but I could try it. I won't until I get confirmation though, don't want to waste time on something that isn't right :p

Also, seeing as they couldn't be sorted, it would probably be a longer process.
 
Last edited:

SifJar

Senior Member
Jul 30, 2009
619
270
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.
 
Last edited:

SifJar

Senior Member
Jul 30, 2009
619
270
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.
 
Last edited:
  • Like
Reactions: Aternus

Aternus

Senior Member
Feb 8, 2010
389
492
atern.us
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.
 

Attachments

  • apk-trans.zip
    418 KB · Views: 268
Last edited:

SifJar

Senior Member
Jul 30, 2009
619
270
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.
 
Last edited:
  • Like
Reactions: Aternus

Aternus

Senior Member
Feb 8, 2010
389
492
atern.us
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 :eek: How much time did it take on your machine?

Thanks!
 

SifJar

Senior Member
Jul 30, 2009
619
270
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.
 
Last edited:
  • Like
Reactions: Aternus

Aternus

Senior Member
Feb 8, 2010
389
492
atern.us
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... :D
 
Last edited:

SifJar

Senior Member
Jul 30, 2009
619
270
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... :D

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
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    Android APK Translation - CMD Line Tool

    CMD Line - The Idea

    Files involved: "strings.xml", "arrays.xml", "plurals.xml"

    translated files:
    strings.xml - http://pastebin.com/embed_iframe.php?i=5u40nHZP
    arrays.xml - http://pastebin.com/embed_iframe.php?i=93v9vZUk
    plurals.xml - http://pastebin.com/embed_iframe.php?i=GwBuFdmW

    original files:
    strings.xml - http://pastebin.com/embed_iframe.php?i=r2W4yYvh
    arrays.xml - http://pastebin.com/embed_iframe.php?i=Lfff9Pur
    plurals.xml - http://pastebin.com/embed_iframe.php?i=eSe8yf4S

    1) Get translated files from a translator.

    2) Sort & delete tags/nodes with duplicate attributes from the translated files.

    3) Get original files from the ROM.

    4) Sort & delete tags/nodes with duplicate attributes from the original files.

    5) Merge translated files with original files

    (Optional) Discard all XML tags/nodes with attributes that doesn't exist in the original XML

    Suggested Tool Syntax
    Code:
    apktrans [OPTS] --i rom/strings.xml --t translated/strings.xml --o merged/strings.xml
    
    OPTS:
    -s - sort xml nodes
    -d - delete duplicate xml nodes
    -m - discard xml nodes not present in the source xml

    Notes

    • The node is considered a duplicate if there is another node with the same attributes, no matter how many children it have inside of it.
    • The node with more children overwrites the node with less.

    Needed Tool Features

    • sort xml tags by attribute name
    • delete duplicate xml tags by attribute name
    • preserve node properties - ability to work on any kind of tags (string & arrays - children) - see example
    • should work with UTF-8





    Android APK Translation - GUI Tool

    GUI - The Idea

    Original idea and source code: APK Translation Wizard

    For the purpose of explanation, its assumed we want to translate from English source files to Vietnamese without a region code


    File Structure

    Code:
    /
    /apks-compiled         - holds the apk files after encoding
    /apks-frameworks      - holds the framework files
    /apks-source            - holds the apk files for decoding/translation
    /apks-translation       - holds the apk files after encoding (with the translated files)
    /core                      - holds the application files (binaries, scripts, etc...)
    /i18n-crowdin           - holds the translation files from the [URL="http://crowdin.net/project/miui-rom-translation"]MIUI translation project[/URL]
    /i18n-other              - holds the other translation files (drawable, raw, xml, etc...)


    Decode Window - APK Decoding

    Selectbox: Select which APK files you want to decode - apk files should be present inside the "/apks-source" directory

    Selectbox: Select which framework file to use for APK decoding - framework file should be present inside "/apks-frameworks" directory

    Button: Decode APK files - using APKTool


    Config Window - Tool Configuration

    Button: Load original files - /res/values/strings.xml, /res/values/arrays.xml, /res/values/plurals.xml

    Seletbox: Select destination locale - required - vi

    Selectbox: Select destination region - optional - rVI

    Button: Start Translation Process - set up /res/values-vi (and /res/values-vi-rVI if selected)


    Translation - strings.xml

    View: APK_NAME | ATTRIBUTE_NAME | ORIGINAL STRING | TRANSLATED STRING

    APK_NAME - name of the decoded apk
    ATTRIBUTE_NAME - name of the tag's attribute we are translating
    ORIGINAL STRING - the original string for translation
    TRANSLATED STRING - the translated string*

    *as appears in the /res/values-vi/strings.xml file OR /res/values-vi-rVI/strings.xml file OR empty if none

    Button: Sort all tags - sorts all tags by attribute name

    Button: Delete duplicate tags - delete tags with duplicate attribute name

    Button: Import an XML patch - imports an XML file and merges the tags that have the same attributes

    Button: Commit Translation - writes the translated xml file - /res/values-vi(-rVI)/strings.xml

    Description
    • The user will be able to edit the TRANSLATED STRING column only.
    • The use will be able to edit tags which present only inside the source xml file (the decoded file) so to avoid adding tags which doesn't exist in the application we are translating.
    • If a tag is present in the XML patch but is missing in the source file; it will be discarded.


    Translation - arrays.xml

    View: APK_NAME | ATTRIBUTE_NODE_NAME | ORIGINAL STRINGS LIST | TRANSLATED STRINGS LIST

    APK_NAME - name of the decoded apk
    ATTRIBUTE_NODE_NAME - name of the tag/node's attribute we are translating
    ORIGINAL STRINGS LIST - a list of the node's children which includes the original strings for translation
    TRANSLATED STRINGS LIST - a list of the node's children which includes the translated strings*

    *as appears in the /res/values-vi/arrays.xml file OR /res/values-vi-rVI/arrays.xml file OR empty if none

    Button: Sort all nodes - sorts all nodes by attribute name - should NOT sort the children b/c their order is important!

    Button: Delete duplicate nodes - delete nodes with duplicate attribute names

    Button: Import an XML patch - imports an XML file and merges the nodes that have the same attributes

    Button: Commit Translation - writes the translated xml file - /res/values-vi(-rVI)/arrays.xml

    Description
    • ORIGINAL STRINGS LIST & TRANSLATED STRINGS LIST column will have a list of all properties (children) which belong to a specific ATTRIBUTE_NODE_NAME.
    • The user will be able to edit the TRANSLATED STRINGS LIST column only.
    • The user will be able to edit nodes which present only inside the source xml file (the decoded file) so to avoid adding nodes which doesn't exist in the application we are translating.
    • If a node is present in the XML patch but is missing in the source file; it will be discarded.
    • If a node in the XML patch includes more children then a node in the source file; All additional children will be discarded.


    Translation - plurals.xml

    View: APK_NAME | PLURAL_ATTRIBUTE_NODE_NAME | ATTRIBUTE_NAME | ORIGINAL STRING | TRANSLATED STRING

    APK_NAME - name of the decoded apk
    PLURAL_ATTRIBUTE_NODE_NAME - name of the plural's node attribute we are translating
    ATTRIBUTE_NAME - name of the plural's node tag attribute we are translating
    ORIGINAL STRING - original string for translation
    TRANSLATED STRING - translated string*

    *as appears in the /res/values-vi/plurals.xml file OR /res/values-vi-rVI/plurals.xml file OR empty if none

    Button: Sort all plural nodes - sorts all nodes by attribute name - should NOT sort the children b/c their order is important!

    Button: Delete duplicate plural nodes - delete nodes with duplicate attribute names

    Button: Import an XML patch - imports an XML file and merges the nodes that have the same attributes

    Button: Commit Translation - writes the translated xml file - /res/values-vi(-rVI)/plurals.xml

    Description
    • The user will be able to edit the TRANSLATED STRING column only.
    • The user will be able to edit nodes which present only inside the source xml file (the decoded file) so to avoid adding nodes which doesn't exist in the application we are translating.
    • If a node is present in the XML patch but is missing in the source file; it will be discarded.
    • If a node in the XML patch includes more children then a node in the source file; All additional children will be discarded.


    Encode Window - APK Encoding

    Selectbox: Select which APK files you want to encode - will be taken from the "/projects" directory

    Selectbox: Select which framework file to use for APK encoding - framework file should be present inside "/apks-frameworks" directory

    Checkbox: Replace "Resources.arsc" - after compilation, the compiled APK will be unzipped, the Resources.arsc file will be taken out and put inside the original APK*.

    Button: Encode APK files - using APKTool

    *this is to avoid signature issues within the APK files.





    Android Localization - Useful Resources


    Examples of Usage
    Note: trimmed due to forum length limits, notice that the xml tags are not sorted.

    translated strings.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
      <string name="common_minutes_ago">%s minutter siden</string>
      <string name="common_hours_ago">%s timer siden</string>
      <string name="common_days_ago">%s dage siden</string>
      <string name="app_name">Browser</string>
    </resources>

    original strings.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
        <string name="common_minutes_ago">%s minutes ago</string>
        <string name="common_hours_ago">%s hours ago</string>
        <string name="common_days_ago">%s days ago</string>
        <string name="app_name">Browser</string>
        <string name="app_settings">Settings</string>
        <string name="urltitlebar_gotourl">GO</string>
        <string name="urltitlebar_hint">Search or type in a URL</string>
        <string name="search_description">Bookmarks, History, Google suggestions</string>
    </resources>

    final strings.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
      <string name="common_minutes_ago">%s minutter siden</string>
      <string name="common_hours_ago">%s timer siden</string>
      <string name="common_days_ago">%s dage siden</string>
      <string name="app_name">Browser</string>
      <string name="app_settings">Settings</string>
      <string name="urltitlebar_gotourl">GO</string>
      <string name="urltitlebar_hint">Search or type in a URL</string>
      <string name="search_description">Bookmarks, History, Google suggestions</string>
    </resources>
    1
    Well, I decided to go ahead and throw together this:

    deldupe.exe

    Basically, pass the XML to deldupe.exe (drag the XML and drop it on EXE, or run it from command line like this: "deldupe.exe example.xml"). It'll delete all the lines with the same "name" attribute. It'll leave the first one. I tested it on the example XML you posted in your first post, got this as a result:

    test.xml

    Seems about right I think.

    Dunno if you actually need this or not anymore, but it only took a few minutes to make, so I figured I may as well.

    EDIT: It's also probably easier than messing with a text editor's settings. Just drag and drop, job done.
    1
    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.
    1
    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.
    1
    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.