Make internationalization easy and enjoyable 😄💪🏻
- lightweight:
- simple:Simple configuration, quick activation
- flexible:Supports Variable Interpolation, and unique Type Tag and Formatter
- automatic-translation:Extract text and generate language pack in one click
- incremental translation:Only translate new text and remove unused text
- multi-platform support:For example, translation platforms such as Google x、OpenAI、Google、Microsoft、Tencent、Alibaba Cloud、Youdao、Baidu
- translation log:Various log outputs make it easy to track issues
- keyless:text-as-key, custom-key is required in specific scenarios (e.g., polysemy)
automatic-translation
is one of the core features of this library, learn more
The library consists of two main parts
- Command Line Tool
- Function API
Command Line Tool:Parse texts requiring translation based on specified rules (regular expressions), translate them using supported platforms, and finally generate language pack files
An example of parsing text using Match Rules is as follows:
The following is an example of text-as-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 your {3} support', ' `i18n-pro` ', 'use', `it's helpful for you`, ' ⭐️ ')
// Type Tag
t('i18n-pro has reached {n0} users', 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 your {3} support', ' `i18n-pro` ', 'use', `it's helpful for you`, ' ⭐️ ')
// Type Tag
t.t('custom-key', 'i18n-pro has reached {n0} users', 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:Provide multilingual support via initI18n
, t
, setI18n
- initI18n:Initialize the configuration and return the API object
- t:Wrap
text
to implement internationalization, also serves as command line matching identifier - setI18n:Set the language and language pack
Command Line Tool
works with Function API
and easily integrate into any JavaScript
project
- 🚀 Quick Start
- 💻 Command Line
- 📖 API
- 📝 Match Rules
- 📊 Translation Log
- ❓ Questions and Answers
- 🤝 Contribution Guidelines
- 📋 Changelog
© 2022-present Eyelly Wu