bertramdev / asset-pipeline

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

Support for multiple anonymous javascript functions in Grails i18n plugin #231

Closed smakela closed 5 years ago

smakela commented 5 years ago

Added support for multiple anonymous functions in the page.

Use case is that I want to have translations in multiple properties files and also have plugins to contain their own javascript translations in the plugin.

So I can have multiple calls to taglib in the page for example:

<asset:i18n name="plugin/bar locale="${lang}"/>

Current implementation does not support this.

I just exposed messages through $L.messages and then merge the associative arrays. This should be also very compatible with different browsers because only thing that is used is "hasOwnProperty"

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty

If ES6 is ok the the merge function could be replaced with Object.assign()

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

smakela commented 5 years ago

@davydotcom Any comments on this?

smakela commented 5 years ago

@davydotcom Any thoughts on this one? I would need this kind of functionality to my grails 3 apps.

smakela commented 5 years ago

@davydotcom Is new version going to be released anytime soon?