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.
Subscribe to Blog updates
The What, Why, and How of JPA Buddy in IntelliJ IDEA
Master JPA entity management with JPA Buddy in IntelliJ IDEA! Our latest article shows you how to simplify your workflow and reduce boilerplate code.
The Best of IntelliJ IDEA’s HTTP Client
In today's fast-paced tech world, easy and efficient management of web services and APIs is crucial. That's where IntelliJ IDEA's HTTP Client steps in, turning complex HTTP requests into a walk in the park. The HTTP Client is a feature-rich, text-based tool in IntelliJ IDEA Ultimate. It seamlessl…
Import Postman Collections to the HTTP Client
We know that many of you use Postman collections and want to stay in the flow while working with them. This means staying inside IntelliJ IDEA and not switching to a different app. Great news! You can now effortlessly transform Postman collections into .http and use them in the HTTP Client …
Profile Java and Kotlin Code with the IntelliJ Profiler
At JetBrains, we believe that profiling Java and Kotlin code should be simple and accessible to all developers, regardless of their level of expertise. That’s why the IntelliJ Profiler puts ease of use and seamless integration at the forefront of its mission. In previous releases, we introduced a r…