Skip to content

Commit

Permalink
another fix to i18n bundle reloading when not using Gradle (from IDE)
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Oct 8, 2014
1 parent 4f5f5e9 commit 6458e8e
Showing 1 changed file with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,10 @@ class I18nGrailsPlugin implements GrailsApplicationAware, ApplicationContextAwar
def nativeascii = event.application.config.grails.enable.native2ascii
nativeascii = (nativeascii instanceof Boolean) ? nativeascii : true
def ant = new AntBuilder()
File appI18nDir = new File("./grails-app/i18n").canonicalFile
if (isChildOfFile(eventFile, appI18nDir)) {
String i18nDir = resourcesDir.absolutePath

def eventFileRelative = relativePath(appI18nDir, eventFile)

if (nativeascii) {
ant.copy(todir:i18nDir, encoding:"UTF-8") {
fileset(dir:"${Environment.current.reloadLocation}/grails-app/i18n") {
include name:eventFileRelative
}
filterchain {
filterreader(classname:'org.apache.tools.ant.filters.EscapeUnicode')
}
}
}
else {
ant.copy(todir:i18nDir) {
fileset(dir:"./grails-app/i18n", includes:eventFileRelative)
}
}
File i18nDir = new File("${Environment.current.reloadLocation}/grails-app/i18n").canonicalFile
if (isChildOfFile(eventFile, i18nDir)) {
executeMessageBundleCopy(ant, eventFile, i18nDir, GrailsApp.RESOURCES_DIR, nativeascii)
executeMessageBundleCopy(ant, eventFile, i18nDir, GrailsApp.CLASSES_DIR, nativeascii)
}
}

Expand All @@ -142,4 +125,24 @@ class I18nGrailsPlugin implements GrailsApplicationAware, ApplicationContextAwar
messageSource.clearCache()
}
}

private void executeMessageBundleCopy(AntBuilder ant, File eventFile, File i18nDir, File targetDir, boolean nativeascii) {
def eventFileRelative = relativePath(i18nDir, eventFile)

if (nativeascii) {
ant.copy(todir: targetDir, encoding: "UTF-8") {

fileset(dir: i18nDir) {
include name: eventFileRelative
}
filterchain {
filterreader(classname: 'org.apache.tools.ant.filters.EscapeUnicode')
}
}
} else {
ant.copy(todir: targetDir) {
fileset(dir: i18nDir, includes: eventFileRelative)
}
}
}
}

0 comments on commit 6458e8e

Please sign in to comment.