About the Translation Content API

Developer Preview
APIs in Developer Preview are subject to change and are not intended for use in production.
Send us your suggestions for improving this API. Your feedback is valuable to us.

 

The Translation Content API allows you to access and manage a site's translation content based on the defined translation schema.

With the Translation Content API, your app can:

  • Create, update, and delete content.
  • Get, and query existing content.
  • Listen to events when content is created, updated, and deleted.

This API is based on Wix Multilingual.

Steps for managing translation content

Step 1 | Add original content in the site's primary language

To begin, you need to add the base content for translation in the site's primary language. This content aligns with the schema you’ve already defined and serves as the foundation for future translations.

Depending on your app, this content can either be user-generated or default content provided by your app:

  • User-generated content: If your app collects user-generated content, prompt Wix users to provide the relevant content. Call createContent() to save this collected content, ensuring it aligns with the schema you defined in the previous step.
  • Default content: If your app provides boilerplate or default content, call createContent() with this default content initially. If at a later time users provide their own content, call updateContent() to replace the default content with user-generated content.

Step 2 | Translate and store the content

Once the original content is added, it can be translated and stored in the following ways:

  • The Wix user can generate translations in the Translation Manager, either manually or using machine translation. When the Wix user saves the translations, the Translation Manager automatically calls the Translation Content API to store the translated content and mark it as ready to publish.
  • Your app can generate the translations or use a third party service to generate them. Wix's Machine Translation API is available for this purpose. Then, call the Translation Content API to store the translated content and flag it for publishing.

Before you begin

It's important to note the following points before starting to code:

  • You can only add translation content to entities that have an existing translation schema. Use the Translation Schema API method to create the schema.
  • The translation content is validated against the corresponding translation schema. For example, if you create a schema field with "type": "VIDEO", you can't set the create content value for that field to an "IMAGE". If you add invalid content you'll get a validation error.
  • This API stores both the original and the translated content, but doesn’t manage site locales or currency conversions.
  • You can only use this API on sites where the Wix user has installed the Wix Multilingual app.

Use cases

Terminology

  • ContentField: This represents the actual content that will be translated, mapped to a specific field in the schema. The ContentField holds the original or translated data (such as the text for a product title) and is linked to its corresponding SchemaField, ensuring it follows the schema’s validation rules.
  • Fields: A list of fields for the translation content. This property uses a string to map to a ContentField (Map<string, ContentField>). The string serves as a key, which you'll need to access each field in the content and when referencing a translation schema.
  • Published: A boolean that indicates whether translated content is ready to publish.
  • Publish status: The aggregated publish status across all content fields. Supported values:
    • UNPUBLISHED: None of the fields have been marked as ready to publish.
    • PUBLISHED: All of the fields have been marked as ready to publish.
    • PARTIALLY_PUBLISHED: Some of the fields have been marked as ready to publish.
Did this help?