{"id":13826477,"url":"https://github.com/DavideGalilei/gpytranslate","last_synced_at":"2025-07-09T00:33:38.478Z","repository":{"id":45186939,"uuid":"290484584","full_name":"DavideGalilei/gpytranslate","owner":"DavideGalilei","description":"A Python3 library for translating text using Google Translate API.","archived":false,"fork":false,"pushed_at":"2023-02-04T21:53:56.000Z","size":128,"stargazers_count":45,"open_issues_count":1,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-14T20:43:02.189Z","etag":null,"topics":["google","googletrans","gpytranslate","python","python3","translate","translation","translator"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/gpytranslate","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DavideGalilei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-26T12:02:34.000Z","updated_at":"2024-07-16T19:06:28.000Z","dependencies_parsed_at":"2023-02-18T19:45:55.580Z","dependency_job_id":null,"html_url":"https://github.com/DavideGalilei/gpytranslate","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavideGalilei%2Fgpytranslate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavideGalilei%2Fgpytranslate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavideGalilei%2Fgpytranslate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavideGalilei%2Fgpytranslate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DavideGalilei","download_url":"https://codeload.github.com/DavideGalilei/gpytranslate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225476383,"owners_count":17480215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google","googletrans","gpytranslate","python","python3","translate","translation","translator"],"created_at":"2024-08-04T09:01:38.582Z","updated_at":"2025-07-09T00:33:38.466Z","avatar_url":"https://github.com/DavideGalilei.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# gpytranslate\n\n[![PyPI version](https://badge.fury.io/py/gpytranslate.svg)](https://badge.fury.io/py/gpytranslate)\n[![Python Versions](https://img.shields.io/pypi/pyversions/gpytranslate.svg)](https://pypi.org/project/gpytranslate/)\n[![License](https://img.shields.io/github/license/DavideGalilei/gpytranslate.svg)](https://github.com/DavideGalilei/gpytranslate/blob/master/LICENSE)\n\nA Python3 library for translating text using Google Translate API.\n## Features\n - **Both Synchronous and Asynchronous**\n - **Dot accessible values**\n - **Supports emoji**\n - **Type hinted**\n - **Free to use**\n - **Easy**\n\n----\n## Quick Start\n\n### Installation\n\nRequirements:\n- Python 3.9 or higher\n- httpx[socks] \u003e= 0.28.0\n- aiofiles \u003e= 24.1.0\n- typing-extensions \u003e= 4.12.2\n\nInstall using pip:\n```bash\npython3 -m pip install -U gpytranslate\n```\n\nOr install with poetry:\n```bash\npoetry add gpytranslate\n```\n----\n### Usage\n\n[Async Example:](/examples/async/example.py)\n```python\nfrom gpytranslate import Translator\nimport asyncio\n\n\nasync def main():\n    t = Translator()\n    translation = await t.translate(\"Ciao come stai? Io bene ahah.\", targetlang=\"en\")\n    language = await t.detect(translation.text)\n    print(f\"Translation: {translation.text}\\nDetected language: {language}\")\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n[Sync Example:](/examples/sync/example.py)\n```python\nfrom gpytranslate import SyncTranslator\n\nt = SyncTranslator()\ntranslation = t.translate(\"Ciao come stai? Io bene ahah.\", targetlang=\"en\")\nlanguage = t.detect(translation.text)\nprint(f\"Translation: {translation.text}\\nDetected language: {language}\")\n```\n❓ **Note:** you could also check [tests](/tests) folder for extra examples.\n\nOutput:\n```\nTranslation: Hello how are you? I'm fine, haha.\nDetected language: en\n```\n\n### Text to Speech\n[Async Example:](/examples/async/tts.py)\n```python\nimport asyncio, aiofiles\nfrom gpytranslate import Translator\n\nasync def main():\n    translator = Translator()\n    async with aiofiles.open(\"test.mp3\", \"wb\") as file:\n        await translator.tts(\"Hello world!\", file=file)\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n[Sync Example:](/examples/sync/tts.py)\n```python\nfrom gpytranslate import SyncTranslator\n\ntranslator = SyncTranslator()\n\nwith open(\"test.mp3\", \"wb\") as file:\n    translator.tts(\"Hello world!\", file=file)\n```\n\n----\n## Useful Resources\nhttps://danpetrov.xyz/programming/2021/12/30/telegram-google-translate.html\nhttps://vielhuber.de/en/blog/google-translation-api-hacking/\nhttps://github.com/OwlGramDev/OwlGram/blob/b9bb8a247758adbf7be7aaf3eb150f680bec1269/TMessagesProj/src/main/java/it/owlgram/android/translator/GoogleAppTranslator.java\n\n### Language Codes\n\nThe library uses ISO 639-1 two-letter language codes. Some common examples:\n\n- English: 'en'\n- Spanish: 'es' \n- French: 'fr'\n- German: 'de'\n- Italian: 'it'\n- Japanese: 'ja'\n- Chinese (Simplified): 'zh'\n\n### Error Handling\n\nThe library raises `TranslationError` when translation fails:\n\n```python\nfrom gpytranslate import Translator, TranslationError\n\ntranslator = Translator()\ntry:\n    result = await translator.translate(\"Hello\", targetlang=\"invalid\")\nexcept TranslationError as e:\n    print(f\"Translation failed: {e}\")\n```\n\n## Development\n\n### Contributing\n\nContributions are welcome! Here's how you can help:\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Make your changes\n4. Run the tests (`pytest`)\n5. Commit your changes (`git commit -m 'Add amazing feature'`)\n6. Push to the branch (`git push origin feature/amazing-feature`)\n7. Open a Pull Request\n\nPlease make sure to update tests as appropriate and follow the existing code style.\n## License\nLicensed under the MIT License.\n\nClick [here](/LICENSE) for further information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDavideGalilei%2Fgpytranslate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDavideGalilei%2Fgpytranslate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDavideGalilei%2Fgpytranslate/lists"}