> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# TranslateSite

# Package: machineTranslation

# Namespace: AsyncSiteTranslator

# Method link: https://dev.wix.com/docs/api-reference/business-management/multilingual/machine-translation/async-site-translator/translate-site.md

## Permission Scopes:
Wix Multilingual: SCOPE.MULTILINGUAL.MANAGE_TRANSLATIONS

## Introduction

Starts a background job that translates a site's content from one locale to another.

The call returns as soon as the job is accepted, and the response contains only the job's ID.
Pass that ID to Get Translation Job Status to track the job.

The job reads the site's content as it goes, rather than working from a snapshot taken when it
started. Content edited while the job is running may or may not be included, depending on
whether the job has already reached it.

Translated fields are marked as ready to publish as the job completes them.

Several jobs can run against the same site at the same time. Each job selects its fields
independently, according to its own `filterByStatus`, at the moment it reads them. Two jobs
started close together can both select the same field and translate it twice. Wait for a job to
reach `COMPLETED` or `FAILED` before starting another one over the same content.

The translation engine is selected automatically based on the site's editor. You can't choose it
in the request, and the job doesn't report which engine ran.

---

## REST API

### Schema

```
 Method: translateSite
 Description: Starts a background job that translates a site's content from one locale to another.  The call returns as soon as the job is accepted, and the response contains only the job's GUID. Pass that GUID to Get Translation Job Status to track the job.  The job reads the site's content as it goes, rather than working from a snapshot taken when it started. Content edited while the job is running may or may not be included, depending on whether the job has already reached it.  Translated fields are marked as ready to publish as the job completes them.  Several jobs can run against the same site at the same time. Each job selects its fields independently, according to its own `filterByStatus`, at the moment it reads them. Two jobs started close together can both select the same field and translate it twice. Wait for a job to reach `COMPLETED` or `FAILED` before starting another one over the same content.  The translation engine is selected automatically based on the site's editor. You can't choose it in the request, and the job doesn't report which engine ran.
 URL: https://www.wixapis.com/multilingual/v3/async-site-translator/translate
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  mainLocale, translatedLocale, filterByStatus
 Method parameters: 
   param name: filter | type: filter | description: Optional filter that narrows which content the job translates. Uses the same filter syntax as Translation Content, over the `schemaId` and `entityId` fields. For example, `{"schemaId": "<SCHEMA_ID>"}` translates a single schema, and `{"entityId": {"$in": ["<ID_1>", "<ID_2>"]}}` translates specific items. The `locale` key is reserved. The job already scopes itself to `mainLocale`, and supplying your own `locale` overrides that scoping.  
   param name: filterByStatus | type: FieldStatusFilter   | required: true 
      - enum:
           ALL_FIELDS - Every translatable field, including fields that are already translated.
           UNTRANSLATED_ONLY - Fields that have no translation yet.
           OUTDATED_ONLY - Fields whose source content changed after they were translated.
           UNTRANSLATED_AND_OUTDATED - Fields that have no translation yet, and fields whose source content changed after they were translated.
   param name: mainLocale | type: mainLocale | description: Locale to translate the content from, in [IETF BCP 47](https://en.wikipedia.org/wiki/IETF_language_tag) language tag format. Typically, this is a lowercase 2-letter language code, followed by a hyphen, followed by an uppercase 2-letter country code. For example, `en-US` for U.S. English, and `de-DE` for Germany German. | required: true | validation: format LANGUAGE_TAG
   param name: translatedLocale | type: translatedLocale | description: Locale to translate the content into, in [IETF BCP 47](https://en.wikipedia.org/wiki/IETF_language_tag) language tag format. Typically, this is a lowercase 2-letter language code, followed by a hyphen, followed by an uppercase 2-letter country code. For example, `en-US` for U.S. English, and `de-DE` for Germany German. | required: true | validation: format LANGUAGE_TAG
 Return type: TranslateSiteResponse
  - name: jobId | type: string | description: Translation job GUID. Pass this GUID to Get Translation Job Status to retrieve the status of the translation job.  | validation: format GUID

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: LANGUAGE_NOT_SUPPORTED | Description: The specified language can't be machine translated.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: LOCALE_NOT_FOUND | Description: Couldn't find the locale on the site.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: MT_CODE_NOT_CONFIGURED | Description: The specified locale has no machine translation code configured. Use a locale that supports machine translation.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: NOT_ENOUGH_CREDITS | Description: The site doesn't have enough word credits for the content in scope. `requiredWords` reports how many words need credit.


```

### Examples

### Translate Site Call Example
This example shows how to start a background job that translates all untranslated and outdated site content from English to Italian.

```curl
curl -X POST 'https://www.wixapis.com/multilingual/v3/async-site-translator/translate' \
     --data-binary '{
                      "mainLocale": "en-US",
                      "translatedLocale": "it-IT",
                      "filterByStatus": "UNTRANSLATED_AND_OUTDATED"
                    }' \
     -H 'Content-Type: application/json' \
     -H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.multilingual.asyncSiteTranslator.translateSite(mainLocale, options)
 Description: Starts a background job that translates a site's content from one locale to another.  The call returns as soon as the job is accepted, and the response contains only the job's GUID. Pass that GUID to Get Translation Job Status to track the job.  The job reads the site's content as it goes, rather than working from a snapshot taken when it started. Content edited while the job is running may or may not be included, depending on whether the job has already reached it.  Translated fields are marked as ready to publish as the job completes them.  Several jobs can run against the same site at the same time. Each job selects its fields independently, according to its own `filterByStatus`, at the moment it reads them. Two jobs started close together can both select the same field and translate it twice. Wait for a job to reach `COMPLETED` or `FAILED` before starting another one over the same content.  The translation engine is selected automatically based on the site's editor. You can't choose it in the request, and the job doesn't report which engine ran.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  mainLocale, options.translatedLocale, options.filterByStatus, options
 Method parameters: 
   param name: mainLocale | type: string | description: Locale to translate the content from, in [IETF BCP 47](https://en.wikipedia.org/wiki/IETF_language_tag) language tag format. Typically, this is a lowercase 2-letter language code, followed by a hyphen, followed by an uppercase 2-letter country code. For example, `en-US` for U.S. English, and `de-DE` for Germany German. | required: true | validation: format LANGUAGE_TAG
   param name: options | type: TranslateSiteOptions  none | required: true 
        - name: translatedLocale | type: string | description: Locale to translate the content into, in [IETF BCP 47](https://en.wikipedia.org/wiki/IETF_language_tag) language tag format. Typically, this is a lowercase 2-letter language code, followed by a hyphen, followed by an uppercase 2-letter country code. For example, `en-US` for U.S. English, and `de-DE` for Germany German. | required: true | validation: format LANGUAGE_TAG
        - name: filterByStatus | type: FieldStatusFilter | description: Which fields the job translates, based on their current translation status. | required: true 
             - enum:
             -     ALL_FIELDS: Every translatable field, including fields that are already translated.
             -     UNTRANSLATED_ONLY: Fields that have no translation yet.
             -     OUTDATED_ONLY: Fields whose source content changed after they were translated.
             -     UNTRANSLATED_AND_OUTDATED: Fields that have no translation yet, and fields whose source content changed after they were translated.
        - name: filter | type: object | description: Optional filter that narrows which content the job translates. Uses the same filter syntax as Translation Content, over the `schemaId` and `entityId` fields. For example, `{"schemaId": "<SCHEMA_ID>"}` translates a single schema, and `{"entityId": {"$in": ["<ID_1>", "<ID_2>"]}}` translates specific items. The `locale` key is reserved. The job already scopes itself to `mainLocale`, and supplying your own `locale` overrides that scoping.  
 Return type: PROMISE<TranslateSiteResponse>
  - name: jobId | type: string | description: Translation job GUID. Pass this GUID to Get Translation Job Status to retrieve the status of the translation job.  | validation: format GUID

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: LANGUAGE_NOT_SUPPORTED | Description: The specified language can't be machine translated.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: LOCALE_NOT_FOUND | Description: Couldn't find the locale on the site.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: MT_CODE_NOT_CONFIGURED | Description: The specified locale has no machine translation code configured. Use a locale that supports machine translation.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: NOT_ENOUGH_CREDITS | Description: The site doesn't have enough word credits for the content in scope. `requiredWords` reports how many words need credit.


```

### Examples

### Translate untranslated and outdated site content
Start a background job from English to Italian using locale IDs configured on the site.

```javascript
import { asyncSiteTranslator } from "@wix/multilingual";

async function translateSite() {
  const response = await asyncSiteTranslator.translateSite("en", {
    translatedLocale: "it-it",
    filterByStatus: "UNTRANSLATED_AND_OUTDATED",
  });
}

/* Promise resolves to:
 * {
 *   "jobId": "243de60c-110f-4e29-803d-132042d45473"
 * }
 */

```

### translateSite (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { asyncSiteTranslator } from '@wix/multilingual';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { asyncSiteTranslator },
  // Include the auth strategy and host as relevant
});


async function translateSite(mainLocale,options) {
  const response = await myWixClient.asyncSiteTranslator.translateSite(mainLocale,options);
};
```

---