diff --git a/.classpath b/.classpath
index 34c81af..7a4eb17 100644
--- a/.classpath
+++ b/.classpath
@@ -7,27 +7,22 @@
-
+
-
+
-
+
-
-
-
-
-
-
+
diff --git a/.gitignore b/.gitignore
index 4776242..e6cfb53 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
/*.zip.sha1
/plugin.xml
/target/
+/web-app/WEB-INF/
diff --git a/.project b/.project
index b00e49a..56c669e 100644
--- a/.project
+++ b/.project
@@ -20,7 +20,7 @@
.link_to_grails_plugins
2
- GRAILS_ROOT/2.4.3/projects/I18nAssetPipeline/plugins
+ /home/dellermann/projects/i18n-asset-pipeline/target/plugins
diff --git a/I18nAssetPipelineGrailsPlugin.groovy b/I18nAssetPipelineGrailsPlugin.groovy
index 5a129a8..826fd31 100644
--- a/I18nAssetPipelineGrailsPlugin.groovy
+++ b/I18nAssetPipelineGrailsPlugin.groovy
@@ -17,12 +17,8 @@
*/
-import asset.pipeline.AssetHelper
-import asset.pipeline.i18n.I18nAssetFile
-
-
class I18nAssetPipelineGrailsPlugin {
- def version = '0.9.0'
+ def version = '1.0.0'
def grailsVersion = '2.2 > *'
def title = 'I18n Asset Pipeline Plugin'
def author = 'Daniel Ellermann'
diff --git a/README.md b/README.md
index 31b2157..eee246c 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,15 @@ client-side i18n.
For more information on how to use asset-pipeline, visit
[asset-pipeline project page][asset-pipeline].
+Version information
+-------------------
+
+Because `asset-pipeline` 2.0.0 introduced a new API and isn't backward
+compatible, you must use the following versions of this plugin:
+
+* for `asset-pipeline` up to version 1.9.9 use version 0.9.0 of this plugin
+* for `asset-pipeline` version 2.0.0 or higher use version 1.0.0 of this plugin
+
Usage
-----
@@ -75,7 +84,6 @@ To DRY, add a file `_messages.i18n` to `grails-app/assets/javascripts`:
# List of message codes that should be available on client-side.
#
-
# Add your messages codes here:
default.btn.cancel
default.btn.ok
@@ -114,7 +122,7 @@ Examples:
```
```html
-
+
```
Author
diff --git a/grails-app/taglib/asset/pipeline/I18nTagLib.groovy b/grails-app/taglib/asset/pipeline/I18nTagLib.groovy
index e0a5f9a..ec2deaa 100644
--- a/grails-app/taglib/asset/pipeline/I18nTagLib.groovy
+++ b/grails-app/taglib/asset/pipeline/I18nTagLib.groovy
@@ -22,6 +22,13 @@ package asset.pipeline
import org.codehaus.groovy.grails.commons.GrailsApplication
+/**
+ * Class {@code I18nTagLib} contains tags that help loading client-side i18n
+ * files.
+ *
+ * @author Daniel Ellermann
+ * @version 1.0
+ */
class I18nTagLib {
//-- Class variables ------------------------
diff --git a/src/groovy/asset/pipeline/i18n/I18nAssetFile.groovy b/src/groovy/asset/pipeline/i18n/I18nAssetFile.groovy
index 3d1ad47..65d5b03 100644
--- a/src/groovy/asset/pipeline/i18n/I18nAssetFile.groovy
+++ b/src/groovy/asset/pipeline/i18n/I18nAssetFile.groovy
@@ -30,7 +30,8 @@ import java.util.regex.Pattern
* keys to localized messages.
*
* @author Daniel Ellermann
- * @version 0.9.0
+ * @author David Estes
+ * @version 1.0
*/
class I18nAssetFile extends AbstractAssetFile {
@@ -43,16 +44,19 @@ class I18nAssetFile extends AbstractAssetFile {
static final String compiledExtension = 'js'
static processors = [I18nProcessor]
Pattern directivePattern = ~/(?m)#=(.*)/
- //-- Public methods -------------------------
+ //-- Public methods -------------------------
+
@Override
String processedStream(AssetCompiler precompiler) {
def skipCache = precompiler ?: (!processors || processors.size() == 0)
String fileText
if(baseFile?.encoding || encoding) {
- fileText = inputStream?.getText(baseFile?.encoding ? baseFile.encoding : encoding)
+ fileText = inputStream?.getText(
+ baseFile?.encoding ? baseFile.encoding : encoding
+ )
} else {
fileText = inputStream?.text
}
@@ -61,9 +65,7 @@ class I18nAssetFile extends AbstractAssetFile {
def md5 = AssetHelper.getByteDigest(fileText.bytes)
if (!skipCache) {
- def cache = CacheManager.findCache(
- path, md5, baseFile?.path
- )
+ def cache = CacheManager.findCache(path, md5, baseFile?.path)
if (cache) {
return cache
}
@@ -75,10 +77,7 @@ class I18nAssetFile extends AbstractAssetFile {
}
if (!skipCache) {
- CacheManager.createCache(
- path, md5, fileText,
- baseFile?.path
- )
+ CacheManager.createCache(path, md5, fileText, baseFile?.path)
}
fileText
diff --git a/src/groovy/asset/pipeline/i18n/I18nPreprocessor.groovy b/src/groovy/asset/pipeline/i18n/I18nPreprocessor.groovy
index 4b2b76c..01ecbd8 100644
--- a/src/groovy/asset/pipeline/i18n/I18nPreprocessor.groovy
+++ b/src/groovy/asset/pipeline/i18n/I18nPreprocessor.groovy
@@ -19,8 +19,8 @@
package asset.pipeline.i18n
-import asset.pipeline.AssetHelper
import asset.pipeline.AssetFile
+import asset.pipeline.AssetHelper
import groovy.transform.CompileStatic
import java.util.regex.Matcher
import java.util.regex.Pattern
@@ -31,7 +31,8 @@ import java.util.regex.Pattern
* which are used in the asset pipeline.
*
* @author Daniel Ellermann
- * @version 0.9.0
+ * @author David Estes
+ * @version 1.0
*/
@CompileStatic
class I18nPreprocessor {
@@ -79,8 +80,11 @@ class I18nPreprocessor {
* Pre-processes an i18n file by removing empty lines and comment lines and
* resolving all imports.
*
- * @param input the content of the i18n file
- * @return the pre-processed content
+ * @param input the content of the i18n file
+ * @param fileHistory the history of all import files that have been
+ * processed already; this is needed to handle
+ * circular dependencies
+ * @return the pre-processed content
*/
protected String preprocess(String input, Set fileHistory) {
StringBuffer buf = new StringBuffer(input.length())
@@ -102,15 +106,21 @@ class I18nPreprocessor {
/**
* Loads the import file with the file name and processes its content.
*
- * @param fileName the name of the import file
- * @return the pre-processed content of the import file
+ * @param fileName the name of the import file
+ * @param fileHistory the history of all import files that have been
+ * processed already; this is needed to handle
+ * circular dependencies
+ * @return the pre-processed content of the import file
*/
- protected String resolveImport(String fileName, Set fileHistory) {
+ protected String resolveImport(String fileName,
+ Set fileHistory)
+ {
if (!fileName.endsWith('.i18n')) {
fileName += '.i18n'
}
- AssetFile importFile = (AssetFile) AssetHelper.fileForFullName(fileName)
+ AssetFile importFile =
+ (AssetFile) AssetHelper.fileForFullName(fileName)
if (importFile == null || importFile in fileHistory) {
return ''
}
diff --git a/src/groovy/asset/pipeline/i18n/I18nProcessor.groovy b/src/groovy/asset/pipeline/i18n/I18nProcessor.groovy
index 1766f29..c80dfa9 100644
--- a/src/groovy/asset/pipeline/i18n/I18nProcessor.groovy
+++ b/src/groovy/asset/pipeline/i18n/I18nProcessor.groovy
@@ -22,10 +22,8 @@ package asset.pipeline.i18n
import asset.pipeline.AbstractProcessor
import asset.pipeline.AssetCompiler
import asset.pipeline.AssetFile
-import asset.pipeline.AssetHelper
import groovy.transform.CompileStatic
import java.util.regex.Matcher
-import java.util.regex.Pattern
import org.springframework.core.io.DefaultResourceLoader
import org.springframework.core.io.Resource
import org.springframework.core.io.ResourceLoader
@@ -55,7 +53,8 @@ import org.springframework.core.io.ResourceLoader
*
*
* @author Daniel Ellermann
- * @version 0.9.0
+ * @author David Estes
+ * @version 1.0
*/
class I18nProcessor extends AbstractProcessor {