Answer the question
In order to leave comments, you need to log in
How to make translation in Nuxt, using i18n, to asyncData?
Good afternoon,
there is a need to create breadcrumbs that will support internationalization.
Breadcrumbs are a separate component, the data to which is passed through Vuex. The "asyncData" method is called on the pages - so that the crumbs are generated on the server. But the translation does not work.
Please tell me what is the catch?
Page call:
i18n: {
messages: {
ru: require('./page-ru.json'),
uk: require('./page-uk.json'),
},
},
asyncData({ app, store }) {
store.commit('breadcrumbs/setData', [
{
name: app.i18n.t('текст для перевода страницы'),
path: 'url',
},
]);
},
export default ({ app }) => {
app.i18n = new VueI18n({
locale: app.$cookies.get('language') || 'ru',
fallbackLocale: 'uk',
silentTranslationWarn: true,
});
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question