# Migrate from Google Translate

Move a Google Cloud Translation v2 integration to VibeQL by changing the base URL and the API key.

VibeQL serves the Google Cloud Translation v2 (Basic) REST format. Change the base URL and the key, and keep your request code.

| | Google | VibeQL |
|---|---|---|
| Base URL | `https://translation.googleapis.com/language/translate/v2` | `https://vibeql.com/language/translate/v2` |
| Key | `?key=` Google API key | `?key=` VibeQL key |

VibeQL also accepts the key in an `Authorization: Bearer` header. See [Authentication](/docs/authentication).

## Translate

`GET` or `POST https://vibeql.com/language/translate/v2`

| Parameter | Required | Description |
|---|---|---|
| `q` | Yes | Text to translate. Repeat it for several strings, up to 50. |
| `target` | Yes | Target language, for example `de` or `pt-BR`. |
| `source` | No | Source language. Leave it out and the API detects it. |
| `format` | No | `text` or `html`. Other values return `400`. |

**Form**

```bash
curl "https://vibeql.com/language/translate/v2?key=$VIBEQL_API_KEY" \
  -d "q=Where is the station?" \
  -d "q=How much is it?" \
  -d "target=de"
```

**JSON**

```bash
curl "https://vibeql.com/language/translate/v2?key=$VIBEQL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"q": ["Where is the station?", "How much is it?"], "target": "de"}'
```

```json
{
  "data": {
    "translations": [
      { "translatedText": "Wo ist der Bahnhof?", "detectedSourceLanguage": "en" },
      { "translatedText": "Wie viel kostet das?", "detectedSourceLanguage": "en" }
    ]
  }
}
```

The response has the same shape as Google's. `detectedSourceLanguage` is in each result, also when you send `source`.

## Detect the language

`POST https://vibeql.com/language/translate/v2/detect` with one or more `q` values.

```bash
curl "https://vibeql.com/language/translate/v2/detect?key=$VIBEQL_API_KEY" \
  -d "q=Bonjour tout le monde"
```

```json
{ "data": { "detections": [[{ "language": "fr", "isReliable": false, "confidence": 1 }]] } }
```

## List languages

`GET https://vibeql.com/language/translate/v2/languages`. Add `target=en` to get the names too.

```bash
curl "https://vibeql.com/language/translate/v2/languages?key=$VIBEQL_API_KEY&target=en"
```

```json
{ "data": { "languages": [{ "language": "ar", "name": "Arabic" }, { "language": "de", "name": "German" }] } }
```

## Language codes

VibeQL supports 34 target languages, fewer than Google. A code that VibeQL does not support returns `400`. See [Languages](/docs/languages).

> **Important:** In Google, `pt` means Brazilian Portuguese. In VibeQL, `pt` means European Portuguese. Send `pt-BR` for Brazilian Portuguese.

- `zh-CN` and `zh-TW` work as in Google.
- `no` maps to Norwegian Bokmål.
- `en` maps to American English. Send `en-GB` for British English.
- Codes are not case-sensitive.

## Errors

Errors use the Google format:

```json
{ "error": { "code": 403, "message": "Authorization failure, check auth_key", "status": "PERMISSION_DENIED" } }
```

See [Limits and errors](/docs/limits-and-errors) for all status codes.

## Documents

Google's document translation API is not available. Use the [DeepL or Azure document endpoints](/docs/translate-documents) with the same key.
