Sample Use Case and Flow

This article presents a possible use case and corresponding sample flow that your app can support. It provides a useful starting point as you plan your app's implementation.

Translation flow with default app content and user-generated translations

Suppose you're developing an app for managing book collections, and you want your Wix users (bookstore owners) to be able to translate the book collection data from the primary language en-us into other languages on their site.

Step 1 | Define the schemas

Use the Create Schema method to define which fields of your book and collection entities are translatable. This step only needs to be done once. The fields parameter maps each field name (as a string) to an object specifying the data type (like text or image) and any constraints (like minimum or maximum length). The string acts as a key, which you'll use when adding translation content. The Create Schema method returns a schema ID that is also required for adding the translation content in the following step.

In our example, we define two schemas with the following fields:

SchemaFields
Book
  • Title
  • Author
  • Description
Book Collection
  • Title

Step 2 | Add default translatable content

Ask the Wix user to specify the site's primary language. Call the Create Content method with the schema ID and the string key for each field to add your app's default content in the site's primary language. This content will serve as the base for all future translations across different locales.

For example, if the site's primary language is en-us, your default translatable content (field values) for a book may look like this:

Copy

Step 3 | Wix user adds translations

The Wix user translates the book and book collection content via the Translation Manager. When they save the translations, the Translation Manager automatically calls the Translation Content API to store the updated content and mark it as ready to publish.

Step 4 | Use published translations

When a site visitor views the site in a language other than the site’s primary language, call Query Published Content to retrieve and display the publish-ready translated content in their language. This ensures site visitors see the appropriate translations for their locale.

Did this help?