About the Translation Schema 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 Schema API allows you to manage the schema for translating site content. Define the structure and fields of your app's translatable content to ensure consistency and accuracy across different locales. You only need to do this setup once per entity, providing a foundation for all future translations.

You can create schemas for each entity of your app. For example, if you are developing a food delivery app, you may want to create two schemas, one for a menu and another for orders.

With the Translation Schema API, your app can:

  • Create, update, and delete a translation schema.
  • Get an existing translation schema by ID or key.
  • Query your app's schemas.
  • List all schemas associated with a site.

Validations

You can also set validations for fields in the schema. For example, in the schema below, the title field has a minLength of 1, meaning the smallest valid text value for that field must be at least one character long. If validations are defined in the schema, the corresponding content is constrained to those validations. If you add invalid content you'll get a validation error.

Copy

Before you begin

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

  • There are no private schemas. All of a site's schemas can be retrieved by calling List Site Schemas.
  • You can only use this API on sites where the Wix user has installed the Wix Multilingual app.

Use cases

Terminology

  • Scope: A schema can have one of two scopes:

    • Site: A custom schema for a specific site.

    • Global: A global schema for all sites.

    You can update both site and global schemas, as well as change a site schema to global or vice versa. However, if you need to create a site-specific schema based on an existing global one, create a new schema with a site scope and manually copy the specifications from the existing global one.

  • Schema field: This defines the structure and validation rules for a field within a translation schema. It specifies the type of data (such as text or image) and constraints (such as minimum or maximum length) for each field in the schema. The SchemaField ensures that any content added conforms to the defined format.

  • Fields: A list of fields for the translation schema. The fields property uses a string to map to a SchemaField (Map<string, SchemaField>). The string serves as a key, which you'll need to access each field in the schema and when adding translation content.

Did this help?