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

gpt-json-translator

v1.2.2

Published

A tool for translating JSON files using GPT.

Downloads

8

Readme

JSON Translator using ChatGPT

Overview

JSON Translator is an innovative tool designed to utilize ChatGPT for translating extensive JSON text files efficiently. This project is ideal for developers and content creators who require quick and accurate localization of their JSON-based data into multiple languages.

en.json

{
    "website": {
      "name": "Mock Language Explorer",
      "url": "www.mocklanguageexplorer.com",
      "pages": [
        {
          "pageTitle": "About Us",
          "content": "Language Explorer is dedicated to making language learning accessible to everyone. Our team, composed of language experts and technology enthusiasts, believes in the power of communication and understanding. With over a decade of experience, we provide resources, tools, and courses to help individuals and organizations break language barriers."
        },
        {
          "pageTitle": "Our Services",
          "subPages": [
            {
              "subPageTitle": "Translation Tools",
              "description": "Explore our state-of-the-art translation tools designed to provide accurate and swift translations across multiple languages. From document translations to real-time conversational assistance, our tools utilize advanced algorithms and machine learning to ensure quality and efficiency."
            },
            {
              "subPageTitle": "Language Courses",
              "description": "Our language courses range from beginner to advanced levels, offering comprehensive learning modules in over 30 languages. Each course is tailored to promote immersive learning experiences, facilitated by native speakers and enriched with cultural insights."
            }
          ]
        }
      ]
    }
  }

zh.json

{
  "website": {
    "name": "模拟语言探索者",
    "url": "www.mocklanguageexplorer.com",
    "pages": [
      {
        "pageTitle": "关于我们",
        "content": "语言探索者致力于使语言学习对每个人都更加可及。我们的团队由语言专家和技术爱好者组成,坚信沟通和理解的力量。凭借超过十年的经验,我们提供资源、工具和课程,帮助个人和组织打破语言障碍。"
      },
      {
        "pageTitle": "我们的服务",
        "subPages": [
          {
            "subPageTitle": "翻译工具",
            "description": "探索我们的最先进的翻译工具,旨在提供跨多种语言的准确和快速翻译。从文件翻译到实时对话协助,我们的工具利用先进的算法和机器学习,确保质量和效率。"
          },
          {
            "subPageTitle": "语言课程",
            "description": "我们的语言课程涵盖初学者到高级水平,在30多种语言中提供全面的学习模块。每门课程都旨在促进沉浸式学习体验,由母语人士主持,并丰富文化见解。"
          }
        ]
      }
    ]
  }
}

Installation

To start using gpt-json-translator, you need to install the package from npm. You can do this using either npm or yarn. Here are the steps for each method:

Using npm

Visit NPM page Run the following command to install the package:

npm install gpt-json-translator

Using Yarn

If you prefer using Yarn, run this command instead:

yarn add gpt-json-translator

Features

  • High-Speed Translation: Capable of translating substantial JSON files into various languages concurrently, typically within one minute.
  • Overcome Token Limitations: Effectively handles translations that exceed the maximum token limit, ensuring comprehensive content translation without tokenization issues.
  • Automated Segmentation and Reassembly: Automatically divides large JSON files for translation and seamlessly reassembles them after the process, ensuring integrity and consistency.
  • Reliable Translation Verification: Includes an automatic verification step after translation. If any discrepancies are found, it retriggers the translation to guarantee accuracy.
  • User-Friendly Commands:
    • To translate all supported languages: npx translateAll
    • To translate into a specific language (e.g., French): npx translateLocale fr

Usage

After installation, you can import and use gpt-json-translator in your JavaScript project. Here's a simple example to get you started:

Command Line

To translate all supported languages:

npx translateAll

To translate into a specific language (e.g., French):

npx translateLocale fr

To use inside project

import { translateOne, translateAll } from 'gpt-json-translator/index.js';

//translating a single locale
translateOne('fr');

//translating all supported locales
translateAll();

Dry Run Mode

For those cautious about overwriting existing files, the tool offers a dryRun mode. This mode enables users to preview the translation results without altering the original files.

  • To execute in dryRun mode for all languages: npx translateAll --dryRun
  • To execute in dryRun mode for a specific language: npx translateLocale zh --dryRun

Configuration

Set up a config.yaml file in your project's root directory with the necessary parameters for the translation process.

Example config.yaml:

sourceLocale: 'en'
supportedLocales: ['en', 'fr', 'zh']
filePath: 'locales'
# dryRun: true

openai: 
  api_key: ${OPENAI_API_KEY}    # put your openai api key here or in your .env file
  model: 'gpt-3.5-turbo-1106'   # you can put the modal you wants to run
  max_tokens: 1000              # max prompt_tokens for source locale language. 
  max_retry: 3

# max_tokens: total_tokens = prompt_tokens + completion_tokens. when you send 1000 token en to translate to fr. it could return 2000 token as fr. so the total_tokens will be 3000.

For more information about ChatGPT models, you can Visit OpenAI Models

Contribution

We welcome contributions to enhance JSON Translator. Feel free to fork the repository and submit pull requests.

License

This project is released under the MIT License.


Leverage the capabilities of ChatGPT with JSON Translator to streamline and refine your JSON localization processes.