I’m using the Grails Resources plugin with jQuery validation. jQuery validation has locale-specific texts declared as JS files:
/localization
messages_ar.js
messages_bg.js
messages_ca.js
And so on and so forth. In my ApplicationResources.groovy file, I have the following block declared:
form {
resource url: '/js/jquery/jquery.validate.js'
resource url: '/js/jquery/jquery.validate.additional-methods.js'
resource url: '/js/jquery/localization/messages_es.js'
}
But this is a hard-coded value. Is there any way I can configure the Resources plugin to load the correct JS file based on the user’s locale?
Here’s how I’ve done this in the past:
In your view when you are laying out resources, add something like:
<r:external uri=”js/messages_${RequestContextUtils.getLocale(request).getLanguage()}.js”/>
this should properly pull the resource based on the local.
Hope that helps!