A few flavors of this question have been asked before, but I don't understand how the answers to them are satisfactory for large projects.
My goal here is to find any hardcoded strings in my application that need to be localized, so I do the following:
- Select the directory I want to run the hardcoded strings check from in the project hierarchy
- Navigate to Analyze-->Run inspection by name...
- Select "Hard coded strings"
- With the "Directory" radio button selected, click OK to run the check
At this point, I get about 3500 hits, 2500 of which are logging statements. I run a sed command to remove all logging from my project and repeat the steps above. This leaves 1000 hits. Of those about 700 hundred are strings literals assigned to constants, so I do the following:
- Navigate to Android Studio-->Preferences
- Navigate to Inspections-->Internationalization issues-->Hard coded strings
- In the box to the right, I check "Ignore literals assigned to constants"
I rerun the check and end up with 300 hits. Of those about 200 are some form of hardcoded tag for reading/writing JSON properties, and 99 are built strings for things like file names and shared preferences.
This 2 hour process left me with 1 actual string literal that wasn't being localized.
The question: Is there a built-in way to say, "run this localization check, but ignore lines that match this [list of] regular expression[s]"?