Skip to content

Instantly share code, notes, and snippets.

@fobo66
Created March 13, 2020 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fobo66/6af39b45cf130c0dfa1f675b1c7b1db4 to your computer and use it in GitHub Desktop.
Save fobo66/6af39b45cf130c0dfa1f675b1c7b1db4 to your computer and use it in GitHub Desktop.
awk script to convert Android strings.xml into iOS Localizable.strings
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 ""
}
@fobo66
Copy link
Author

fobo66 commented Mar 13, 2020

Usage:

awk -f android2iosstrings.awk strings.xml > Localizable.strings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment