Internationalizing Messages in Groovy Views

This section is a work in progress. Want to help? Check out the jenkinsci-docs mailing list. For other ways to contribute to the Jenkins project, see this page about participating and contributing.

Introduction

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

Example

As an example, consider the following groovy page:

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

package jenkins.security.DownloadSettings

def f = namespace(lib.FormTagLib)

f.section(title:_("Plugin Manager")) {
        f.entry(field: "useBrowser") {
                f.checkbox(title: _("Use browser for metadata download"))
        }
}

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

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

Plugin\ Manager=\u63D2\u4EF6\u7BA1\u7406
Use\ Browser=\u4F7F\u7528\u6D4F\u89C8\u5668
Use\ browser\ for\ metadata\ download=\u4F7F\u7528\u6D4F\u89C8\u5668\u4E0B\u8F7D\u5143\u6570\u636E

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.