Machine Translation & Credit Data: Sample Flow

This article presents possible use cases and corresponding sample flows that you can support. This can be a helpful jumping off point as you plan your implementation.

Translate a blog post with credit validation

Many businesses maintain blogs to increase their online presence and visibility, establish their expertise in the industry, and drive more traffic to their website. A business may want to translate their blog posts to other languages to reach international audiences. Your app can use the Machine Translation APIs to translate content while monitoring translation credit usage.

To translate a blog post with credit validation:

  1. Retrieve a blog post using the Wix Blog API.

  2. Count the total words in the blog post content to estimate credit requirements.

  3. Call Check Sufficient Credits to verify the site has enough credits for the translation.

  4. If insufficient credits are available, notify the Wix user and provide options to purchase additional credits through the Translation Manager.

  5. Check the length of the post content:

    • If under 5,000 characters: Use Machine Translate to translate the post.
    • If over 5,000 characters: Parse the content into units of 5,000 characters or less, ensuring you don't break sentences. Then use Bulk Machine Translate to translate all units. Append the translated text back into a single unit.
  6. Store the translated content separately from the original blog post.

  7. Call Get Credit Data to retrieve the updated credit balance for display to the Wix user.

  8. Return the translated content and remaining credit information.

Did this help?