Problem when running XML file - Android Software Development

I am just starting with Android Development and have a few minor problems.
First of all, sometimes I don't always know what packages to import. Is there a way to import them automatically? I am coding in Ecplise.
2nd, If, because I am not attentive, I hit the "Run" button but with an XML file opened. This results in making a another xml file name <filename>.out.xml that has errors. If I delete the file I still have a red x on my project folder. And when I try to run the actual java file it sais that the project contains error. The only solution is to delete the entire project and recreate it. But this is uncovinient to always recreate the project, recopy the entire code and everything. Does anyone know how to solve this problem? Thanks
Forgot to mention, the error that appears in the "problems" tab is this: Description
Unparsed aapt error(s)! Check the console for output.
And in the console i have this:
[2010-06-30 19:36:36 - Math Test] Error in an XML file: aborting build.
[2010-06-30 19:37:12 - Math Test] res\layout\main.xml:0: ERROR Resource entry main is already defined.
[2010-06-30 19:37:12 - Math Test] res\layout\main.out.xml:0: Originally defined here.
[2010-06-30 19:37:16 - Math Test] res\layout\main.xml:0: ERROR Resource entry main is already defined.
[2010-06-30 19:37:16 - Math Test] res\layout\main.out.xml:0: Originally defined here.

to import packages ctrl+shift+o

Thanks. Also, I managed to remove the error just by deleting it from the "Problems" tab and forcing a rebuild. Thanks.

Related

SDConfigGen - a tool for automatically creating SDAutorun configurations

First off, I'd like to thank Sleuth255 for SDAutoRun, and to mousio for his AutoRun tool which provided the inspiration for this project.
SDConfigGen is a command line tool for the PC which inspects a collection of files to be installed, then produces an SDConfig.txt and other associated scripts and provisioning files to allow SDAutoRun to automatically install them.
It differs from mousio's solution in that rather than having SDAutoRun call a MortScript to do all the work, this tool creates an SDConfig.txt to do the majority, only calling scripts for specific functionality when required. Scripts (and therefore MortScript) may not even be required, if nothing being installed needs automation.
Installation
Unzipping the contents of the archive will produce this folder structure:
\
Storage Card\SDConfig\Cabs\
Files\
Scripts\
Settings\
Sys\​First things first - to use any of the script-based functionality a copy of the MortScript installation cab file must be placed within the Sys folder. Download MortScript-4.11b7.zip (or newer version) from http://www.sto-helit.de, then extract \cab\MortScript-4.11b7-PPC.cab from it.
Usage
If the name of the Storage Card will be different on your target device, then rename that folder to whatever it will be. Otherwise, just leave it as it is.
Within the sub-folders of SDConfig, add the files you want to be installed.
Cabs:
Any .cab files in this folder will be installed. If the installation of a .cab file requires user interaction (to confirm a license window, for example), then create a .mscr script file of the same name containing instructions to be executed while the cab file is being installed.
For example, if you need to install a cab file: "eWallet-PocketPC-Install.cab",
create a file called "eWallet-PocketPC-Install.mscr" too. This file contains
MortScript to be run while the cab installer is being run, for example:
Code:
windowTitle = "Software License Agreement"
WaitFor(windowTitle, 60)
SendLeftSoft(windowTitle)
Note that you don't need to worry about actually installing the cab, or waiting for installation to finish - just write the automation code itself.
The SDAutoRun UI will be hidden while an interactive cab is being installed like this, and a MortScript status window shown instead. The device will be responsive to user input, so if any non-automatable interaction is required, that can be done manually.
Files:
After the cab files have been installed, all files in this folder will be copied directly to the root folder. To copy files to sub-folders, place them in sub-folders of this folder. For example, to copy files to the Windows folder, create a Windows folder here and place the files within it.
Standard (English) folder names will automatically be replaced by variables, so files in the "Files\Program Files" folder here will be copied to %CE1% folder by SDAutoRun.
The file copy operation is actually performed by generating a CopyFiles.xml provisioning file in the Sys folder, and it is this that goes in the SDConfig.txt file. This method was chosen as it avoids the path length limit of copying directly in SDConfig.txt, and allows for the %CEn% variable subsitution scheme.
Settings:
After the files have been copied, any settings in this folder will be applied. Settings may either be .xml provisioning files (which are added directly to SDConfig.txt), or registry data in .reg, .rgu or .cereg files. Registry data files will be automatically converted to xml provisioning files within the Sys folder, which are then added to SDConfig.txt.
Scripts:
After the settings have been applied, any .mscr scripts within this folder will be executed. SDConfigGen will generate instructions in SDConfig.txt to automatically handle copying them to the \Temp folder and renaming them to replace spaces by underscores before execution if required.
Note that the device will not be interactive at this point, so don't write scripts that require user interaction.
Sys:
Apart from placing a copy of MortScript-4.11b7-PPC.cab in here, you shouldn't touch the contents of this folder; they will be automatically cleaned out and generated by the SDConfigGen tool.
Notes
I've provided RegToXml as a standalone .exe file so that registry data files can be manually converted to .xml provisioning files, if required. This is not generally necessary, though, as it will occur automatically as part of the SDConfigGen process.
Due to limitations of SDAutoRun, during installation some files need to be copied to the \Temp folder on the device before execution. A TempCleanup.xml provisioning file is generated in the Sys folder by SDConfigGen which is the last thing executed by SDConfig.txt. It should remove any temporary files that were placed in the \Temp folder, but will not remove the folder itself, or any other files within it.
SDAutoRun also requires that SDConfig.txt be ASCII, which means that if any files contain characters outside that range (such as accented characters), they can not be directly referenced. SDConfigGen will automatically detect this, and generate provisioning XML files to transparently rename the files before processing them, then back again afterwards.
The last statement in the SDConfig.txt is the RST: Reset statment, to reset the device.
The only part of the file structure that can be changed is the name of the "Storage Card" folder - the other folders cannot be renamed or moved. By default, when the SDConfigGen tool is run, it works with the first sub folder under the folder the .exe file is placed. To override this behaviour, pass the folder path to SDConfigGen.exe as a command line argument.
Cabs, settings and scripts are executed in alphabetical order, grouped by subfolder. Subfolders will be executed first, so for example the contents of Cabs\Prerequisites\ would be installed before the files directly in Cabs\ (but after files in Cabs\A\). All interactive cabs are executed first, followed by non-interactive ones.
All generated files (except SDConfig.txt) are in Unicode UTF-16 encoding.
To have SDConfigGen create a log file of the generation process, use the SDConfigGenWithLog.bat file included in the archive. It will create a results.log file containing the messages that would normally be output to the console.
This is still an early version, so there will probably be bugs with it. I've used it successfully for setting up my own device several times now, but I can't make any guarantees. Please do post any bug reports or suggestions here though!
Alex
Updates
0.6:
All output files are now in UTF-16 encoding, with the exception of SDConfig.txt, which is in ASCII.
If files referenced by SDConfig.txt have names containing non-ASCII characters, provisioning files to automatically rename them before they are accessed, and to restore them afterwards will be generated.
Subfolders are now supported in the Cabs, Settings and Scripts folders. Files within subfolders will be processed first, in alphabetical order of subfolder name.
File folder variable substition made case insensitive
Added SDConfigGenWithLog.bat file for easy logging of output to a log file
0.5.1:
Removed .svn files from the file structure (oops!)
0.5:
Made warning message on skipping registry files less confusing
RegToXml: Now supports empty values for String, MultiString and Binary values
RegToXml: Made ,ore robust to invalid data - if a value contains invalid data, only that value is skipped.
RegToXml: The line number is now reported with any error or warning message.
RegToXml: Whitespace allowed to surround the = in value lines.
0.4:
RegToXml: Fixed nesting bug with registry key deletion conversion
RegToXml: Now supports comments (lines starting with ; )
0.3:
RegToXml now assumes that registry files without Unicode BOM's are encoded in the system default ANSI codepage, rather than UTF-8 (this means that if your registry file is UTF-8, it must contain a Byte Order Mark to be read correctly)
0.2:
Files are now installed in alphabetical order by file name (within their own group). For example, first interactive cabs A-Z, then non-interactive cabs A-Z. This allows control over installing cabs that require others to be installed before or after them.
.NET Framework (required)
Lookin Mighty Fine Siuer.
Not in the Testing Time yet.
But does the scripts folder eventually combine the scripts into one?
(lazy Bum At Work, Not Able to test it)
No, the scripts in the scripts folder are not combined into a single script, they are all executed separately. Would there be some benefit to trying to combine them into a single script before execution?
AlexVallat said:
No, the scripts in the scripts folder are not combined into a single script, they are all executed separately. Would there be some benefit to trying to combine them into a single script before execution?
Click to expand...
Click to collapse
No, you are absolutely right there is now good reason for it.
It's better to have them seprated, makes finding **** Ups easier.
Don't know what i was thinking or why..
AlexVallat,
Thanks for your job, you soft is amazingly simple which is a great pro compared to SASHIMI for instance.
So yhis afternoon I started to put all my files in the appropriate folders and when I launch SDConfigGen with the folder path I don't get in the config.txt file \Storage Card\ before the files to execute but the path I gave as parameter. I think transforming the path given into \Storage Card\ could help.
One other point, as a poor French guy your RegToXml converter does not handle all the French extended character set such as é, à, ... Could you make it support this characters.
Anyway for now it is fully usable but requires SDConfig.txt file edition before launching the whole process. Tomorrow it will be hands-on time as I plan to upgrade my Polaris ROM so more news to come regarding SDCofingGen usage.
The_Steph
The_Steph said:
AlexVallat,
Thanks for your job, you soft is amazingly simple which is a great pro compared to SASHIMI for instance.
So yhis afternoon I started to put all my files in the appropriate folders and when I launch SDConfigGen with the folder path I don't get in the config.txt file \Storage Card\ before the files to execute but the path I gave as parameter. I think transforming the path given into \Storage Card\ could help.
One other point, as a poor French guy your RegToXml converter does not handle all the French extended character set such as é, à, ... Could you make it support this characters.
Anyway for now it is fully usable but requires SDConfig.txt file edition before launching the whole process. Tomorrow it will be hands-on time as I plan to upgrade my Polaris ROM so more news to come regarding SDCofingGen usage.
The_Steph
Click to expand...
Click to collapse
Hm my pall had the same thing but changing to Unicode seemed to solve his XML issue. NOt sure if this is the same but worth the try.
Great work alex!
Question:
Anyway to verify the syntax of the provisioning XML files?
Any tools out there that can create these files or verify them? I think a tool like this would be great.
NEVERMIND! I just saw your reply in the reg2xml converter thread! THANKS!
The_Steph: Thanks for your comments!
The idea with the path is that the name of the folder is used to control the name of the Storage Card on the device. So if you name your folder Storage Card, that's what goes in the SDConfig.txt. If, on your device, it has a different name (due to language changes, or whatever), then you need to rename the folder appropriately.
Thanks for the bug report about accented characters in RegToXml. I will fix that and post an updated version soon.
gtxaspec: I could verify that the files were valid XML, but the more useful check that they contain valid provisioning instructions is beyond the scope of this project. Not least because the documentation describing what are valid instructions is confusing and can be inaccurate. With anything other than the file and registry providers, it usually ends up being a case of trial and error. With the file and registry providers, using the auto-generation capabilities of SDConfigGen will avoid most surprises.
Alex
Version 0.3 released
I've just updated the first post to release version 0.3. This should address the accented characters issue raised by The_Steph, however it does mean that if your registry file is UTF-8 encoded, it must include Byte Order Marks to indicate this. Otherwise, it will be assumed to be encoded in the system default code page.
I've also added a feature that files are now installed in alphabetical order (within each group). If you need to make sure that certain cabs are installed before others, this can now be done by renaming them, usually by including a numeric prefix.
Alex
reg2xml bugs
Hi Alex,
Converting everything to xml and using standard provisioning is an interesting approach!
Only obviously reg2xml has got some problems still with .reg files containing certain characters:
I've attached you a sample file which is not converted correctly at three points, each with a different error cause.
- Comments (Lines beginning with ";") in the .reg files are sometimes (not in every case, could not see what the trigger is) leading to an aborted conversion.
- Some characters like the arrow character (ASCII 27/1BHex) are also a problem.
Maybe the attached file helps in finding the bug.
BTW: Do you also have a tool that is converting just the other way around: From XML to reg indstead of from reg to XML?
Sometimes I need to have a .reg file instead of an .XML. And importing the XML and then trying to find all registry entries to export it back to a .reg can be a very tedious thing when the imports are not all together in one registry branch.
Thanks!
Thanks for the bug report, asango. Yes, I forgot about comments, I'll fix that and release an update soon. I'm looking into what the best way to handle control characters like 0x1B is (which is 'Escape', according to the ASCII chart I'm looking at). Obviously crashing is not an acceptable behaviour, so I'll have some sort of fix for it.
I don't have a XmlToReg tool, but it sounds like a good idea - I'll probably write one over the weekend.
Alex
Great, looking forward to that, thank you!
Version 0.4 released
The first post has been updated to version 0.4. RegToXml has been updated to add support for comments in .reg files.
Unfortunately there appears to be no way to include control characters in an XML file. If the character itself, or even the character entity (like &#x1B, then the file is regarded as malformed and not accepted. I have therefore not been able to do anything to fix this (sorry asango!).
If anyone knows of a way that a provisioning file could be used to set a registry string value containing these characters, please let me know.
On a more positive note, the requested XmlToReg tool is up - I've given it its own thread here: XmlToReg.
Alex
Yes, the comments are now handled corectly, perfect!
Some other thing is still an issue:
test.reg: Converting...
test.reg: Conversion failed. (Unexpected value format: dword) Skipping.
In this case the output file is not generated at all, seems that not only the value is skipped but this causes the whole file not being written.
This leads to another suggestion: Would it be possible to indicate the line number where a problem happened?
This would make it much easier to find the problem.
And regarding the non handled escape characters:
This also leads to aborting. Would it also be possible to just skip them and issue a warning but go on with the conversion and with writing the outout file for the rest of the entries?
Now that is odd. "dword" is a perfectly valid value format, it shouldn't have produced that error. Any chance you could send me the .reg file that produced it?
Line numbers should be do-able, I'll add that to the next version.
The "skipping" message there referred to the "test.reg" at the start of the message, not to the dword value. I agree it looks misleading as it is currently worded though, I'll improve that.
About recovering from errors and skipping only invalid values rather than the whole file - this will be quite tricky. By the time I am notified of invalid characters by the XmlWriter, it has already given up in a sulk and can't be persuaded to continue writing any further. I'll need to do some sort of pre-vetting before passing data on to it. If I come up with any good ideas on how to do this, I'll include it in the next version.
Alex
asango, here's a candidate RegToXml.0.5.0 - could you check if it is still reporting the "Unexpected value format: dword" error with your file? It now reports line numbers, which might help track down the problem. It should also be able to recover from an invalid value and skip just that value, although I'm not sure how well that is working yet.
Alex
Hi Alex,
Great, the line numbers are making things much easier and this way I even found the reason for this error very easily:
Here's the point where it is failing:
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\RIL]
"NITZEnable"= dword:00000001
...with this error message:
test.reg: Converting...
[Line 194] Error: Invalid value (Unexpected value format: dword)
Skipping: HKEY_LOCAL_MACHINE\Drivers\BuiltIn\RIL\NITZEnable
Done.
As soon as I'm deleting the blank between the "=" and "dword" everything is ok.
Maybe you can allow blanks after the "=" in general?
This would solve this issue definitely
And yes, by the way the xml file is now generated despite of this error, very good!
Asango
Hmm... I'm not sure whitespace is supposed to be allowed around the = sign. It doesn't make anything ambiguous though, so there's no good reason not to relax the matching. Try this 0.5.1 which allows whitespace around the = sign, hopefully that should now parse your file correctly.
Alex
Yes, now I can see no other issues with the RegToXml tool, good work!
Also the whole cold boot import is ok with one exception:
Only the CopyFiles.xml which is generated by the SDConfigGen.exe is not copying all the files from the "Files" diectory during its execution.
Tried to import that xml manually with the xml option of Taskmgr and also got an error, but since the error is *very* uninformative and not showing the line number and my CopyFiles.xml is rather big I could not find the problem.
Could it be that the reason for the error is that if a file is already existing or read only that this will stop the rest of the import?
asango said:
Yes, now I can see no other issues with the Only the CopyFiles.xml which is generated by the SDConfigGen.exe is not copying all the files from the "Files" diectory during its execution.
Tried to import that xml manually with the xml option of Taskmgr and also got an error, but since the error is *very* uninformative and not showing the line number and my CopyFiles.xml is rather big I could not find the problem.
Click to expand...
Click to collapse
Second hands-on day with SDConfigGen and I have the same issue with v0.4. CopyFiles.xml is not executed at all. Probably a syntax error issue as stated by asango (I've done the same tests as him).
The_Steph

[Q] SAX Parsing in Android

Hi,
need a help regarding SAX Parsing in Android.
I have code in XML file Having List of attributes of innertags.
outertag->innertag--> 1st attribute
-> 2nd attribute
-> 3rdattribute
How I could store these in vector..
would anyone provide me solution How could I DISPLAY Vector in oncreate() method.
Found this SAX example: http://www.anddev.org/parsing_xml_from_the_net_-_using_the_saxparser-t353.html
Dont understand the difficulty you're having in using a Vector, its just another collection....
http://www.roseindia.net/java/beginners/vectordemo.shtml

[JAR][frameworks] A little program to automate changing all those ids

Don't you wish smalis referenced xml by their tag name instead of those hex numbers? It would be so much easier to port smalis from one framework to another.
Changing every id that is different from the original fw to the destination fw by hand is feasible, but very time consuming. Thus, I made this little java program to automate the task. It runs in the command line, and takes four arguments: the smali you want to change, the smali to be created, the original public.xml, and the target public.xml
It is meant to be used with the script that is also attached, to change all the smali files in any directory. It should work also in windows, but I don't include a .bat file since I only tested this in ubuntu.
the idea is to use it like this:
Code:
./changeAllIds.sh in/ out/ original.xml target.xml > log 2 > err.log
Known issues/bugs/TODO-list:
- The bad news is that the program will throw an exception if there is an id in the smali file that is present in the original.xml but not in the target.xml. The good news is that it will output to stderr the name of the smali file and the line that has that reference, so you can immediately know which one is and add it to the target fw.
- For some reason, the ids 'ok' and 'cancel' will make this program crash. It was for me faster to temporally remove those references in the smali file and continue (adding them back later) rather than fixing the code. You're welcome to fix it if you feel like.
Source code can be found here:
https://github.com/aleadam/xml_id_changer
Well, thank you Sine for linking me to another post in the Vibrant forum.
There is a java program made by untermensch posted 3 days ago that does the same. Except, as judging by the description and the comments, that it's well done, as opposed to the crude and amateur code I posted above
http://forum.xda-developers.com/showthread.php?t=945637

compiled jar library project

Hi all.
I need to do a close source library for my work.
I figured I could create a library project and then export all of its code into a compiled jar archive.
Then, when I need to use that library, I use the empty android library project for its resources and I import the jar file in the build path.
So far, it works when the main project that uses the library doesn't have its own resources.
But as soon as I add a resource (like icon.png) into the main project, the application fails to launch a library activity and I get this error : Unable to start activity ComponentInfo{...}: android.content.res.Resources$NotFoundException: File res/drawable/icon.png from xml type layout resource ID #0x7f020000
I really don't get it. What's the problem ?
Thank you for your help.

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

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
Android SDK Guide on Localization
http://developer.android.com/guide/topics/resources/localization.html
http://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch
http://developer.android.com/guide/topics/resources/providing-resources.html#table2
Mobile Country Codes (MMC)
http://en.wikipedia.org/wiki/List_of_mobile_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>
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.
SifJar said:
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.
Click to expand...
Click to collapse
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.
Merged with Post#1
Merged with Post#1
Useful Resources
Merged with Post#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.
Merged with Post#1
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
Also, seeing as they couldn't be sorted, it would probably be a longer process.
Merged with Post#1
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.
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.
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.
First post have been updated again to better fit the new section
Thanks to the mods for moving it!
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.
SifJar said:
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.
Click to expand...
Click to collapse
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!
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.
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...
Aternus said:
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...
Click to expand...
Click to collapse
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

Categories

Resources