refactoring for localization


I need to refactor a project for better localization. Basically, this means going through the code, finding string literals, move them to one of four .properties file, and replacing with a call to getString("]]>"). I didn't find an Extract Property refactor (kinda makes sense, though), but what'd be the best way to do this in IDEA? A third-party plugin?



Turn on the "Hardcoded Strings" inspection, under "Errors/Internationalization Issues". It will highlight every hardcoded string in your program, and offer you a quick-fix to move it to a properties file. If you have a concatenation of strings and arguments, it will offer to turn them into an equivalent format string and store it in a properties file. Overall, it's incredibly slick, although it would be nice if you could easily specify different properties files for different projects/modules.

There's also a bunch of other inspections under "Errors/Internationalization Issues" that you might find handy for finding other I18N issues, although most of them don't have quickfixes.

--Dave Griffith


Please sign in to leave a comment.