This project is a command-line tool for translating .po and .pot files using various translation services. It
supports multiple translators and can handle placeholders in the text.
- Supports multiple translators including Google, Microsoft, Deepl, and more.
- Handles placeholders in the text to ensure they are not altered during translation.
- Can process individual files or entire folders.
- Supports custom configuration through a JSON file.
- Option to output in Odoo format.
- Uses
tqdmfor progress reporting. - Supports multiprocessing for faster translation.
- Split
.pofiles into multiple parts. - Merge multiple
.pofiles into a single file. - Supports caching
-
Clone the repository:
git clone https://github.com/tickernelz/translator_po.gitcd translator_po -
Install the required dependencies:
pip install -r requirements.txt -
Install the package as a pip module:
pip install .
-f,--file_path: Path to the input.poor.potfile.-d,--folder_path: Path to the folder containing.poor.potfiles.-o,--output_folder: Path to the output folder.-c,--config_file: Path to the configuration file (default:config.json).-O,--odoo_output: Enable Odoo output format.-j,--jobs: Number of concurrent jobs/threads (default: number of CPU cores).-F,--force: Force processing even if output file already exists.-s,--split: Path to the input.pofile to split.-ns,--num_split: Number of parts to split the.pofile into.-os,--output_split: Path to the output folder for split files.-m,--merge: Path to the folder containing.pofiles to merge.-om,--output_merge: Path to the output merged.pofile.-nc,--no_cache: Disable caching of translations.
translator_po -f path/to/your/file.po -o path/to/output/foldertranslator_po -d path/to/your/folder -o path/to/output/foldertranslator_po -f path/to/your/file.po -o path/to/output/folder -c path/to/config.jsontranslator_po -f path/to/your/file.po -o path/to/output/folder -Otranslator_po -s path/to/your/file.po -ns 5 -os path/to/output/foldertranslator_po -m path/to/your/folder -om path/to/output/merged_file.poThe configuration file is a JSON file that specifies the translator settings. If the configuration file does not exist,
a default configuration will be created in the home directory under .translator_po.
{
"translator": "GoogleTranslator",
"source_lang": "id",
"target_lang": "en",
"max_msgid_length": 300,
"DeeplTranslator": {
"api_key": "",
"use_free_api": true
},
"QcriTranslator": {
"api_key": ""
},
"YandexTranslator": {
"api_key": ""
},
"MicrosoftTranslator": {
"api_key": "",
"region": ""
},
"LibreTranslator": {
"api_key": "",
"use_free_api": true,
"custom_url": ""
},
"PapagoTranslator": {
"client_id": "",
"secret_key": ""
},
"ChatGptTranslator": {
"api_key": "",
"model": "gpt-3.5-turbo"
},
"BaiduTranslator": {
"appid": "",
"appkey": ""
}
}The program uses logging to provide information about its progress and any errors that occur. Logs include timestamps and log levels for better readability.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Create a new Pull Request.
This project is licensed under the MIT License. See the LICENSE file for more details.
For any questions or suggestions, please open an issue or contact the maintainer.