npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

i18n-pro

v2.1.1

Published

Lightweight, simple, flexible, automatic translation internationalization tool for JavaScript(适用于 JavaScript 的轻量、简单、灵活、自动翻译的国际化工具)

Downloads

1,615

Readme

logo

English | 简体中文

npm-version npm-download

github-stars last-commit github-issues codecov

demo

Vision Features Live Demo Principle Help Document License

Vision

To make internationalization easy and enjoyable 😄💪🏻

Features

  • lightweightbundlesize
  • simple:Low learning cost and easy to use
  • flexible:Support Variable Interpolation , as well as unique type tag and formatting callbacks (numbers, currency, dates, times, plurals)
  • automatic-translation:One command can automatically extract text and translate it to generate language packs
    • Support incremental translation mode:Only translate new text and intelligently remove unused text
    • Support multi -translation platform:Google x、OpenAI、Google、Microsoft、Tencent、Alibaba Cloud、Youdao、Baidu(In addition to Google x, other platforms need to register an account by themselves)
    • Support multiple translation logs:The output of a variety of types of translation logs, which is convenient for tracking and positioning translation issues
  • keyless:No need to manually define key, Translation Text is key

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
  • 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:

/** 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

  • initI18n:Used to initialize the fixed configuration, and finally return the objects containing the following 3 APIs
  • t:It is used for wrapping Translation Text to achieve internationalization, and it is also used as a logo of the command line to match Translation Text rules
  • setI18n:Set language and language package
  • withI18n:It is applicable to the server. Each interface response needs to be internationalized

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