1. Introduction

GR8 CRM is a set of Grails Web Application Framework plugins that makes it easy to develop web applications with CRM functionality.

You can find more information about GR8 CRM on the main documentation site http://gr8crm.github.io.

1.1. Customer relationship management

Customer relationship management (CRM) is a system for managing a company’s interactions with current and future customers. It involves using technology to organize, automate and synchronize sales, marketing, customer service, and technical support. Wikipedia

The GR8 CRM "Ecosystem" currently contains over 40 Grails plugins. For a complete list of plugins see http://gr8crm.github.io.

Each GR8 CRM plugin defines a Bounded Context that focus on one specific domain, for example contact, project or document.

2. CRM i18n Plugin

The crm-i18n plugin installs a custom Spring MessageSource grails.plugins.crm.i18n.CrmMessageSource that provide two main features.

  1. Messages can be stored in the database making it possible to override messages stored in property files in grails-app/i18n.

  2. During message lookup a few message key variants are used as fallback when the exact message key does not match. This reduces the number of message keys needed in an application if it’s possible to fall back to generic messages.

2.1. Message key fallback

The crm-i18n plugin implements a custom message lookup algorithm that makes it possible to reduce the number of message keys in message bundles (.properties files). The algorithm is best explained with an example:

<g:message code="crmContact.button.save"/>

For the above message lookup CrmMessageSource tries with the following keys until a message is found.

  1. Database: crmContact.button.save

  2. Message Bundle: crmContact.button.save

  3. Database: crmContact.button.save.label

  4. Message Bundle: crmContact.button.save.label

  5. Database: default.button.save

  6. Message Bundle: default.button.save

  7. Database: default.button.save.label

  8. Message Bundle: default.button.save.label

As soon as a message is found it is cached to make future lookups faster.

This lookup strategy makes it possible to have generic messages for common texts, like button labels for Save, Find, Delete, etc. The .gsp can contain markup specifying a unique key for the save button crmContact.button.save.label but does not need to provide that key in the message bundle. Instead a generic default.button.save.label = Save can be provided by the application bundle or a common plugin.

If you want to have a unique label in one specific application you can add the key crmContact.button.save.label = Save Contact Information in the application’s message bundle.

3. Services

The crm-i18n plugin provide a service called CrmMessageService. This service contains methods for retrieving and updating messages and also methods that import and exports messages.

3.1. CrmMessageService

void setMessage(String key, String value, Locale locale = null)

Updates the message specified by key with the text value. The text will be updated in the database, not in the message bundle (.properties file). A Locale instance can be specified to set the text for a specific language, otherwise the default server locale will be used.

Example

crmMessageService.setMessage('crmContact.number.label', 'Customer Id', Locale.ENGLISH)

int copyMessages(Number from, Number to, Boolean overwrite = false)

Copy customized messages from one tenant to another.

File exportToFile(String filename = null)

Export all customized messages to a message bundle (.properties file).

void importText(InputStream inputStream, Locale locale = null)

Import messages from a message bundle (.properties file) to the database.

4. Caching

This plugin can use EhCache to cache messages retrieved from database (recommended). To enable caching, configure a bean named messageCache in resources.groovy

resources.groovy
import org.springframework.cache.ehcache.EhCacheFactoryBean

beans = {
    messageCache(EhCacheFactoryBean) {
        timeToLive = 3600
        timeToIdle = 1800
        maxElementsInMemory = 5000
        eternal = false
        overflowToDisk = false
    }
}

5. Changes

2.4.0

First version compatible with Grails 2.4.4.

2.0.0

First public release.

6. License

This plugin is licensed with Apache License version 2.0

7. Source Code

The source code for this plugin is available at https://github.com/goeh/grails-crm-i18n

8. Contributing

Please report issues or suggestions.

Want to improve the plugin: Fork the repository and send a pull request.