Backbone.js的如何传递到模板之前,国际化的价值 [英] Backbone.js how to i18n value before passing to template

查看:125
本文介绍了Backbone.js的如何传递到模板之前,国际化的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Backbone.js的,车把和Require.js与国际化。我有我的en_us.js所有字符串翻译文件,但如何处理动态值的情况下被发送到模板?

Using Backbone.js, Handlebars and Require.js with i18n. I have my en_us.js file with all the string translations, but how do I deal with the case of dynamic values being sent to the template?

我知道所有这些字符串的时间提前,但硬编码它们放入模板看起来凌乱,我可以传递一个pre-翻译字符串中的一些如何?我现在用的是HBS模块对国际化和模板require.js。

I know all these strings ahead of time, but hard coding them into the template seems messy, can I pass in a pre-translated string some how? I am using the hbs module for the i18n and templates with require.js.

推荐答案

我看这个问题不相关的国际化的,而是你需要渲染仍然需要计算数据的情况下。

I see this problem not related to i18n but to any case where you need render data that still need to be calculated.

您应该做饭您的数据发送到模板要呈现之前,让您的模板只是要采取键,显示

You should cook your data before you send it to the template to be rendered, so your template just has to take a key and show the value.

如果你的 Model.attributes 还没有准备好您的模板,你不应该直接发送,但prepare他们,当他们准备把他们送到模板

If your Model.attributes are not ready for your template you shouldn't send them directly but prepare them and when they are ready send them to the template.

检查这个问题以查看是否有任何问题的答案匹配您的需求

Check the answers in this question to see if any of the answers match with your needs.

这篇关于Backbone.js的如何传递到模板之前,国际化的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆