How to extract Java hard-coded strings from source code to resources
Lingobit Extractor extracts hard-coded strings from Java source code to .properties files. It is most commonly used solution to store Java resources and prepare application for localization.
By default Lingobit Extractor replaces string with a call to getText function, that incapsulates loading of resource string for current locale. Extracted string is stored into .properties file.
Code replace templates
There are several replace templates for Java source code.
Get string using automatically generated Resource Bundle wrapper. You can customize wrapper generation at "Resource Wrapper" page.
Loads ResourceBundle and gets string from it. Use of this template doesn't require any additional code changes.
Use custom-defined 'getString' method to load strings. It is recommended name for custom function.
Step by Step
Here are the steps to extract hardcoded strings from Java source code and prepare your application for localization
- Make getText function visible in all files you are going to modify
- Create Lingobit Extractor project and add you source files into it
- Add existing .properties file or create new one.
- Review and extract hard-coded strings
- Save the changes