|
| 1 | +# Google Cloud Translate API Samples |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +These samples show how to use the [Google Cloud Translate API]( |
| 6 | +https://cloud.google.com/translate/). |
| 7 | + |
| 8 | +## Build and Run |
| 9 | +1. **Enable APIs** - [Enable the Translate API](https://console.cloud.google.com/flows/enableapi?apiid=translate.googleapis.com) |
| 10 | + and create a new project or select an existing project. |
| 11 | +2. **Download The Credentials** - Click "Go to credentials" after enabling the APIs. Click "Create Credentials" |
| 12 | + and select "API key". Copy the API key. |
| 13 | +3. **Clone the repo** and cd into this directory |
| 14 | +``` |
| 15 | + $ git clone https://github.com/GoogleCloudPlatform/php-docs-samples |
| 16 | + $ cd php-docs-samples/vision/api |
| 17 | +``` |
| 18 | +4. **Install dependencies** via [Composer](http://getcomposer.org/doc/00-intro.md). |
| 19 | + Run `php composer.phar install` (if composer is installed locally) or `composer install` |
| 20 | + (if composer is installed globally). |
| 21 | +5. **Run**: |
| 22 | +``` |
| 23 | +$ php translate.php |
| 24 | +Console Tool |
| 25 | +
|
| 26 | +Usage: |
| 27 | + command [options] [arguments] |
| 28 | +
|
| 29 | +Options: |
| 30 | + -h, --help Display this help message |
| 31 | + -q, --quiet Do not output any message |
| 32 | + -V, --version Display this application version |
| 33 | + --ansi Force ANSI output |
| 34 | + --no-ansi Disable ANSI output |
| 35 | + -n, --no-interaction Do not ask any interactive question |
| 36 | + -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug |
| 37 | +
|
| 38 | +Available commands: |
| 39 | + detect Detect which language text was written in using Google Cloud Translate API |
| 40 | + help Displays help for a command |
| 41 | + list Lists commands |
| 42 | + list-codes List all the language codes in the Google Cloud Translate API |
| 43 | + list-langs List language codes and names in the Google Cloud Translate API |
| 44 | + translate Translate text using Google Cloud Translate API |
| 45 | +``` |
| 46 | + |
| 47 | +6. Run `php translate.php COMMAND --help` to print information about the usage of each command. |
| 48 | + |
| 49 | +## Contributing changes |
| 50 | + |
| 51 | +* See [CONTRIBUTING.md](../../CONTRIBUTING.md) |
| 52 | + |
| 53 | +## Licensing |
| 54 | + |
| 55 | +* See [LICENSE](../../LICENSE) |
0 commit comments