This API endpoint allows for the translation of texts into different languages using the LetzChat service.
Endpoint
URL: https://letzchat.pro/firestoreconfig/translate_CUSTOM_ENDPOINT_PER_CUSTOMER.php
Method: POST
Authorization: Bearer Token
Headers
Content-Type: application/json
Authorization: Bearer CUSTOM-TOKEN-PER-CUSTOMER
Request Body
{
"lang": "fr",
"texts": [
"hello my house is for sale",
"the owl is silver"
]
}
Response
{
"texts": [
"bonjour ma maison est à vendre",
"la chouette est argentée"
],
"lang": "fr",
"lang_source": "en"
}
Testing the API
To test the translation API:
- Open the Postman application.
- Create a new
POST
request to the endpoint URL:https://letzchat.pro/firestoreconfig/translate_CUSTOM_ENDPOINT_PER_CUSTOMER.php
. - Under the Authorization tab, select
Bearer Token
and paste the provided token:CUSTOM-TOKEN-PER-CUSTOMER
. - In the Body tab, choose
raw
and selectJSON
format. Paste the following JSON structure into the body:{ "lang": "fr", "texts": [ "hello my house is for sale", "the owl is silver" ] }
- Click Send to execute the request.
Language Detection
To determine the user's current language on your webpage, use the lzCurrentLanguage
variable. This variable holds the current language code, which can be sent to the API as the lang
parameter for translations.
console.log("Current Language: " + lzCurrentLanguage);