I18n Templates Plugin
This simple plugin provides i18n aware scaffolding templates to generate fully internationalizable applications. The templates are identical to the default by Grails provided scaffolding templates, except that they are i18n aware. When the default Grails templates change, this plugin will be updated accordingly.
This plugin is updated to Grails 1.0.1
Installation
To install the i18n templates plugin type this command from your project's root folder:
grails install-plugin i18n-templates
Installing the plugin overwrites any previously installed scaffolding templates.
Usage
The i18n resource bundles contained by your application will be used to resolve page titles, header labels, property labels, button labels and feedback messages. These texts need to be added manually; however if you don't add any messages, the Grails application will render as if the default templates were used. This is done by using default texts which are indentical to the texts which are used by the default templates.
If you want to customize or translate the texts then add messages for the following keys to your i18n resource bundle(s) for each domain:
<domainClass>.create <domainClass>.edit <domainClass>.list <domainClass>.new <domainClass>.show <domainClass>.created <domainClass>.updated <domainClass>.deleted <domainClass>.not.found <domainClass>.<property> <-- for each property <domainClass>.<property>.<value> <-- for each value in a list constraint
|
You can use the generate-i18n-messages script to ouput all needed messages for a domain class to your command line interface. grails generate-i18n-messages <domainClass> If you have a domain class in a package or are generating from a Hibernate mapped class remember to include the fully qualified package name. grails generate-i18n-messages <fully qualified package name><domainClass>
|
Example
Imagine you application consists of these 2 domain classes:
class Author {
static hasMany = [books:Book]
String name
static constraints = {
name(blank: false, maxSize: 50)
}
}
class Book {
Author author
String isbn
String title
String category
Float price
String description
static constraints = {
author()
isbn(blank: false, maxSize: 10)
title(blank: false, maxSize: 50)
category(inList: ["Fantasy", "Mystery", "Romance", "Thriller"])
price(min: 0F, max: 100F, nullable: true)
description(blank: true, maxSize: 500)
}
}
Then these messages could be used to translate your application:
# Author messages author.create=Create Author author.edit=Edit Author author.list=Author List author.new=New Author author.show=Show Author author.created=Author {0} created author.updated=Author {0} updated author.deleted=Author {0} deleted author.not.found=Author not found with ID {0} author.id=ID author.name=Name author.books=Books # Book messages book.create=Create Book book.edit=Edit Book book.list=Book List book.new=New Book book.show=Show Book book.created=Book {0} created book.updated=Book {0} updated book.deleted=Book {0} deleted book.not.found=Book not found with ID {0} book.id=ID book.author=Author book.isbn=ISBN book.title=Title book.category=Category book.category.Fantasy=Fantasy book.category.Mystery=Mystery book.category.Romance=Romance book.category.Thriller=Thriller book.price=Price book.description=Description
General messages
The plugin already contains English and Dutch texts for general messages as displayed below:
home=Home create=Create edit=Edit update=Update delete=Delete delete.confirm=Are you sure?
When installing the i18n templates plugin these texts are installed as 'i18n-templates.properties' resource bundles in your project's grails-app\i18n folder.
If you are creating a translation for a different language then you need to add a translation for above messages as well.

