Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page broadly describes the methods you would use to :send files for translation into a Codyt project. This can be used for translating a CMS or any other content.

  • Find project or create new project

  • Send files for translation into a project

  • Poll for the completion of workflows / jobs

  • Optional creation of translated files (if not down by the translation team or automation)

  • Download translated files

...

Note that in our screenshot above, the French translator already finished the work. So, we should be able to fetch the French translation but not yet the Spanish one.

...

Find completed workflows

Now that we started sending content for translation, we definitely want to check in to see if any work has been completed! If so, we want to download that work.

Use the “workflows” method to list all completed workflows / documents in a project:

Code Block
curl --location '{{API1URL}}/projects/workflows?token={{token}}&sourcelocale=en&workflowstatus=1&statusdatefrom=2023-04-25&projectid=5938&from=0&count=100'

The above enumerates all workflows satisfying these conditions:

  • Check for workflows with English source locale (en)

  • Check only completed workflows: workflowstatus = 1

  • Check for project with ID = 5938

  • Get the first 100 completed workflows / documents (see from / count)

  • Get only workflows that were completed after the last time we checked (see statusdatefrom). This condition is really useful as it prevents that you get workflows completed in the past (and which you already had processed).

The method returns all workflows (a specific document for a specific source and target locale). Example:

Code Block
[
    {
        "BeeDocumentId": 20630,
        "BeeDocumentSetId": 6837,
        "Comments": "",
        "IsCurrent": true,
        "LocaleSource": "en",
        "LocaleTarget": "en",
        "Name": "content103.html",
        "OpenTasks": 0,
        "ProjectId": 5938,
        "ProjectReference": "Stephan API1 Test",
        "RevisionSetId": 11319,
        "Status_": 1,
        "StatusUpdateDate": "/Date(1682486757650+0200)/",
        "Version": "",
        "VersionDate": "/Date(1682486757610+0200)/"
    },
    {
        "BeeDocumentId": 20630,
        "BeeDocumentSetId": 6837,
        "Comments": "",
        "IsCurrent": true,
        "LocaleSource": "en",
        "LocaleTarget": "fr",
        "Name": "content103.html",
        "OpenTasks": 0,
        "ProjectId": 5938,
        "ProjectReference": "Stephan API1 Test",
        "RevisionSetId": 11319,
        "Status_": 1,
        "StatusUpdateDate": "/Date(1682501618297+0200)/",
        "Version": "",
        "VersionDate": "/Date(1682486757610+0200)/"
    }
]

The first item is the source document itself, we can disregard it.

The second item is the completed French translation. We did see the completed job in the Wordbee platform - see the screenshot further up.

With the target language and the document name, we can now proceed with the download of this translation.

Note: We use present method since we only want to download a translation when all workflow steps are completed.

Build translated file (optional)

In most cases, your project workflow automatically creates the translated file upon completion of a workflow. This can be configured in the Workflow & Supplier page of the project.

Alternatively, you may ask the supplier (in the last workflow step to do so).

Or, finally, you may create the translated file with the API. Just make sure that the workflow is completed (you use the method in the previous chapter).

To create the translated file you run:

Code Block
curl --location --request POST '{{API1URL}}/projects/5938/files/en/file/translation?token={{token}}&name=content103.html&targetlocale=fr'

You need to specify:

  • The source locale (see “en”)

  • The project ID (5938 in our example)

  • The name of the file to download

  • The target locale

Download translated file

Download the file using:

Code Block
curl --location '{{API1URL}}/projects/5938/files/fr/file?token={{token}}&names=content103.html'

You need to specify:

  • The source locale (see “en”)

  • The project ID (5938 in our example)

  • The name of the file to download

  • The target locale

See Download files or folders for more details.

File names and folders

A file name can include folders such as:

Code Block
folder1\folder2\myfile.html

Make sure to URL encode the \ in the parameters (replace \ by %5C)

Code Block
folder1%5Cfolder2%5Cmyfile.html

Next steps

These are just the most important methods that you likely would use for an integration.

There are many more advanced methods. Check out the present API 1 documentation.