Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pandodao/i18n-cli
A CLI tool that utilizes the OpenAI API to translate JSON-based locale files
https://github.com/pandodao/i18n-cli
i18n openai
Last synced: 2 days ago
JSON representation
A CLI tool that utilizes the OpenAI API to translate JSON-based locale files
- Host: GitHub
- URL: https://github.com/pandodao/i18n-cli
- Owner: pandodao
- License: agpl-3.0
- Created: 2023-03-04T03:05:30.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-10T22:41:11.000Z (8 months ago)
- Last Synced: 2025-01-16T21:11:19.998Z (9 days ago)
- Topics: i18n, openai
- Language: Go
- Homepage: https://pando.im
- Size: 50.8 KB
- Stars: 201
- Watchers: 5
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-chatgpt-api - i18n-cli
README
# i18n-cli
A command-line interface (CLI) tool that utilizes the OpenAI API to translate locale files based on JSON format.
![](./screenshot.webp)
## Install
```bash
go install github.com/pandodao/i18n-cli@latest
```## Usage
```bash
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.