Created
March 13, 2020 13:18
-
-
Save fobo66/6af39b45cf130c0dfa1f675b1c7b1db4 to your computer and use it in GitHub Desktop.
awk script to convert Android strings.xml into iOS Localizable.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN{ | |
FS = "^ *<string *| *>|<\/string> *$|^ *<!-- *| *--> *$"; | |
} | |
{ | |
if (/<string.*name\=\".*\".*>.*<\/string> *$/){ | |
match($2, /name *\= *\"[^ ]+\"/) | |
name = substr($2, RSTART + 5, RLENGTH - 5) | |
print name " \= \"" $3 "\";" | |
} | |
else if(/<!--.*-->/) | |
print "// "$2; | |
else if(/^ *$/) | |
print "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
awk -f android2iosstrings.awk strings.xml > Localizable.strings