# Python GPT-4 PO File Translator
This Python script provides a convenient tool for translating `.po` files using OpenAI's GPT-4 model. It is designed to handle both bulk and individual translation modes, making it suitable for a wide range of project sizes and `.po` file structures.
## Features
- **Bulk Translation Mode**: Enhances efficiency by facilitating the translation of multiple text entries simultaneously.
- **Individual Translation Mode**: Offers the flexibility to translate entries one at a time for greater precision.
- **Configurable Batch Size**: Allows users to set the number of entries to be translated in each batch during bulk translation.
- **Comprehensive Logging**: Logs detailed information for progress monitoring and debugging purposes.
- **Fuzzy Entry Exclusion**: Enables the option to omit 'fuzzy' entries from translation in `.po` files.
- **Flexible API Key Configuration**: Supports providing the OpenAI API key either through command-line arguments or a `.env` file.
## Requirements
- Python 3.x
- `polib` library
- `openai` Python package
![gpt-po](https://github.com/pescheckit/python-gpt-po/assets/78353155/d76ebc10-b24d-47b3-acef-7c02805faee3)
## API Key Configuration
The `gpt-po-translator` supports two methods for providing OpenAI API credentials:
1. **Environment Variable**: Set your OpenAI API key as an environment variable named `OPENAI_API_KEY`. This method is recommended for security and ease of API key management.
```bash
export OPENAI_API_KEY='your_api_key_here'
```
2. **Command-Line Argument**: Pass the API key as a command-line argument using the `--api_key` option.
```bash
gpt-po-translator --folder ./locales --lang de,fr --api_key 'your_api_key_here' --bulk --bulksize 100 --folder-language
```
Ensure your API key is kept secure and not exposed in shared or public spaces.
## Installation
### Via PyPI
Install the `gpt-po-translator` package directly from PyPI:
```bash
pip install gpt-po-translator
```
### Manual Installation
For manual installation or to work with the latest code from the repository:
1. Clone the repository:
```bash
git clone [repository URL]
```
2. Navigate to the cloned directory and install the package:
```bash
pip install .
```
## Usage
Use `gpt-po-translator` as a command-line tool:
```
gpt-po-translator --folder [path_to_po_files] --lang [language_codes] [--api_key [your_openai_api_key]] [--fuzzy] [--bulk] [--bulksize [batch_size]] [--folder-language]
```
### Example
```
gpt-po-translator --folder ./locales --lang de,fr --api_key 'your_api_key_here' --bulk --bulksize 100 --folder-language
```
This command translates `.po` files in the `./locales` folder to German and French, using the provided OpenAI API key, and processes 100 translations per batch in bulk mode.
## Logging
The script logs detailed information about the files being processed, the number of translations, and batch details in bulk mode.
## License
[MIT](LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/pescheckit/python-gpt-po",
"name": "gpt-po-translator",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Bram Mittendorff",
"author_email": "bram@pescheck.io",
"download_url": "https://files.pythonhosted.org/packages/ea/3f/96e0a009d483bf3aba822a2fc0cd499d9cbb8e3e95c54855253defd3e6af/gpt-po-translator-0.1.10.tar.gz",
"platform": null,
"description": "# Python GPT-4 PO File Translator\n\nThis Python script provides a convenient tool for translating `.po` files using OpenAI's GPT-4 model. It is designed to handle both bulk and individual translation modes, making it suitable for a wide range of project sizes and `.po` file structures.\n\n## Features\n\n- **Bulk Translation Mode**: Enhances efficiency by facilitating the translation of multiple text entries simultaneously.\n- **Individual Translation Mode**: Offers the flexibility to translate entries one at a time for greater precision.\n- **Configurable Batch Size**: Allows users to set the number of entries to be translated in each batch during bulk translation.\n- **Comprehensive Logging**: Logs detailed information for progress monitoring and debugging purposes.\n- **Fuzzy Entry Exclusion**: Enables the option to omit 'fuzzy' entries from translation in `.po` files.\n- **Flexible API Key Configuration**: Supports providing the OpenAI API key either through command-line arguments or a `.env` file.\n\n## Requirements\n\n- Python 3.x\n- `polib` library\n- `openai` Python package\n\n![gpt-po](https://github.com/pescheckit/python-gpt-po/assets/78353155/d76ebc10-b24d-47b3-acef-7c02805faee3)\n\n## API Key Configuration\n\nThe `gpt-po-translator` supports two methods for providing OpenAI API credentials:\n\n1. **Environment Variable**: Set your OpenAI API key as an environment variable named `OPENAI_API_KEY`. This method is recommended for security and ease of API key management.\n\n ```bash\n export OPENAI_API_KEY='your_api_key_here'\n ```\n\n2. **Command-Line Argument**: Pass the API key as a command-line argument using the `--api_key` option.\n\n ```bash\n gpt-po-translator --folder ./locales --lang de,fr --api_key 'your_api_key_here' --bulk --bulksize 100 --folder-language\n ```\n\nEnsure your API key is kept secure and not exposed in shared or public spaces.\n\n## Installation\n\n### Via PyPI\n\nInstall the `gpt-po-translator` package directly from PyPI:\n\n```bash\npip install gpt-po-translator\n```\n\n### Manual Installation\n\nFor manual installation or to work with the latest code from the repository:\n\n1. Clone the repository:\n ```bash\n git clone [repository URL]\n ```\n2. Navigate to the cloned directory and install the package:\n ```bash\n pip install .\n ```\n\n## Usage\n\nUse `gpt-po-translator` as a command-line tool:\n\n```\ngpt-po-translator --folder [path_to_po_files] --lang [language_codes] [--api_key [your_openai_api_key]] [--fuzzy] [--bulk] [--bulksize [batch_size]] [--folder-language]\n```\n\n### Example\n\n```\ngpt-po-translator --folder ./locales --lang de,fr --api_key 'your_api_key_here' --bulk --bulksize 100 --folder-language\n```\n\nThis command translates `.po` files in the `./locales` folder to German and French, using the provided OpenAI API key, and processes 100 translations per batch in bulk mode.\n\n## Logging\n\nThe script logs detailed information about the files being processed, the number of translations, and batch details in bulk mode.\n\n## License\n\n[MIT](LICENSE)\n",
"bugtrack_url": null,
"license": "LICENSE",
"summary": "A CLI tool for translating .po files using GPT models.",
"version": "0.1.10",
"project_urls": {
"Homepage": "https://github.com/pescheckit/python-gpt-po"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "38b15016b23701bfd0d7c6101cb5f4db1d49c27bceeadc61785097bd4e2c8b42",
"md5": "c6fd9e1a4d39d2225073e657010c6f17",
"sha256": "de21ddb4997dc11b153dbcbaa8356575cbc6675b9578676aeee0ace2216524fb"
},
"downloads": -1,
"filename": "gpt_po_translator-0.1.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c6fd9e1a4d39d2225073e657010c6f17",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8769,
"upload_time": "2023-12-29T13:07:51",
"upload_time_iso_8601": "2023-12-29T13:07:51.512119Z",
"url": "https://files.pythonhosted.org/packages/38/b1/5016b23701bfd0d7c6101cb5f4db1d49c27bceeadc61785097bd4e2c8b42/gpt_po_translator-0.1.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ea3f96e0a009d483bf3aba822a2fc0cd499d9cbb8e3e95c54855253defd3e6af",
"md5": "6a39188896e541831d93884a4473ca9f",
"sha256": "9ed70b11618ffeb44ef7ac26ae39a8e7c528381dc7f400a62e023458788c6a1d"
},
"downloads": -1,
"filename": "gpt-po-translator-0.1.10.tar.gz",
"has_sig": false,
"md5_digest": "6a39188896e541831d93884a4473ca9f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7600,
"upload_time": "2023-12-29T13:07:52",
"upload_time_iso_8601": "2023-12-29T13:07:52.956037Z",
"url": "https://files.pythonhosted.org/packages/ea/3f/96e0a009d483bf3aba822a2fc0cd499d9cbb8e3e95c54855253defd3e6af/gpt-po-translator-0.1.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-29 13:07:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pescheckit",
"github_project": "python-gpt-po",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "gpt-po-translator"
}