Giter Site home page Giter Site logo

pandodao / i18n-cli Goto Github PK

View Code? Open in Web Editor NEW
198.0 5.0 9.0 52 KB

A CLI tool that utilizes the OpenAI API to translate JSON-based locale files

Home Page: https://pando.im

License: GNU Affero General Public License v3.0

Go 100.00%
i18n openai

i18n-cli's Introduction

i18n-cli

A command-line interface (CLI) tool that utilizes the OpenAI API to translate locale files based on JSON format.

Install

go install github.com/pandodao/i18n-cli@latest

Usage

export OPENAI_API_KEY=YOUR_API_KEY
i18n-cli translate \
  --dir ./locales \
  --source ./locales/en-US.json \
  --independent ./independent.json

in which,

  • --dir: This flag specifies the directory where the locale files are located. The value ./locales specifies that the locales directory is located in the current working directory.
  • --source: This flag specifies the source locale file to be used as a reference for translation.
  • --independent: This flag specifies the independent locale file to be used as a reference for translation.

i18n-cli reads the directory containing locale files, retrieves translations from OpenAI, and then writes the translated content back to the same files.

To have i18n-cli translate the content of a JSON locale file, any existing values will be ignored.

If you want i18n-cli to translate a specific value, you can add a "!" at the beginning of the string. Alternatively, you can delete the key/value pair from the JSON file to have i18n-cli generate a new translation.

i18n-cli's People

Contributors

lyricat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

i18n-cli's Issues

won't install ...

go install -x github.com/pandodao/i18n-cli@latest
# get https://proxy.golang.org/github.com/@v/list
# get https://proxy.golang.org/github.com/pandodao/i18n-cli/@v/list
# get https://proxy.golang.org/github.com/pandodao/@v/list
# get https://proxy.golang.org/github.com/pandodao/@v/list: 404 Not Found (0.110s)
# get https://proxy.golang.org/github.com/@v/list: 404 Not Found (0.136s)
# get https://proxy.golang.org/github.com/pandodao/i18n-cli/@v/list: 200 OK (0.138s)
WORK=/var/folders/cm/cmj5bhyd3652kbz69v3k4xc80000gn/T/go-build3962320052

go version go version go1.20.3 darwin/arm64

What is --independent?

I am running under Windows.

Your screenshot shows MacOS running it from the command-line without the --independent parameter, but the usage documentatation states:

export OPENAI_API_KEY=YOUR_API_KEY
i18n-cli translate \
  --dir ./locales \
  --source ./locales/en-US.json \
  --independent ./independent.json

Since I am under Windows, I am using SET OPENAI_API_KEY= instead.

After this, I attempt to run:

i18n-cli translate --dir ./i18n --source ./i18n/en.json

This results in two errors:

failed to get language: independent.json
failed to get language: test.json

First, what is independent.json? The documents don't say much about what this is or what it is supposed to contain. Right now I have three files in my i18n folder ... en.json, which has all the translations, and two empty ones, fr.json and es.json, that I would like populated. Is that correct?

What is independent.json? And for that matter, what is test.json?

If I create an empty independent.json file to test, and then run:

i18n-cli translate --dir ./i18n --source ./i18n/en.json --independent ./i18n/independent.json

I get the same error as above.

My en.json is structured as such ... is this not what this program is meant to deal with?

{
  "LOGIN": {
    "FORGOT_USERNAME": "Forgot your username?",
    "FORGOT_PASSWORD": "Forgot your password?",
  },
  "CUSTOMERSEARCH": {
    "CONTACT_EMAIL": "Contact Email",
    "BILLING_EMAIL": "Billing Email",
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.