domingo, 1 de dezembro de 2013

APK Translation - Android Developers


Font: XDA-Developers
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 MIUI translation project
/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

Android SDK Guide on Localization
http://developer.android.com/guide/t...alization.html
http://developer.android.com/guide/t...html#BestMatch
http://developer.android.com/guide/t...es.html#table2

Mobile Country Codes (MMC)
http://en.wikipedia.org/wiki/List_of..._country_codes

List of ISO-639-1 Codes (Country Codes)
http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

List of ISO-3166-1-alpha-2 Codes (Region Codes)
http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

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>
Font: XDA-Developers

Unknown

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.

2 comentários:

  1. A very good platform for crowd translating xml files is https://poeditor.com/. I recommend it to all android developers, it has a simple interface and lots of languages available. It also has useful translation memory and API functions.

    ResponderEliminar
  2. Casino Review - Bet007
    Here you will 카지노 find 007벳 카지노사이트 the information of Casino, a global game company, the information, software and all other important aspects of Rating: 7.4/10 · ‎Review by Bet007

    ResponderEliminar

 

Copyright @ 2014 Android Genius.

Designed by Genius-Android