Home

Awesome

<div align="center">

logo

English | 简体中文

<p style="font-size: 18px;">Lightweight, simple, flexible, automatic translation internationalization tool for JavaScript</p>

npm-version npm-download

github-stars last-commit github-issues codecov

demo

</div> <details > <summary>Table of Contents</summary>

Vision<br/> Features<br/> Live Demo<br/> Principle<br/> Help Document<br/> License<br/>

</details>

Vision

To make internationalization easy and enjoyable 😄💪🏻

Features

Live Demo

Principle

Taking Translation Text as key is the key to all the functions of the library. If you have any questions about this, Please see

The library is mainly composed of two parts

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:

/** Normal string */

t('hello world')
t("hello world")
t(`hello world`)


/** Support Variable Interpolation */

t('hello {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`, ' ⭐️ ')


/** Interpolation Variable type tag need to be used with corresponding formatting callbacks */

// Number Type
t('The number of users has reached {n0}', 100000000)

// Currency Type
t('The selling price is {c0}', 14999)

// Date Type
t(`Today's date is {d0}`, new Date())

// Time Type
t('Current time: {t0}', new Date())

// Plural Type
t('I have {p0 apple}, {p1 banana} and {p2 pear}', 5, 4, 3) 

Function API:Connect the international language package into the project, consisting of initI18n , t , setI18n and withI18n

Therefore, Command Line Tool and Function API work better together. It is precisely because of this structural design that i18n-pro library can be easily integrated into any JavaScript project

Help Document

License

MIT

Copyright (c) 2022-present Eyelly Wu