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
Thanks, we've got you!
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 on the Fly With the IntelliJ Profiler
At JetBrains, we believe that profiling 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 range of features to s…
Java Annotated Monthly – July 2023
Welcome to Java Annotated Monthly! We have an exciting edition lined up for you, packed with valuable content and insightful articles. You will learn about AI Assistant by JetBrains, discover new features in the upcoming Java 21 release, and gain valuable instruction from tutorials, tips, and tri…
History of Gradle Delegation Process in IntelliJ IDEA
Nowadays, a build tool is an essential part of any project, and IntelliJ IDEA integrates with the majority of them. Among the most popular build tools is Gradle. We’d like to give a brief historical overview of its integration with IntelliJ IDEA and the delegation process implemented inside the I…