问题
I'm developing a web application and I'd need some advice on how to solve the following 'problem' of internationalization.
I use Grails 2.2.0
along with Ember.js
and Handlebars.js
whereas the frontend (which is realised through JavaScript with the before mentioned frameworks) is residing in it's on project with the Sass
files for styling Grunt.js
for compiling the whole thing.
Within this 'frontend project' I create the handlebars
templates which I want to deliver via Grails
on demand, with the full text of the template being internationalized through the server side (Grails
) according to the locale of the logged in user. So, the workflow would be something like the following:
Client (JS) -> requests Backend (Grails)
Backend Controller checks if the user has permission to access this method, checks the set
locale
of the user, precompiles the accordingtemplate
(handlebars) with the correcti18n
file, fetches the neededdata
and returns aJSON
object withdata
andtmpl
valuesBackend (Grails) responses to Client (JS)
Client takes template, caches it if possible and compiles it with the given data set to place
Is there a proper Grails
plugin for this issue? If I'm searching for 'handlebars' at the Grails Plugin page I get 3 matches:
- Handlebars Plugin
- Handlbars Resources Plugin
- EmberJS templates precompiler Plugin
I read through the documentation of all of them but I'm still not sure whether any of this plugins could be used to what I'm looking for or not. The reason why I want to do it like this is, that I have very large (and by that I mean VERY LARGE) i18n
files in at least 12 different languages which I don't want to send to the client per se...
Has anybody had the same issue/problem/challenge and could provide me some information to this topic? Or is my approach complete nonsense and I should try another way?
来源:https://stackoverflow.com/questions/16173957/grails-internationalization-with-ember-js-and-handlebars-js