LLM-Translator is a simple CLI tool to translate any .txt and .md files of any length in the supported languages by leveraging ChatGPT's API.
Texts and documents are translated into the Modern Standard version of the following languages:
| Language | Code | Speculative Translation Accuracy |
|---|---|---|
| English | en | 1.00 |
| German | de | 0.90 - 0.95 |
| Spanish | es | 0.90 - 0.95 |
| Italian | it | 0.85 - 0.90 |
| Portuguese | pt | 0.85 - 0.90 |
| French | fr | 0.90 - 0.95 |
| Swedish | sv | 0.80 - 0.85 |
| Arabic | ar | 0.70 - 0.80 |
| Japanese | ja | 0.70 - 0.80 |
| Swahili | sw | 0.75 - 0.80 |
| Afrikaans | af | 0.75 - 0.80 |
| Danish | da | 0.80 - 0.85 |
| Greek | el | 0.75 - 0.80 |
| Georgian | ka | 0.65 - 0.75 |
| Thai | th | 0.65 - 0.75 |
| Turkish | tr | 0.70 - 0.80 |
You can manually add new languages by modifying language_info in languages.py.
You can also change the prompt template by modifying supported_languages/prompt_template.txt.
Once modified, the program will automatically update the prompt of every supported languages.
Or you can modify the prompt to a specific language by edditing the associated .json file of the language in the /supported_languages folder.
Before utilizing this tool, ensure that you have an OpenAI account and an OpenAI API key and to follow the installation procedure.
LLM-Translator has been successfully tested on Ubuntu 20.04.
-
Open a Terminal
-
Check that Python 3 and git are installed
python3 --version- most of the time they are installed by default, if not install them with:
sudo apt install python3 python3-pip python3-env git
-
Clone the Repository
git clone https://github.com/Asi0Flammeus/LLM-Translator.git
-
Navigate to the Project Directory:
cd LLM-Translator/
-
Set Up OpenAI API Key:
- Create a
.envfile. nano .env- press
Ctrl+Xand thenyandEnterto quit nano and save file. - Add the following line, replacing
"YOUR_API_KEY"with your actual OpenAI API key (go here for futher details). OPENAI_API_KEY="YOUR_API_KEY"
- Create a
-
Create a Python Virtual Environment:
python3 -m venv env
-
Activate the Virtual Environment:
source env/bin/activate
-
Install Required Libraries:
pip3 install -r requirements.txt
LLM-Translator has been successfully tested on Windows 11.
By default, Python 3 and git are not already installed on Windows so I will also explain how to install them. If you already have those installed you can directly jump to step 4.
- Download Python on official website
- Execute the installer wizard,
python-3.11.5-amd64.exefor example.⚠️ Beware to tick theAdd python.exe to PATHoption on the first installation page before cliking theInstall Nowbutton.- Follow the installation procedure and choose default settings.
- Download GitBash on official website
- Execute the wizard installer,
git-2.42.0.2-64-bit.exefor example. - Follow the installation procedure and choose default settings.
-
Open Git Bash
-
Clone the Repository
git clone https://github.com/Asi0Flammeus/LLM-Translator.git
-
Navigate to the Project Directory:
cd LLM-Translator/
-
Set Up OpenAI API Key:
- Create a
.envfile. nano .env- Add the following line, replacing
"YOUR_API_KEY"with your actual OpenAI API key (go here for futher details). OPENAI_API_KEY="YOUR_API_KEY"- Press
Ctrl+Xand thenyandEnterto quit nano and save file.
- Create a
-
Create a Python Virtual Environment:
python -m venv env
-
Activate the Virtual Environment:
source env/Scripts/activate
-
Install Required Libraries:
pip install -r requirements.txt
-
Make Script Executable:
chmod +x ./run-LLM-Translator.shfor Linux userchmod +x ./run-LLM-Translator-on-windows.shfor Windows user
Please follow these steps each time you want to run LLM-Translator:
- Open a terminal (or Gitbash for windows users)
- Go to LLM-Translator directory
cd LLM-Translator
-
activate the Python Environment
source env/bin/activate- or
source env/Scripts/activatefor windows users
-
Prepare Input Files:
- Before running the program, you have to create subfolders inside the
/inputs/directory and populate them with.txtand.mdfiles that you wish to translate. - All the files in a subfolder should be written in the same language.
- Before running the program, you have to create subfolders inside the
-
Execute the Program:
.run-LLM-Translator.shfor linux usersrun-LLM-Translator-on-windows.shfor windows users
-
Follow the On-screen Instructions
Note: Translations will be automatically stored in an associated subfolder into the /outputs/ folder.
Note 2: A better installation process will be done soon™ with executable files for windows and linux.
- Language Selection
- Improved Output Organization
- Comprehensive Testing and Continuous Integration
- Integration with ChatGPT-4 Model
- Development of a User-Friendly GUI
- Integration with Additional LLM Models
Contributions are welcome. To contribute, please fork the repository and create a pull request with your changes. Ensure that changes are tested and existing functionality is maintained.
Here we promote Value for Value model so if you find value in this humble script tips are welcomed via LN or by scanning directly this QR code with a Lightning wallet 👇.
This project is governed by the MIT License. For more information, refer to the LICENSE file.
