Backbone.js as i18n value before going to template

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

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

+4
requirejs internationalization
source share
1 answer

I see that this problem is not related to i18n, but in any case, when you need visualization data that still needs to be calculated.

You must prepare your data before sending it to the template that will be displayed, so your template should accept key and show value .

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

Check the answers to this question to find out if any of the answers fits your needs.

0
source share

All Articles