I'm developing a extjs project using 6.5.1 version and modern toolkit, i have a singleton class that manage all translations something like that:
Ext.define('QApplication.Labels', {
singleton: true,
name: "Name",
email: "Email",
correctAnswer: "Correct Answer",
button: 'My Button'
});
Now it's located in the main viewmodel:
Ext.define('QApplication.view.main.MainModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.main',
data: {
i18n: QApplication.Labels,
}
});
Now, i define a DataView with his own XTemplate but i have to use some of the translations given by the singleton class:
var qTpl = new Ext.XTemplate(
"<div class=\"question-text\"><a \">{questionTitle}</a></div>",
"<tpl if='totalAnswers > 0'>",
"<div class=\"question-answer-color\">{totalAnswers} {i18n.correctAnswer}
"<tpl else>",
"<div class=\"question-answer-no-color\">Unanswered</div>",
"</tpl>",
);
Ext.define('QApplication.view.quest.list', {
extend: 'Ext.dataview.DataView',
xtype: 'qList',
requires: [
'QApplication.store.QTier',
'QApplication.view.main.MainModel'
],
height: 'auto',
controller: '////',
viewModel: 'main',
store: {
type: '////'
},
itemTpl: qTpl
});
In XTemplate, i define the data bind {i18n.correctAnswer} which refer the singleton class that manage all the translations, but it doesn't take the given value