Complementary topics
In this section, we will cover a few more topics that can be useful for bigger apps.
Internationalization and code-splitting
If the app is to be used by people in different countries, it should be translated to be more user-friendly and appealing. To localize the texts of the app, you can use the recommended vue-i18n
package:
npm i -S vue-i18n
Using vue-i18n
, we will add a link in the AppFooter
component to a new page where the user can select the language. Only the link and this page will be translated, but you can translate more parts of the app if you wish. vue-i18n
works by creating a i18n
object from it with the translated messages and injecting it into the Vue app.
- In the
src/plugins.js
file, install the new plugin into Vue:
import VueI18n from 'vue-i18n'
// ...
Vue.use(VueI18n)
- Let's create a new folder called
i18n
in the project directory. Download thelocales
folder (https://github.com/Akryum/packt-vue-project-guide/tree/master/chapter7-download/locales...