Need help with simple string - Android Software Development

Hi @all,
is it possible to use a string from android/frameworks/base/core/res/res/values in systemui app ?
How do i import the Resources?
a import call to
Code:
import android.core.R;
doesnt work
many thanks for help

In XML files it's usually referenced as "@android/string/whatever"

Well, first I suggest you to use an xml file called strings.xml in the folder ...\MyApp\res\values
Your strings.xml should contain the strings you need, in this format:
<string name="app_name">MyApp</string>
Then, you could refer to the string "app_name" from the main app class or from the xml layout.
From the xml layout, I suppose you have a textView or a Button or whatever. In the declaration you should use:
android:text="@string/app_name"
In the main app class (or other class) you should refer to your layout oblect (a button or whatever) and then access to the string value:
myButton.setText(mContext.getResources().getText(R.string.app_name));
I hope it helps

Related

HOWTO: programmaticaly create a shortcut to a file/folder

hi,
I need to create a shortcut to a file or folder using eVC++ 4.0, anybody knows how to do this??
Thaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaanx alot
Mohammad
It's very easy:
Just create a file (with lnk extension)
and write to it:
10#"my_app.exe" -launch
this is what it means:
10 - length of the string after #. This value doesn't have to be accurate because it is usually ignored.
"my_app.exe" - path and name of the target of the shortcut.
-launch - command line parameters (if you have any)
You can also add: ?incon.exe,0 to take an icon from another exe / dll
Thaaaaaaaaaaaaaaank you very very much,
but I need a small thing, could you please provide me with a complex example so I can understand all features supported for shortcuts.
Thank you again,
Mohammad
Mo.
A number of us have posted about the structure of the .lnk file.
Search against my username for the word completeness.
V
now, I searched and got how the thing works, but I have a problem with coding this stuff:
When I attemp to write to shortcut file like this:
strData.Format(_T("%d#\"%s\""),strFilename.GetLength(), element.strPathname);
ShortcutFile.Write(strData,strData.GetLength()*2);
The file is not written correctly, what I get is the data I wrote in the file with a square charecter after each letter like this:
#□4□0□"□\□S□t□o□r□a□g□e□ □C□a□r□d□\□M□y□P□r□o□g□r□a□m□.□E□x□e□"□
so how can I solve this? and does it relate to unicode?
That's because you are trying to write it in UNICODE. This adds zero to every byte.
You must use fopen, fprintf, fclose functions or just create an array of char and use FileWrite to create an ASCII text file.
Thanks levenum,
but isn't windows ce file system unicode based? if so, how can I use ASCII format to write unicode filenames?
Thanks alot
Mohammad
#include <Oleauto.h>
......
char convertUshortToChar(unsigned short in)
{
char con='\0';
VarI1FromUI2(in,&con);
return con;
}
and add Oleaut32.lib to the list of object/library moduals in you project settings.
just call that for each unicode character that you want to be ascii and write the result to file.
Two things:
a) The file system may be UNICODE, but shortcuts are ASCII text. Also ASCII functions like fopen are supported.
b) There is a much easier way to convert UNICODE to ASCII:
mbstowcs(unicodeStrBuffer, asciiStrBuffer);
OK, I did it, but I think that there is a problem with Windows mobile, and it is a big problem.
Till now, I beleive that you cannot create a shortcut to a unicode-named file, I failed to do that, File explorer was not successful, Resco Explorer was not better.
Worse, they do not tell you that you cant create the shortcut, they create the shortcut for you and when you try to open it they conclude that the path was not found!!.
Very bad huh?
Mohammad
I thought that all file names are in unicode?? Use my shortcut creator in GSMbeam file open dialog to try and make a shortcut to a file named like you said. If that shortcut dose not work send me the file in question and I will try and see whats going on.
Ok, I downloaded your program and tried to create a shortcut for an arabic-named file, simply it did not work.
I know its not a bug in ur program, its a bug in Windows Mobile, it is mainly a bug in the design itself, how does Micro$oft design windows mobile to be unicode based while non-ascii characters are not supported in the shell links, its really a shame.
You can be sure that this will happen with asian characters along with Farsi, Hebrew, Arabic and all non-ascii characters.
Programmatically, what happens is as follows:
1. A program converts a filename from unicode to ASCII to save it in the .lnk file.
2. If the file name contains non-ASCII characters, those will be converted to NULL character.
3. When the shell tries to resolve the link target it does not recognise the filename because some characters are NULL.
Thats what I found out!!
Take this file name for example (Arabic): 2مرحبا.mp3
Try to solve the issue, and please inform us whatever happens with you..
Best Regards,
Mohammad
So the problem is how to get the shell to read unicode in lnk files. I re-wrote a lnk file in unicode to see if it would work but it would not. There are a lot of non english ppc users, surely this problem has come up before?
As an experiment I also made shortcut to a folder using utf-8, I think that contains arabic characters and also the ascii characters. After removing some garbage that my editor put at the front of the lnk file worked fine. Try making a shortcut in notepad and saving it as a utf-8 file then rename it on your device but make sure there is no extra characters.
أنا قادر على أكل الزجاج و هذا لا يؤلمني. -- I think those characters are arabic and they are copied of a utf-8 table site so if the shell can read a utf-8 lnk that contains english letters then maybe it can do the arabic too.
Actually, non English UNICODE characters are translated in to extended ASCII codes (128 - 255). When the system needs to translate these codes back to UNICODE it relies on code page definitions in the wince.nls file.
If your locale is properly set to Arabic and you have a valid nls installed (ether you have Arabic ROM or some sort of Arabic language support installed) you should be able to reference Arabic file names using ASCII links.
So, can I depend on string conversion functions we discussed before in this topic to convert characters according to my code page?
I have an arabic ROM installed on my Wizard, it is the i-mate rom on O2 device, so the arabizer doesnt work well, may be because the serial number of the O2 device.
Anyway, I should invistigate this issue on my friend's JamIn device, and we should come up with a workaround for this wiered problem.
Regards all,
Mohammad
OK,
I have tried creating a shortcut on my friend's arabic-enabled JamIn device, the shortcut refers to arabic-named file and it worked good.
levenum, you are right, it depends on the code page on each device, so your device will not be able to create a shortcut to an arabic named file.
Mohammad

HELP Translating Apps Tutorial

I've seen that many apps comes with AppName.0409.mui installed in the same folder of the app, usually \Windows.
For who don't have an english OS, usually miss app dialog box string.
I've seen that if u want to have back dialog box string u have to make a copy of AppName.0409.mui and reneme it into AppName.xxxx.mui where xxxx is your contry code (for me, italian, 0410).
But how to have dialog box string in native language?
I've tried with a recent app extracted from touch dual (Action Screen) which have a mui file with only one string. I've used Resource Hack, changed the string, compiled and saved. But... nothing.
In second instance i've changed not only the string but also the language code, compiled, saved and...
So can someone who is skilled make a tutorial for changing app strings?
Sorry for my bad english and thanks in advance for reply.
P.S.: i've read this http://forum.xda-developers.com/showthread.php?t=311078 and also this http://forum.xda-developers.com/showthread.php?t=307968 but talking about rom, not apps...
I do it like this:
1. Copy the program's executable file to pc.
2. Open the exe with Resource Tuner. I delete all other folders exept Menu, Dialog and String(in these are all the strings for translation) and save the file.
3. Then I open it with resource hacker and push action -> save all recources
4. I open the generated rc file with notepad and replace all the:
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US(or maybe this is another language)
lines to:
LANGUAGE LANG_GREEK, 0x1 (this is for greek language)
and save the file.
5. After that I open the rc file again, but now with resource builder and I push tools -> Create resource-only dll and I save the file as name_of_file.exe.0408.mui(for greek).
6. Finally I open this file with resource hacker and I translate it
I used to do it in this way cause I have all these three progrs(resource hacker, resource tuner and resource builder)
Maybe there are other progs or ways but this works fine for me until now. If someone knows easier and faster methods I also want to know.
First, thanks for reply.
I was trying to make an easier thing... but maybe i can try this way for my scope.
I've installed HTC Action Screen, you can found it at: http://forum.xda-developers.com/showthread.php?t=336587
It's a cool launcher, nothing more. After installation i can find in \Windows folder two files:
HTCActionScreen.exe
HTCActionScreen.exe.0409.mui
Well in the mui there's only one string that is the top of the launcher screen, that i don't see. I've renamed 0409 into 0410 and now i see the string, the original one in english (some like that "Dial phone number or select a task below:").
I'd like to change in italian, so, i've used resource hacker ONLY for translate the string (as in your 6.) but... i don't see anything once again!!!
Any suggestion?
Have i to start from exe as in your reply?
Thanks again.
This is happens because you cannot change the LANGUAGE line with resource hacker. For this I save the resources in a rc file and adit it with notepad. I had similar problems with some muis that cannot translated before use the method that I described above. You only need resource builder to recompile the rc file to mui again. I don't now in what must change the Language line for Italian, but I think you can find out if you open an italian mui file.
So, i describe my step:
1) open HTCActionScreen.exe.0409.mui with Resource Hacker and and push action -> save all recources
2) open the .rc just created with notepad and changed LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US into LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
3) open this .rc with resource builder and push tools -> Create resource-only dll and I save the file as HTCActionScreen.exe.0410.mui
4) open this file with resource hacker and translate it
it doesn't work
Where's my fault?
Maybe have i to sign the file?

Mortscript XML Parser

New Version, v2.3
# v2.3 Minor tweak to allow passing a filename instead of
# naruzo 20080117 an XML string
# Added option to disable string shrinking (shrinkString)
# Added a filter option. filterType can be "include" or "exclude"
#
Click to expand...
Click to collapse
I bundled RSSWeather.mscr (an example script that accesses Yahoo! weather feeds), the readme and the parser into one archive. The only file necessary to use the parser itself is parseXML.mscr.
There is also a new example included in the archive, topStories.mscr, which is a tool to access the Yahoo! top stories news feed (http://rss.news.yahoo.com/rss/topstories) and utilizes the new filterTags functionality to improve performance. The script reads each news item, pulls down the image file from Yahoo!'s site and stores several pieces of information in the registry for use in other scripts/rlToday/etc.
==================================================
Hello there!
I wrote an XML parser for Mortscript. From the synopsis:
parseXML.mscr is an XML parser written in Mortscript.
Writing a custom parser for every application tends to waste a lot of effort and time. Although a custom script for 1 particular application may be faster, parseXML.mscr simply offers a way to parse any XML into an easily accessible data structure with minimum coding/Mortscript experience.
The initial use case was to parse a Yahoo! weather RSS feed for use in my rlToday home screen (RSSWeather.mscr) An example script for parsing the Yahoo! Top Stories feed also exists (topStories.mscr)
parseXML is not staggeringly fast, but several options exist that can improve performance. I have not run it against any particularly hairy XML, but in theory it should be able to handle any well-formed XML.
Click to expand...
Click to collapse
### Output:
The following XML:
<rss version="2.0" >
<channel>
<title>ChannelTitle</title>
<item>
<title>ItemTitle</title>
<description lang="en" country="US">This is the description</description>
</item>
</channel>
</rss><!-- Published by blah 2007 -->
Parses to this data structure:
struct["rss"]["version"] = 2.0
struct["rss"]["channel"]["title"] = ChannelTitle
struct["rss"]["channel"]["item"]["title"] = ItemTitle
struct["rss"]["channel"]["item"]["description"]["lang"] = en
struct["rss"]["channel"]["item"]["description"]["country"] = US
struct["rss"]["channel"]["item"]["description"]["value"] = This is the description
struct["comment"] = Published by blah 2007
Click to expand...
Click to collapse
Enjoy!
thanks
NOw i go tmore idea on how to do other stuff.
v3patel said:
NOw i go tmore idea on how to do other stuff.
Click to expand...
Click to collapse
I hope so!
The parser uses Mortscript 'references' to build the data structure, which are a new (and very handy) feature as of version 4.1, if I remember correctly.
@naruzopsycho:
I'm trying to understand your xml parser and what the output would be. Is the output data written to registry, or to a specific file? Please forgive me my very limited knowledge about mortscript that I'm unable to understand your file completely.
The real use I have for this is to understand the weather cache file for pointUI, which is written in xml format (please refer to the attachment), to read the temperature and weather code and insert those to registry to update the S2U2 user weather as suggested in this thread:
http://forum.xda-developers.com/showthread.php?t=390841
I have posted the same question in the above thread and I think you may have a better idea of how to read the xml file.
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

[Q] Android Studio - Extract String Resource - Replace all occurrences?

In Eclipse, when creating a new String resource, there was an option to replace all occurrences of the hardcoded string (throughout the project) with references to the new String resource. Is this option available in Android Studio?

Resources