I want to scan my Android project for all hardcoded Strings so I can localize the project, putting the Strings in strings.xml. I see an option in Eclipse to 'Externalize Strings...' but it isn't specific to Android.
I know you can refactor individual strings but I'd like to refactor all the Strings at once. I've got a ton of files, and I'm trying to avoid going through each one manually.
I would just open up a terminal window(putty if you are on windows) at the root directory of your project. You can then run something like the following:
grep -r --include=*.java '="[^"\r\n]*"' ./* --to look for something like this String test="text";, a string with =""
or
grep -r --include=*.java '"[^"\r\n]*"' ./* -- to look for any string, anything enclosed in ""
Of course the next part is to actually substitute the Strings into the Strings.xml, that could be scripted out as well, but may take more tinkering.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With