Я пытаюсь использовать nuxti18n, хотя есть несколько примеров, но ни один из них не работает.Я смог изменить язык, но он не смог перевести.
Документы: https://nuxt -community.github.io / nuxt-i18n /
Все, что естьпрокомментировал Это то, что уже попробовал
Components / Header.vue
<nuxt-link :to="switchLocalePath('pt')">pt</nuxt-link>
<nuxt-link :to="switchLocalePath('en')">en</nuxt-link>
<nuxt-link :to="switchLocalePath('de')">de</nuxt-link>
<nuxt-link :to="switchLocalePath('fr')">fr</nuxt-link>
nuxt.config.js
modules: [
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
'@nuxtjs/auth',
'bootstrap-vue/nuxt',
['nuxt-i18n', {
locales: [
//{ code: 'en', iso: 'en-US', langFile: 'en.json' },
//{ code: 'en', iso: 'en-US', langFile: '~/locales/en.json' },
//{ code: 'en', iso: 'en-US', langFile: './locales/en.json' },
//{ code: 'en', iso: 'en-US', langFile: '../locales/en.json' },
{ code: 'en', iso: 'en-US', langFile: 'en.json' },
{ code: 'pt', iso: 'pt-PT', file: 'pt.json' },
{ code: 'de', iso: 'de-DE', file: 'de.json' },
{ code: 'fr', iso: 'ft-FR', langFile: 'fr.json' }
],
langDir: 'locales/' //with and without
/*vueI18n: {
fallbackLocale: 'pt',
messages: {
//en: require('./locales/en.json'),
//en: require('en.json'),
//en: require('locales/en.json'),
//en: require('./locales/en.json'),
//en: require('~/locales/en.json'),
//en: require('../locales/en.json'),
en: require('~/locales/en.json'),
fr: require('~/locales/fr.json'),
de: require('~/locales/de.json'),
pt: require('~/locales/pt.json')
}*/
}]
],
/ locales / en.json
{
"crm": {
"entidades":{
"editarEntidade":{
}
},
"pesquisa": "Search",
"pesquisar": "Search...",
"sim": "Yes",
"nao": "No",
"nomeUtilizador": "User name",
"nome": "Name",
"email": "Email",
"admin": "Admin",
"acoes": "Actions",
"porPagina": "Per Page",
"confirmarEliminar": "Do you want to delete the user ",
"cancelar":"Cancel",
"confirmar": "Confirm"
},
"pt": "Portuguese",
"en": "English",
"fr": "French",
"de": "Germam"
}
предупреждение консоли (многие из них)
...
[vue-i18n] Cannot translate the value of keypath 'crm.pesquisa'. Use the value of keypath as default.
...
{{$ t ('crm.cancelar')}} я ожидаю Отмена, но показывает crm.cancelar
Thx дляпомогая этому новичку:)