Discussion:
How to Externalize i18N folder
markatharvest
2014-03-17 18:59:59 UTC
Permalink
In production, the messages.properties have to be picked up from a
externalized location..
Question is how can I externalize the i18N folder for PRODUCTION and TESTING
env..





--
View this message in context: http://grails.1312388.n4.nabble.com/How-to-Externalize-i18N-folder-tp4655172.html
Sent from the Grails - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
markatharvest
2014-03-20 00:43:50 UTC
Permalink
Hi

Found a way to fix it, its a kind of a work around, where we did the
following steps

1. in _events.groovy - make sure grails-app/i18N folder is not a part of WAR
2. create a softlink from external folder to where the war is deployed.
3. add it to watched resources section in context.xml, so that each time the
property file is changed externally, it gets relfected in the app

http://grails.1312388.n4.nabble.com/Symlinks-in-the-web-app-directory-td3017473.html
<http://grails.1312388.n4.nabble.com/Symlinks-in-the-web-app-directory-td3017473.html>

Let know if anybody finds a better way of doing it

regards
Mark



--
View this message in context: http://grails.1312388.n4.nabble.com/How-to-Externalize-i18N-folder-tp4655172p4655248.html
Sent from the Grails - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
candrews
2014-03-20 16:15:09 UTC
Permalink
I think there's a better way that doesn't involve symlinks or exploding the
war. Here's how I'm doing it:

In Config.groovy:
---
external.i18n.dir='file:/etc/i18n'
---

In BootStrap.groovy:
---
class BootStrap {
ReloadableResourceBundleMessageSource messageSource
DirectoryWatcher i18nDirectoryWatcher

def init = { servletContext ->
watchi18n();
}

@TypeChecked
/*
* Watch the i18n directory for changes. The requirement is that changes to
the i18n (message bundle) files should be reflected on the live site without
requiring a restart.
*/
void watchi18n(){
messageSource.basename = Holders.flatConfig.get('external.i18n.dir')
i18nDirectoryWatcher = new DirectoryWatcher()
DirectoryWatcher.FileChangeListener fileChangeListener = new
DirectoryWatcher.FileChangeListener() {
void onChange(File file) {
messageSource.clearCacheIncludingAncestors()
}

void onNew(File file) {
messageSource.clearCacheIncludingAncestors()
}
}
i18nDirectoryWatcher.addListener(fileChangeListener)
i18nDirectoryWatcher.addWatchDirectory((new
DefaultResourceLoader()).getResource("${Holders.flatConfig.get('external.i18n.dir')}").getFile(),
'*')
i18nDirectoryWatcher.start()
}

def destroy = {
i18nDirectoryWatcher.setActive(false)
}
---



--
View this message in context: http://grails.1312388.n4.nabble.com/How-to-Externalize-i18N-folder-tp4655172p4655276.html
Sent from the Grails - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Loading...