Reputation: 26142
Context: single page web applications written in JavaScript and AMD modules (like require.js)
What is the better way to implement i18n with AMD modules?
Lets say:
translation.js returns some i18n function
require([..modules files., 'translation.js' ], function(.modules.. , t ){
here in the code/view templates I use t('give_me_text') function
})
Is such approach ok?
Upvotes: 1
Views: 880
Reputation: 4498
it's ok but if your doing a singlepage app you might consider using a template engine and use some helper there to translate the templates during parsing.
you might have a look at http://i18next.com i18n for javascript (has amd version) and the template section
Upvotes: 1