How to generate Localizable.strings file from strings.xml in Android -
i want strings in strings.xml converted ios localizable.strings format
format:
"string"="string" i have used few online tools in web converts xml localible.strings, format have seen :
"key"="value" but need in format:
"value"="value" example:
if strings.xml file,
<resources> <string name="addtocart">please add cart</string> </resources> the localizable.strings format should in :
"please add cart"="please add cart" (i need this) and not
"addtocart"="please add cart" (format resulted conversion tools in web) is there plugin or built in functionality in eclipse. new android , localization process.
can 1 me out in achieving please...
thanks in advance.
a pretty simple awk bash script can job.
awk ' begin{ fs = "^ *<string *| *>|<\/string> *$|^ *<!-- *| *--> *$"; } { if (/<string.*name\=\".*\".*>.*<\/string> *$/){ print "\""$3 "\" \= \"" $3 "\";" } else if(/<!--.*-->/) print "// "$2; else if(/^ *$/) print "" }' save above android2ios.sh. script read standard input stream.
for example android strings content <string name="addtocart">please add cart</string> copied clipboard, , you're using os x operating system.
pbpaste | sh android2ios.sh this print
"please add cart" = "please add cart"; you can redirect , pipe thing in own way. script converting.
comments <!--comment--> , multiline content handled script.
btw, "addtocart"="please add cart" way better, because "value" = "value" may result in duplicated keys.
Comments
Post a Comment