Translation Import API

This v1 API method is scheduled for deprecation March 1, 2017. Where possible, use File API v2

The Import API allows you to import existing translated content by matching keys from an original source file to keys in the translated file (10 MB limit).

If you select the overwrite option, Smartling will overwrite any translation that is already in Smartling, with the translation in the file being imported from.

Any Smartling directives in the original source file (for example, placeholders) must also appear in the translated file.

The Import API uses the following URL: https://api.smartling.com/v1/file/import and is a HTTP POST, multipart/form-data type.

You cannot import translations unless there are source strings in the Smartling Dashboard to match those translations to. You must upload your source file first, then import your translations. Smartling matches translated strings with source strings that share the same key, so you can only import translations for files that use key/value pairs.

The Import API sets successful string translation imports to the workflow state specified and creates a translation memory entry.

TranslationImport (/v1/file/import)


Parameters

apiKey (required)

The API Key for your account. Available in the Smartling dashboard at Project Settings>API.

projectId (required)

The unique ID for your project. Available in the Smartling dashboard at Project Settings>API.

fileUri (required)

The Smartling URI for file that contains the original language strings already uploaded to Smartling.

fileType (required)

The type of file used for imports. Valid values are: ios, android, gettext, javaProperties, xml, json, yaml, and csv.

To allow translation imports, XML and JSON files must be uploaded with source_key_paths defined.

See details on valid directives for each type supported for importing in Supported File Types.

locale (required)

The Smartling locale identifier for the language Smartling is importing (see https://dashboard.smartling.com/settings/api for valid locales)

file (required)

The file on your local machine that contains the translated content

overwrite (optional)

Boolean indicating whether or not to overwrite existing translations.

translationState (required)

Value indicating the workflow state to import the translations into. Content will be imported into the language's default workflow.

  • PUBLISHED - The translated content is published.
  • POST_TRANSLATION - The translated content is imported into the first step after translation - if there are none, it will be published.

Returns
{"response":{"data":{"wordCount":174,"stringCount":11,"translationImportErrors":[{"stringHashcode":"e0c8e180e33546fb41df2db297e7ee23","contentFileId":18936,"messages":["Mismatched placeholders for original string and translated one"],"importKey":"ios string11"}]},"code":"SUCCESS","messages":[]}}

data.wordCount

Words imported.

data.stringCount

Strings imported.

translationImportErrors.stringHashcode

The hashcode of a string affected by the error

translationImportErrors.contentFileID

The ID of the file affected by an error

translationImportErrors.messages

Information about an import error

translationImportErrors.importKey

Key for an imported string affected by the error

Examples

Import Examples for Android XML

Original English file:


<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="string_1">Hello</string>
    <string name="string_2">Goodbye</string>
</resources>

Spanish translation file:


<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="string_1">Hola</string>
    <string name="string_2">Adios</string>
</resources>

Import Errors

Key not found:

The import file included a key that does not exist in the original source file, so Smartling couldn't match it to an original string.

Placeholder Mismatch

If the number of placeholders in your translation for a string does not match the number of placeholders in the original source string, Smartling won’t set the string to the “published” workflow state. Smartling sets the imported translation to the “In Translation” workflow state for the appropriate locale in the Smartling dashboard at Content > In Translation and creates an unresolved issue for the string credited to the API user with the comment: "Placeholders mismatch for the translation import". Smartling will not create a Translation Memory entity for strings that fail to import to the “Published” workflow state.

Authorized users can use the Smartling Dashboard and Translation Interface (TI) to edit the translation, make corrections, and resolve the issue. The Smartling TI requires that you provide the appropriate number of placeholders (there is an exception to the placeholder requirement for translation of Plural strings.)

Limitations

  • The Import API does not yet support the Smartling iOS plurals format.
  • TMX imports follow a different process and will not require that you upload an original source language first. Uploaded TMX files are associated with a Smartling account and can be shared with all projects in an account.