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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sola-grj/translator-widget

v0.1.7

Published

Framework-agnostic floating page translator widget for browser-based frontends.

Readme

ECI Translator Widget

一个可复用、框架无关的浏览器右侧悬浮翻译器插件,适合接入 Vue、React 或普通 HTML 前端项目。

已实现能力

  • 默认悬浮在浏览器右侧,可在右半区域自由拖动
  • 鼠标悬浮时显示“翻译此页面”快捷入口
  • 点击后弹出翻译面板,支持选择目标语言、翻译服务、是否显示原文
  • 通过整页文本提取 + 批量 segments 调用远程翻译接口完成页面翻译
  • API 地址和 API Key 支持从外部 JSON 读取,语言和服务默认值内置在源码中
  • 通过 Shadow DOM 隔离大部分宿主样式影响

安装

npm install

本地开发

npm run dev

打开 http://localhost:4173 查看示例页面。

作为库构建

npm run build

产物会输出到 dist/

基本接入

import { createTranslatorWidget } from '@eci/translator-widget';

createTranslatorWidget({
  configUrl: '/eci-translator.config.json'
});

也可以直接传对象:

import { createTranslatorWidget } from '@eci/translator-widget';

createTranslatorWidget({
  config: {
    apiUrl: 'http://link3.test.ecilink.com/ai-gateway-service/translation/api',
    apiKey: 'your-api-key',
    batchSize: 20,
    sourceLanguage: 'zh-CN',
    defaultTargetLanguage: 'en-US',
    services: [
      {
        id: 'medical-default',
        label: 'ECI 翻译',
        mtSettings: [{ medValue: 98, type: 2 }]
      }
    ]
  }
});

推荐外部配置文件

{
  "apiUrl": "http://link3.test.ecilink.com/ai-gateway-service/translation/api",
  "apiKey": "your-api-key",
  "batchSize": 20
}

运行时 API

const widget = createTranslatorWidget({
  configUrl: '/eci-translator.config.json'
});

widget.openPanel();
await widget.translatePage();
widget.restorePage();
widget.destroy();

说明

  • 当前整页翻译基于 DOM 文本节点扫描,默认会跳过 scriptstyleinputtextareaprecode 等区域
  • batchSize 用于控制每次调用翻译 API 时请求体中 segments 数组的数量,取值范围为 11000
  • “显示原文”模式会在页面中插入译文 + 原文组合节点,便于对照阅读
  • 当前源码内置默认值:sourceLanguage: zh-CN、中英互译目标语言、ECI 翻译 服务和默认 mtSettings
  • 若后续要兼容更复杂的业务页面,建议继续扩展过滤规则、响应解析规则和宿主自定义钩子