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

@xieyezi/genji-i18n

v0.0.8

Published

translate Markdown into specified multiple languages automatically by openai.

Downloads

10

Readme

genji i18n 是一款使用 基于 openAI 的自动翻译 markdown 文档的工具。

English ・ 简体中文 ・ にほんご ·

特性

  • [x] 利用 openAI 自动翻译 markdown 文档
  • [x] 支持大型文件自动分割,不必担心 openAI token 限制
  • [x] 支持自定义 OpenAI 模型、API 代理、temperature

安装

要安装 genji i18n,请运行以下命令:

pnpm add @xieyezi/genji-i18n -D

建议安装到全局环境中:

npm install -g @xieyezi/genji-i18n

请确保环境中 Node.js 版本 >= 18

使用

genji-i18n translate -c path/to/genji.config.ts

配置

在你文档的根目录下面,创建一个 genji.config.tsgenji-i18n 提供了 defineConfig 函数。 下面是一个例子:

// genji.config.ts
import { defineConfig, LanguageModel } from "@xieyezi/genji-i18n";

export default defineConfig({
  model: LanguageModel.GPT3_5,
  entryLocale: "zh-CN",
  entrySuffix: ".zh-CN.md",
  outputLocales: ["en-US", "ja-JP"],
  entry: ["./index.zh-CN.md"],
  outputCustom: (locale, { getDefaultSuffix }) => {
    if (locale === "en-US") return ".md";
    return getDefaultSuffix(locale);
  }
});

genji.confit.ts 完整类型

export interface GenjiI18nConfig {
  /**
   * @description 要使用的 ChatGPT 模型
   */
  model?: LanguageModel;
  /**
   * @description 并发的待处理的任务数量
   */
  concurrency?: number;
  /**
   * @description 提供一些上下文以获得更准确的翻译
   */
  reference?: string;
  /**
   * @description 按标记拆分
   */
  splitToken?: number;
  /**
   * @description 要使用的采样温度
   */
  temperature?: number;
  /**
   * @description 入口文件或文件夹,支持 glob模式
   */
  entry: string[];
  /**
   * @description 将用作翻译参考的语言
   */
  entryLocale: string;
  /**
   * @description 将用作翻译参考的语言 Markdown 后缀
   */
  entrySuffix?: string;
  /**
   * @description 将被忽略的 markdown,支持 glob
   */
  exclude?: string[];
  /**
   * @description 需要进行翻译的所有语言
   */
  outputLocales: string[];
  /**
   * @description 是否使用 json 模式
   */
  experimental?: {
    jsonMode?: boolean;
  };
  /**
   * @description 自定义生成函数
   */
  outputCustom?: (
    locale: string,
    config: {
      fileContent: string;
      filePath: string;
      getDefaultSuffix: (locale: string) => string;
    }
  ) => string;
}

例子

可参考 Examples 文件夹查看详细使用示例。