Android: is there an easy way to find all the Strings in my project?

前端 未结 6 1899
既然无缘
既然无缘 2021-02-19 15:49

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 String

6条回答
  •  执笔经年
    2021-02-19 16:26

    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.

提交回复
热议问题