diff --git a/I18nAssetPipelineGrailsPlugin.groovy b/I18nAssetPipelineGrailsPlugin.groovy index 55a9907..fe7f716 100644 --- a/I18nAssetPipelineGrailsPlugin.groovy +++ b/I18nAssetPipelineGrailsPlugin.groovy @@ -22,7 +22,7 @@ import asset.pipeline.i18n.I18nAssetFile class I18nAssetPipelineGrailsPlugin { - def version = '0.9.0' + def version = '0.9.1' def grailsVersion = '2.2 > *' def title = 'I18n Asset Pipeline Plugin' def author = 'Daniel Ellermann' diff --git a/grails-app/taglib/asset/pipeline/I18nTagLib.groovy b/grails-app/taglib/asset/pipeline/I18nTagLib.groovy index e0a5f9a..daa077f 100644 --- a/grails-app/taglib/asset/pipeline/I18nTagLib.groovy +++ b/grails-app/taglib/asset/pipeline/I18nTagLib.groovy @@ -20,6 +20,7 @@ package asset.pipeline import org.codehaus.groovy.grails.commons.GrailsApplication +import org.springframework.core.io.Resource class I18nTagLib { @@ -56,6 +57,9 @@ class I18nTagLib { } } locale = locale.replace('-', '_') + if (log.debugEnabled) { + log.debug "Retrieving i18n messages for locale ${locale}…" + } String name = attrs.remove('name') ?: 'messages' String [] parts = locale.split('_') @@ -67,13 +71,32 @@ class I18nTagLib { buf << '_' << parts[j] } String s = buf.toString() - def f = AssetHelper.fileForUri( - s.toString(), 'application/javascript' - ) - if (f != null) { + if (log.debugEnabled) { + log.debug "Trying to find asset ${s}…" + } + + /* + * XXX This is a somewhat dirty hack. When running in WAR file a + * filter (asset.pipeline.AssetPipelineFilter) looks for a resource + * in folder "assets". So we try this first, and, if not found, we + * look in "grails-app/assets" via fileForUri(). + */ + Resource res = + grailsApplication.mainContext.getResource("assets/${s}.js") + if (res.exists()) { src = s + break + } else { + def f = AssetHelper.fileForUri(s, 'application/javascript') + if (f != null) { + src = s + break + } } } + if (log.debugEnabled) { + log.debug "Found asset ${src ?: name}" + } out << asset.javascript(src: src ?: name) } diff --git a/src/groovy/asset/pipeline/i18n/I18nAssetFile.groovy b/src/groovy/asset/pipeline/i18n/I18nAssetFile.groovy index 0a0ebd8..d74424f 100644 --- a/src/groovy/asset/pipeline/i18n/I18nAssetFile.groovy +++ b/src/groovy/asset/pipeline/i18n/I18nAssetFile.groovy @@ -29,7 +29,7 @@ import asset.pipeline.CacheManager * keys to localized messages. * * @author Daniel Ellermann - * @version 0.9.0 + * @version 0.9 */ class I18nAssetFile extends AbstractAssetFile {