I'am trying to implement i18next translation on my web-site and cannot get success with it.
i18next.init({
debug: true,
lng: 'en',
resources: {
en: {
translation: {
opt: {
page_title: 'Orders'
},
}
},
ru: {
translation: {
opt: {
page_title: 'Заказы'
},
}
}
}, function(err, t) {
jqueryI18next.init(i18next, $);
});
I have vocabulary for some part of my system which need to have a set of named variables.
i18next.addResources('en', 'desktop', {
'Авиа' : 'Avia',
'Ж/Д' : 'Train',
'Произвольная услуга' : 'Custom Service',
'Текущий баланс' : 'Current balance',
'Оборот за предыдущий месяц' : 'Turnover for the previous month',
'Оборот за текущий месяц' : 'Turnover for the current month',
'Общий оборот' : 'Total turnover',
});
i18next.loadNamespaces('desktop');
There is no success with next equation:
var fincanceDict = {
company_balance : $.t('Текущий баланс'),
company_turnover_prev_month : $.t('Оборот за предыдущий месяц'),
company_turnover_current_month : $.t('Оборот за текущий месяц'),
company_turnover_full : $.t('Общий оборот')
}
I'm getting an errors for each translation operation:
i18next.js?v=e988b1:142 i18next::translator: missingKey en translation Текущий баланс Текущий баланс
i18next.js?v=e988b1:142 i18next::translator: missingKey en translation Оборот за предыдущий месяц Оборот за предыдущий месяц
i18next.js?v=e988b1:142 i18next::translator: missingKey en translation Оборот за текущий месяц Оборот за текущий месяц
i18next.js?v=e988b1:142 i18next::translator: missingKey en translation Общий оборот Общий оборот
If I check my i18next.translator.resourceStore.data
I'll get initial vocabulary for en
& ru
language object with translation
child who own a set of nested key/value pairs with no extension I did.
I fill that I missing something, I have try to change namespace
to default
and back to desktop
neither is helped.
loadNamespace -> does load a namespace via backend (eg. xhr-backend): https://www.i18next.com/api.html#loadnamespaces
translation is the default namespace that's why you can access translations in that without prepending it in t function. https://www.i18next.com/configuration-options.html#languages-namespaces-resources
you can create a "fixedT" function