Uredi

Deli z drugimi prek


Container: Transliterate Text

Convert characters or letters of a source language to the corresponding characters or letters of a target language.

Request URL

POST request:

 POST http://localhost:{port}/transliterate?api-version=3.0&language={language}&fromScript={fromScript}&toScript={toScript}

See Virtual Network Support for Translator service selected network and private endpoint configuration and support.

Request parameters

Request parameters passed on the query string are:

Query parameter Description Condition
api-version Version of the API requested by the client. Value must be 3.0. Required parameter
language Specifies the source language of the text to convert from one script to another. Required parameter
fromScript Specifies the script used by the input text. Required parameter
toScript Specifies the output script. Required parameter

Request headers

Headers Description Condition
Authentication headers See available options for authentication Required request header
Content-Type Specifies the content type of the payload. Possible value: application/json Required request header
Content-Length The length of the request body. Optional
X-ClientTraceId A client-generated GUID to uniquely identify the request. You can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. Optional

Response body

A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties:

  • text: A string that results from converting the input string to the output script.

  • script: A string specifying the script used in the output.

Response headers

Headers Description
X-RequestId Value generated by the service to identify the request. It can be used for troubleshooting purposes.

Sample request

curl -X POST "http://localhost:5000/transliterate?api-version=3.0&language=ja&fromScript=Jpan&toScript=Latn"

Sample request body

The body of the request is a JSON array. Each array element is a JSON object with a string property named Text, which represents the string to convert.

[
    {"Text":"こんにちは"},
    {"Text":"さようなら"}
]

The following limitations apply:

  • The array can have a maximum of 10 elements.
  • The text value of an array element can't exceed 1,000 characters including spaces.
  • The entire text included in the request can't exceed 5,000 characters including spaces.

Sample JSON response:

[
  {
    "text": "Kon'nichiwa​",
    "script": "Latn"
  },
  {
    "text": "sayonara",
    "script": "Latn"
  }
]

Note

  • Each sample runs on the localhost that you specified with the docker run command.
  • While your container is running, localhost points to the container itself.
  • You don't have to use localhost:5000. You can use any port that is not already in use in your host environment.

Transliterate with REST API


  curl -X POST "http://localhost:5000/transliterate?api-version=3.0&language=ja&fromScript=Jpan&toScript=Latn" -H "Content-Type: application/json" -d "[{'Text':'こんにちは'},{'Text':'さようなら'}]"

Next Steps