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

trans-sync-tool

v1.0.8

Published

Connect to yicat service and receive the latest translated segment in real-time.

Downloads

3

Readme

Description

Trans-Sync-Tool is a js plugin to help your translator to check translation text in your site real time.

You can add the code below to your project and the plugin will fetch or receive the newset segment from remote yicat server with a websocket channel, so they can translate and view text in same time.

Install

npm i trans-sync-tool -S

Usage

Init connection with a yicat config

import TransSyncTool from 'trans-sync-tool'
const yicatConfig = { email: '**@*.com', apiKey: '***', projectId: '***' }
const transSyncTool = new TransSyncTool(yicatConfig.email, yicatConfig.apiKey, yicatConfig.projectId, newMsgHandler)

Fetch all segments when page loaded.

// add the code to the component where we can switch the language locale
// run once when page load to get the latest messages
// for my project, zh-CN is not exist in remote server, because my project source language is chinese
if (userLanguage !== 'zh-CN') { // such as 'en-US'
  // fetch all one time
  transSyncTool.fetchAll(userLanguage).then(msgMap => {
    if (msgMap) {
      // set the whole messages to i18n or cave to your locale json properies.
      i18n.setLocaleMessage(userLanguage, msgMap)
    }
  })
}

You can use i18n solution in your project and connect to yicat to fetch segments in where you manage your locale with i18n.


const transSyncTool = new TransSyncTool(yicatConfig.email, yicatConfig.apiKey, yicatConfig.projectId, (msg) => {
  // handler to resolve new translated segment
  // update the message for each segment
  i18n._vm.messages[msg.tgtLan][msg.msgKey] = msg.tgtText // so we can view the text real-time
})

// attach it the i18n instance and use it anywhere
i18n.transSyncTool = transSyncTool

// add the code to the component where we can switch the language locale
// run once when page load to get the latest messages
// for my project, zh-CN is not exist in remote server, because my project source language is chinese
if (userLanguage !== 'zh-CN') { // such as 'en-US'
  // fetch all one time
  transSyncTool.fetchAll(userLanguage).then(msgMap => {
    if (msgMap) {
      // set the whole messages to i18n
      i18n.setLocaleMessage(userLanguage, msgMap)
    }
  })
}

Trans-Sync-Tool works fine with another vue code tool i18n-yipicker(auto extract chinese text to a json file and send it to yicat-server) to get your localization work easier. I18n-Yipicker is not published to public, Contact YiCAT Team to get more if you need.

Let me know if you have any problem.

Visit YiCAT Page:

Tmxmall-YiCAT: https://www.yicat.vip

develop(nodejs16)

npm run dev

切换到master分支后编译和发布

publish

npm run build

npm publish --registry=https://registry.npmjs.org