When using video.js in a vue project, Chinese culture is required, but the solution online is not easy to find, so I will record it here.
Wrong steps:
- According to the online tutorial, find the Chinese package in node_modules/video.js/dist/lang/zh-CN.js
import 'video.js/dist/lang/zh-CN.js
- Configure it to Chinese in settings:
language:“zh-CN”
- Error: videojs is not defined
Solution:
1. Find this /zh-CN.js and add a sentence in it: import videojs from "video.js"
Disadvantages: This project involves multiple people cooperating. If others do not modify the plug-in synchronously, errors will still be reported, which is not conducive to project maintenance, so this solution is abandoned.
2. Just use zh-CN.json, it is effective through personal testing
import videojs from "video.js"
import "video.js/dist/video-js.css"
import video_zhCN from 'video.js/dist/lang/zh-CN.json'
videojs.addLanguage('zh-CN', video_zhCN)
- Configure it to Chinese in settings:
language:“zh-CN”