Skip to content

Commit

Permalink
Grails i18n Plugin: Revert 0adeb49
Browse files Browse the repository at this point in the history
  • Loading branch information
rainboyan committed May 25, 2023
1 parent be8b1ae commit acc1626
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,6 @@ package org.grails.plugins.i18n

import java.nio.file.Files

import groovy.ant.AntBuilder
import groovy.util.logging.Slf4j
import org.springframework.core.PriorityOrdered
import org.springframework.core.io.Resource
Expand All @@ -40,7 +39,7 @@ class I18nGrailsPlugin extends Plugin implements PriorityOrdered {

String version = GrailsUtil.getGrailsVersion()
def watchedResources = ['file:./grails-app/i18n/**/*.properties',
'file:./app/i18n/**/*.properties']
'file:./app/i18n/**/*.properties']

@Override
Closure doWithSpring() {
Expand Down Expand Up @@ -84,10 +83,19 @@ class I18nGrailsPlugin extends Plugin implements PriorityOrdered {
File eventFile = event.source.file.canonicalFile
if (isChildOfFile(eventFile, i18nDir)) {
if (nativeascii) {
// if native2ascii is enabled then converts files from native encodings to ASCII
def ant = new AntBuilder()
ant.native2ascii(src: i18nDir, dest: resourcesDir,
includes: eventFile.name, encoding: 'UTF-8')
// if native2ascii is enabled then read the properties and write them out again
// so that unicode escaping is applied
def properties = new Properties()
eventFile.withReader {
properties.load(it)
}
// by using an OutputStream the unicode characters will be escaped
new File(resourcesDir, eventFile.name).withOutputStream {
properties.store(it, '')
}
new File(classesDir, eventFile.name).withOutputStream {
properties.store(it, '')
}
}
else {
// otherwise just copy the file as is
Expand Down

0 comments on commit acc1626

Please sign in to comment.