# Romanize text

> [!WARNING]
>
> **Preview**
>
>
> This feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
> [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

Romanization converts non-Latin script to Latin script. The Latin script is
based on the pronunciation of the source language. For example,
Cloud Translation romanizes the following Japanese characters `こんにちは世界`
into `Kon'nichiwa sekai`.

To see which languages can be romanized, see [Supported languages](https://docs.cloud.google.com/translate/docs/languages.md.txt#roman).

## Before you begin


Before you can start using the Cloud Translation API, you should complete the
[Cloud Translation setup](https://docs.cloud.google.com/translate/docs/setup.md.txt) page, which includes creating a
project, enabling the Cloud Translation API, and setting up authentication. The setup page also provides
instructions for installing client libraries for common programming languages, which is
optional.

<br />

## Romanize text

### REST

Use the
[`romanizeText`](https://docs.cloud.google.com/translate/docs/reference/rest/v3/projects.locations/romanizeText.md.txt)
method to convert non-Latin script into Latin script.


Before using any of the request data,
make the following replacements:

- <var translate="no">PROJECT_NUMBER_OR_ID</var>: the numeric or alphanumeric ID of your Google Cloud project
- <var translate="no">LOCATION</var>: Region where you want to run this operation. For example, `us-central1`.
- <var translate="no">SOURCE_LANGUAGE</var>: The language code of the source text.
- <var translate="no">SOURCE_TEXT</var>: Text in the source language to romanize.


HTTP method and URL:

```
POST https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:romanizeText
```


Request JSON body:

```
{
  "source_language_code": "SOURCE_LANGUAGE",
  "contents": "SOURCE_TEXT"
}
```

To send your request, expand one of these options:

#### curl (Linux, macOS, or Cloud Shell)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) , or by using [Cloud Shell](https://docs.cloud.google.com/shell/docs.md.txt), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Save the request body in a file named `request.json`,
and execute the following command:

```
curl -X POST \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "x-goog-user-project: PROJECT_NUMBER_OR_ID" \
     -H "Content-Type: application/json; charset=utf-8" \
     -d @request.json \
     "https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:romanizeText"
```

#### PowerShell (Windows)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Save the request body in a file named `request.json`,
and execute the following command:

```
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "PROJECT_NUMBER_OR_ID" }

Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -ContentType: "application/json; charset=utf-8" `
    -InFile request.json `
    -Uri "https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:romanizeText" | Select-Object -Expand Content
```

You should receive a JSON response similar to the following:

```
{
  "romanizations": [
    {
      "romanizedText": "ROMANIZED_TEXT"
    }
  ]
}
```

<br />

## What's next

- Romanization is priced per character sent. For more information, see [Pricing](https://cloud.google.com/translate/pricing).