i18n supportMarch 28th, 2006 by Alexandra Rusina
It is widely announced that the recently released version 5.1 of IntelliJ IDEA provides an â€œindustry-leading i18n supportâ€. But what does that mean? Well, this phrase covers not just one particular feature, but the whole set of enhancements, improvements, and new features for making internationalization faster and easier.
First of all, the â€œHard coded stringsâ€ inspection helps you to quickly find all hard-coded string literals at once, instead of thoroughly scanning all files in the project.
With this inspection switched on, the literals are highlighted right in the editor. Also you can inspect the code and see the results in the devoted window.
When the hard-coded string is found, it may need internationalization, or it may represent some identifier that does not depend on localization (and thatâ€™s often the case). IntelliJ IDEA smartly handles both variants.
If you decide to internationalize the string, just use the intention action, and the string will be added to an existing .properties file.
IntelliJ IDEA also handles situations when a hard coded String literal is a part of a concatenated string. In this case, the generated property string will contain all necessary parameters.
For the strings that donâ€™t need internationalization, there is a special intention action. With this action you can annotate strings as @NonNls and therefore exclude them from the internationalization process. It is possible to annotate a certain variable or class field as well as a whole method, class, or even package. Just donâ€™t forget to add annotations.jar to your project or module classpath to make the annotation and related intention actions available.
Note that @NonNls annotation is not required for values representing property keys. IntelliJ IDEA recognizes them automatically.
Get interested? See i18n demo.
Note This tip&trick was originally posted at www.javalobby.org.