|
| 1 | +<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/> |
| 2 | + |
| 3 | +# Google Translate API Python Samples |
| 4 | + |
| 5 | +With the [Google Translate API][translate_docs], you can dynamically translate |
| 6 | +text between thousands of language pairs. |
| 7 | + |
| 8 | +[translate_docs]: https://cloud.google.com/translate/docs/ |
| 9 | + |
| 10 | +## Table of Contents |
| 11 | + |
| 12 | +* [Setup](#setup) |
| 13 | +* [Samples](#samples) |
| 14 | + * [Translate](#translate) |
| 15 | + |
| 16 | +## Setup |
| 17 | + |
| 18 | +Install dependencies: |
| 19 | + |
| 20 | + virtualenv env |
| 21 | + source env/bin/activate |
| 22 | + pip install -r requirements.txt |
| 23 | + |
| 24 | +## Samples |
| 25 | + |
| 26 | +### Translate |
| 27 | + |
| 28 | +View the [documentation][translate_docs] or the [source code][translate_code]. |
| 29 | + |
| 30 | +__Usage:__ `python snippets.py --help` |
| 31 | + |
| 32 | +``` |
| 33 | +usage: snippets.py [-h] |
| 34 | + api_key |
| 35 | + {detect-language,list-languages,list-languages-with-target,translate-text} |
| 36 | + ... |
| 37 | +
|
| 38 | +This application demonstrates how to perform basic operations with the |
| 39 | +Google Cloud Translate API |
| 40 | +
|
| 41 | +For more information, the documentation at |
| 42 | +https://cloud.google.com/translate/docs. |
| 43 | +
|
| 44 | +positional arguments: |
| 45 | + api_key Your API key. |
| 46 | + {detect-language,list-languages,list-languages-with-target,translate-text} |
| 47 | + detect-language Detects the text's language. |
| 48 | + list-languages Lists all available langauges. |
| 49 | + list-languages-with-target |
| 50 | + Lists all available langauges and localizes them to |
| 51 | + the target language. Target must be an ISO 639-1 |
| 52 | + language code. |
| 53 | + translate-text Translates text into the target language. Target must |
| 54 | + be an ISO 639-1 language code. |
| 55 | +
|
| 56 | +optional arguments: |
| 57 | + -h, --help show this help message and exit |
| 58 | +``` |
| 59 | + |
| 60 | +[translate_docs]: https://cloud.google.com/translate/docs |
| 61 | +[translate_code]: snippets.py |
0 commit comments