Makes Grails enums translatable. Annotate an enum with @I18nEnum — or implement the
I18nEnumTrait — and it implements Spring's MessageSourceResolvable, so the enum constant can be
handed straight to messageSource, to <g:message>, or to anything else that resolves message
codes. The codes are derived from the enum's package, class and constant name, and can be tuned per
annotation or globally from the application configuration.
The user guide can be found here: 📚 Documentation
Add the following dependency to your build.gradle:
dependencies {
implementation 'org.grails.plugins:i18n-enums:8.0.0-SNAPSHOT'
}Requires Grails 8 (Java 21 or later, Groovy 5). For Grails 7.x use the 7.0.x line.
import grails.plugins.i18nEnums.annotations.I18nEnum
@I18nEnum
enum OrderStatus {
NEW, PENDING, SHIPPED
}messageSource.getMessage(OrderStatus.NEW, locale) // resolves app.OrderStatus.NEWSee the Documentation for the trait flavour, prefix/postfix/shortName/defaultNameCase options, and
application-wide configuration. A runnable example lives in examples/app1.
See CONTRIBUTING.md. This repository is built on
grails-plugin-template — build-logic/,
gradle/, .github/workflows/, .github/scripts/, .agents/, CONTRIBUTING.md and LICENSE.txt
are kept up to date by its automated file sync and should not be edited here.