bertramdev / asset-pipeline

The core implementation of the asset pipeline for the jvm
194 stars 92 forks source link

How to load properies from Grails plugins? #206

Open lploom opened 6 years ago

lploom commented 6 years ago

I have some properties in Grails plugin that defines some javascript files. It uses both messages.properties and messages.i18n I depend on that plugin in child container Grails app. In that app I define my own messages.properties and messages.i18n files. Now, I can use all the properties from messages.properties files from the plugin and child app. However, I cannot use i18n files in the child app. In the child app I can only use i18n properties that I have definer in both messages.properties and messages.i18n files.

Documentation https://github.com/bertramdev/asset-pipeline/tree/master/i18n-asset-pipeline-grails states that "Added support for loading messages.properties from plugins, Note: Changes to the messages properties files are not hot reloaded. You need to update the i18n file for this to happen." so somehow i18n properties should be extensible. Also I built the latest version (i18n-asset-pipeline-grails-2.14.10) from source since the dependencies defined in readme don't work. buildscript { dependencies { classpath 'org.amcworld.plugins:i18n-asset-pipeline:2.1.0-SNAPSHOT' } } dependencies { runtime 'org.grails.plugins:i18n-asset-pipeline:2.1.0-SNAPSHOT' }

warnerandy commented 6 years ago

@lploom i think what you are saying is that the properties from the plugin's messages.properties file dont seem to be added into the compiled version of messages.i18n in the child app.

Right now the plugin source basically looks everywhere for {filename}.properties before merging and creating the messages js file. The only reason I can see this not loading the codes from properties from the plugin is if there is a naming inconsistency between the plugin's .properties file and your .i18n file.

Can you provide a sample project that shows this error occurring?

lploom commented 6 years ago

@warnerandy Yes that's exactly what I meant. There has been an update from 2.14 to 3.0, I will test again and get back to you.

lploom commented 6 years ago

@warnerandy It didn't work. I've created a sample app here https://github.com/lploom/grails-i18n-bug How to run the sample Clone git clone https://github.com/lploom/grails-i18n-bug.git Install parent plugin to maven local repository grails-i18n-bug/parent/gradlew clean install -Dbuild.number=1 Child app has the dependency already defined (compile 'parent:parent:0.1') Run the child app grails run-app

In browser console you should be able to use $L('parentJsOnly') but it's undefined. The parent plugin's i18n properties do not get merged. However, you can use the parent messages.properties on the backend.