Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Applications with Spring 5 and Vue.js 2

You're reading from  Building Applications with Spring 5 and Vue.js 2

Product type Book
Published in Oct 2018
Publisher Packt
ISBN-13 9781788836968
Pages 590 pages
Edition 1st Edition
Languages
Author (1):
James J. Ye James J. Ye
Profile icon James J. Ye

Table of Contents (23) Chapters

Title Page
Copyright and Credits
Dedication
About Packt
Contributors
Preface
1. Modern Web Application Development - This Is a New Era 2. Vue.js 2 - It Works in the Way You Expected 3. Spring 5 - The Right Stack for the Job at Hand 4. TaskAgile - A Trello-like Task Management Tool 5. Data Modeling - Designing the Foundation of the Application 6. Code Design - Designing for Stability and Extensibility 7. RESTful API Design - Building Language Between Frontend and Backend 8. Creating the Application Scaffold - Taking off Like a Rocket 9. Forms and Validation - Starting with the Register Page 10. Spring Security - Making Our Application Secure 11. State Management and i18n - Building a Home Page 12. Flexbox Layout and Real-Time Updates with WebSocket - Creating Boards 13. File Processing and Scalability - Playing with Cards 14. Health Checking, System Monitoring - Getting Ready for Production 15. Deploying to the Cloud with Jenkins - Ship It Continuously 1. Other Books You May Enjoy Index

Adding i18n support with Vue-i18n


Now, let's see how to add support for i18n in a Vue application with Vue-i18n (https://kazupon.github.io/vue-i18n).

First of all, we will create a front-end/src/locale directory to put our localized message in. This folder looks as follows:

.
└── locale
    ├── index.js
    └── messages
        ├── en_US.json
        └── zh_CN.json

The following is what front-end/src/locale/index.js looks like:

import enUSMessages from './messages/en_US.json'
import zhCNMessages from './messages/zh_CN.json'

export const enUS = enUSMessages
export const zhCN = zhCNMessages

en_US.json and zh_CN.json are simply JSON files that contain a localized message. For example, the following is a snippet of en_US.json:

{
  "logo": {
    "tagLine": "Open source task management tool"
  },
  ...
  "error": {
    "request": {
      ... 
      "notAuthorized": "Request not authorized.",
      ...
    }
  }
}

Please note that we do not have to use JSON for localized messages. We can just use a JavaScript...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}