Grails internationalization with Ember.js and Handlebars.js

匆匆过客 提交于 2020-01-04 05:57:44

问题


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:

  1. Client (JS) -> requests Backend (Grails)

  2. Backend Controller checks if the user has permission to access this method, checks the set locale of the user, precompiles the according template (handlebars) with the correct i18n file, fetches the needed data and returns a JSON object with data and tmpl values

  3. Backend (Grails) responses to Client (JS)

  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!