Internationalizing Messages in Jelly Views

Introduction

Jenkins uses the stapler-jelly library to implement internationalization.

In Jenkins, you need add a similar .properties file with the .jelly file in the same directory. Any changes of .properties does not need restart Jenkins or plugins.

Example

As an example, consider the following jelly page:

src/main/resources/org/example/package/index.jelly:

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:s="/lib/form">
<div>${%message}</div>
</j:jelly>

Then you could add, for example, a Chinese localization file simply as:

src/main/resources/org/example/package/index_zh_CN.properties

message=\u6D88\u606F

In property files all non-ASCII characters need to be converted into hexcode. Modern IDEs do it automatically, so you can be just writing localizations in the target languages there.

References