Internationalizing Messages in Jelly Views

Introduction

Jenkins supports internationalizing messages in Jelly views.

In Jenkins, you add a .properties file with the .jelly file in the same directory. Any changes of .properties do not require a restart of Jenkins.

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