With the popularity of the Internet and the trend of globalization, more and more companies and individuals are turning their attention to overseas markets.
In this context, website internationalization has become an essential link.
Today, we are going to introduce a translation tool library based on JavaScript - translate.js
, and how it helps us achieve website internationalization.
What is translate.js?
translate.js is a free, open-source translation tool library
that supports mutual translation between multiple languages, such as Chinese, English, French, Japanese, Korean, German, etc.
It avoids the limitations and cost issues of API call times, and is easy to use, convenient, and fast.
By using translate.js, we can easily achieve website internationalization, allowing users from different countries and regions to conveniently use our website.
Unique Advantages
- Extremely easy to use
- Does not increase workload
- Dynamically configurable
- Free to use permanently
- No need for API. Translate directly using JavaScript, avoiding limitations and costs associated with API calls;
- Supports translation between multiple languages.
Online Experience
Four, try the water with someone else's website first
- Open a webpage at random
- F12 (Inspect Element)
- Paste the following code into the console tab:
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= 'https://res.zvo.cn/translate/inspector_v2.js';
head.appendChild(script);
5.Enter 回车键 , 执行
- In the upper left corner of the current webpage, there is a big language switch, give it a try.
How to Use Quickly
At the end of the webpage, before, add the following code, generally at the bottom of the page, the select language switch tag appears. It's that simple:
<script src="https://res.zvo.cn/translate/translate.js"></script>
<script>
translate.setUseVersion2(); //设置使用v2.x 版本
translate.language.setLocal('chinese_simplified'); //设置本地语种(当前网页的语种)。如果不设置,默认自动识别当前网页显示文字的语种。
translate.execute();//进行翻译
</script>
More usage methods can be found in the project repository:
Chapter 6 Summary
translate.js project quickly implements website internationalization.
By simple and easy-to-understand tutorials, let your website quickly embrace global users.
If you are still struggling with the huge workload of dynamically configuring translation files for i18n, why not try translate.js? It can save you 99.99% of translation time. Come and experience it now!
- 0
- 10
觉得还不错? 一键收藏 ![](https://csdnimg.cn/release/blogv2/dist/pc/img/collectionCloseWhite.png)