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

前端 未结 6 1900
既然无缘
既然无缘 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:18

    NOTE: This solutions can help with HALF your problem- finding all hardcoded strings. You will still need to do the actual refactoring yourself because you still need to name all extracted strings.


    EDIT:

    This is the shorter and better answer:

    1. Menu -> Analyze -> Run Inspection by name... (even has a shortcut if you feel nimble)
    2. Type "Hardcoded Text", select scope and run.

    You can run a custom lint inspections - to find only hardcoded texts in layout files:

    1. Menu -> Analyze -> Inspect Code
    2. selects desired scope (layouts, for instance)

    3. under 'Inspection profile', select a new custom profile (...)

    4. Duplicate an existing profile, and un-check all inspections EXCEPT 'HardcodedText'

    1. Run this inspection, and all your hardcoded strings will conveniently be collected into a single list.

提交回复
热议问题