gpt-i18n-translator
v1.0.1
Published
A script to check and update missing translations via GPT
Readme
gpt-i18n-translator
gpt-i18n-translator is a Node.js script that compares two language files and adds missing translations. It uses the OpenAI API to generate the missing translations.
Installation
Install Globally
To install the script globally, use the following command:
npm install -g gpt-i18n-translatorSetup
Create the
.envFile:Create a
.envfile in the current directory by copying the provided.env.examplefile:cp $(npm root -g)/gpt-i18n-translator/.env.example .envEdit the
.envFile:Open the
.envfile in a text editor and add your OpenAI API key and model information:OPENAI_API_KEY=your_actual_openai_api_key OPENAI_MODEL=your_actual_openai_model (e.g. gpt-4o)
Usage
Run the script with the following parameters: target language, path to the original language file, and path to the foreign language file to be updated.
gpt-i18n-translator <target_language> <original_file_path> <foreign_file_path>Example
Suppose you want to add missing translations from German to English:
gpt-i18n-translator en ./path/to/de/translation.json ./path/to/en/translation.jsonParameter Explanation
<target_language>: The target language for translation (e.g.,enfor English).<original_file_path>: Path to the original language file (e.g.,./path/to/de/translation.json).<foreign_file_path>: Path to the foreign language file to be updated (e.g.,./path/to/en/translation.json).
Development
Local Installation
If you want to develop or customize the script locally, you can install it in your project directory:
yarn installDEV-Mode
Use
yarn devTo test local installation.
License
This project is licensed under the MIT License.
Author
- Bernard Teske www.bernardteske.de
