Hello! I try to connect i18 for vue.js as described here http://kazupon.imtqy.com/vue-i18n/guide/started.html#html
installing the package in resources / assets / js / app.js prescribed:
import Vue from 'vue'; ... import VueI18n from 'vue-i18n' Vue.use(VueI18n) And I use it in resources / assets / js / components / document_categories / DocumentCategoryEdit.vue:
<template> <section class="card col-sm-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> <p>{{ $t("message.hello") }}</p> </section> <!-- class="card" --> </template> <script> import {bus} from '../../app'; import appMixin from '../../appMixin'; // import VueI18n from 'vue-i18n' Vue.component('markdown-editor', require('../../components/lib/MarkdownEditor.vue')); Vue.component('editor-header', require('../../components/lib/EditorHeader.vue')); Vue.component('editor-buttons', require('../../components/lib/EditorButtons.vue')); // Vue.use(VueI18n) const messages = { en: { message: { hello: 'hello world' } }, ru: { message: { hello: 'Превед медвед' } } } // Create VueI18n instance with options const i18n = new VueI18n({ locale: 'ru', // set locale messages, // set locale messages }) export default { created() { ... And in the console error:
app.js:152341 Uncaught ReferenceError: VueI18n is not defined at Object.render (app.js:152341) at __webpack_require__ (app.js:20) at Object.defineProperty.value (app.js:152192) at __webpack_require__ (app.js:20) at Object._typeof (app.js:4735) at __webpack_require__ (app.js:20) at Object.<anonymous> (app.js:80447) at __webpack_require__ (app.js:20) at app.js:63 at app.js:66 If you uncomment 2 lines with connecting and using VueI18n I get an error:
app.js:6917 [Vue warn]: Error in render: "TypeError: Cannot read property '_t' of undefined" It seems that VueI18n is not connected, and in the second case, although I thought that it was not necessary to connect it in the vue file itself ...
Apparently you need to somehow connect VueI18n in a vue file?
Laravel Framework : 5.6.24 "vue": "^2.5.7" "vue-i18n": "^7.8.0", Thank!
MODIFIED: Successfully installing
npm install vue-i18n --save the command (as indicated by Kosta B) received an error:
$ npm run build npm ERR! missing script: build npm ERR! A complete log of this run can be found in: npm ERR! /home/serge/.npm/_logs/2018-06-12T14_53_02_740Z-debug.log And the specified file has the contents:
0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ] 2 info using npm@6.1.0 3 info using node@v9.11.1 4 verbose stack Error: missing script: build 4 verbose stack at run (/usr/lib/node_modules/npm/lib/run-script.js:151:19) 4 verbose stack at /usr/lib/node_modules/npm/lib/run-script.js:61:5 4 verbose stack at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:5 4 verbose stack at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:418:5 4 verbose stack at checkBinReferences_ (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:373:45) 4 verbose stack at final (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:416:3) 4 verbose stack at then (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:160:5) 4 verbose stack at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:364:12 4 verbose stack at /usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16 4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:525:3) 5 verbose cwd /mnt/_work_sdb8/wwwroot/lar/TasksBs41 6 verbose Linux 4.13.0-45-generic 7 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build" 8 verbose node v9.11.1 9 verbose npm v6.1.0 10 error missing script: build 11 verbose exit [ 1, true ] Is the format of the command correct? I do not remember that I used such a command ...
npm install vue-i18n --savedid, thennpm run build. - Kosta B.npm install, this should have been done first. - Kosta B.