Table of Contents
Vision
Features
Live Demo
Principle
Help Document
License
Vision
Make international access easy and enjoyable 😄💪🏻
Features
- lightweight:

- simple:Simple configuration, quick activation
- flexible:Supports Variable Interpolation, and unique Type tags and Formatizer
- automatic-translation:Extract copy and generate language packages in one click
- incremental translation:Only translate new copy and remove unused copy
- Multi-platform support:Google x、OpenAI、Google、Microsoft、Tencent、Alibaba Cloud、Youdao、BaiduFor translation platforms
- Translation Log:Various log outputs are easy to track problems
- keyless:Copywriting is key, only Custom key is required for A word with multiple meanings
Live Demo
Principle
automatic-translation
is one of the core features of the current library, learn more
The library is mainly composed of two parts
- Command Line Tool
- Function API
Command Line Tool:Parse the text that needs to be translated based on specified rules (regular expressions), translate the text to the specified target language through a translation platform, and finally generate language pack files
An example of parsing text using Matching Rules is as follows:
The following is an example of Copywriting is key
// Normal string
t('Hello World')
t("Hello World")
t(`Hello World`)
// Variable Interpolation
t('Hi,{0}', 'developer friends')
t('This is {0}, welcome to {1}. If you think {2}, please give {3} your support', ' `i18n-pro` ', 'use', `it's helpful for you`, ' ⭐️ ')
// Type tags
t('i18n-pro users reached {n0}', 100000000) // Number
t('The selling price is {c0}', 14999) // Currency
t(`Today's date is {d0}`, new Date()) // Date
t('Current time: {t0}', new Date()) // Time
t('I have {p0 apple}, {p1 banana} and {p2 pear}', 5, 4, 3) // Plural
The following is an example of Custom key
// Normal string
t.t('custom-key', 'Hello World')
t.t('custom-key', "Hello World")
t.t('custom-key', `Hello World`)
// Variable Interpolation
t.t('custom-key', 'Hi,{0}', 'developer friends')
t.t('custom-key', 'This is {0}, welcome to {1}. If you think {2}, please give {3} your support', ' `i18n-pro` ', 'use', `it's helpful for you`, ' ⭐️ ')
// Type tags
t.t('custom-key', 'i18n-pro users reached {n0}', 100000000) // Number
t.t('custom-key', 'The selling price is {c0}', 14999) // Currency
t.t('custom-key', `Today's date is {d0}`, new Date()) // Date
t.t('custom-key', 'Current time: {t0}', new Date()) // Time
t.t('custom-key', 'I have {p0 apple}, {p1 banana} and {p2 pear}', 5, 4, 3) // Plural
Function API:Access to multilingual support through initI18n
, t
, setI18n
- initI18n:Initialize the configuration and return the API object
- t:The package
Case Study
is internationalized, and it is also a command line matching identifier.
- setI18n:Set language and language package
Command Line Tool
works with Function API
and easily integrate into any JavaScript
project
Help Document
License
MIT
© 2022-present Eyelly Wu