Skip to main content

Update Translated Files with File Rewrite Rules

There may be occasions when you need to make a change to your translations upon downloading the translated file, without updating the translations in the Translation Memory or anywhere on the Smartling dashboard. Such changes could include updating a single word or phrase, an entire string or block of text, or even a URL, similarly to performing a find and replace all within the translated file.

With File Rewrite Rules, Account Owners can define changes to be applied to translations for any language, within any file-based project in your account, translating in any of the supported file types.

Example - Localizing URLs

If your translated file contains a URL, such as www.yourcomany.com, to protect the URL, the Smartling CAT Tool does not allow linguistics to edit a URL, but does allow them to place the URL in the correct position of the translation. Using File Rewrite Rules, you can create a rule that rewrites www.yourcompany.com to www.yourcompany.fr in French translated files, www.yourcompany.de in German translated files, etc. See how to create this rule below.

File Download

The rewrite is only visible in the downloaded supported file type, and not anywhere in the Smartling Dashboard. The rewrite is visible in pseudo, current and published file downloads. You can download the file from within the Job Details, from the Files tab, or via the API. The File Rewrite Rule must be created before downloading the file.

Supported File Types

  • Microsoft Office - Excel, PowerPoint, Word

  • Smartling Excel Template

  • Android XML

  • JSON

  • iOS Strings

  • Rich Text Format (RTF)

  • XML

  • XLIFF

Limitations

There is a limit of 1000 rules per account.

Variables

In cases where you want to create the one File Rewrite Rule to be applied to some or all languages, you can save time and effort by using the available variables:

  1. $locale: rewrites to each language's locale ID

  2. $language: rewrites to each language's language ID

  3. $country: rewrites to each language's country ID

All of Smartling's supported variable types above can be found in this article. A locale ID consists of a language ID and country ID.

Create a File Rewrite Rule

  • In your Smartling Account, go to Account Settings > File Rewrites

  • Click New Rule

  • Complete the fields in the Rewrite Rule dialog:

    • Choose a Project on the Account to apply the rule to

    • Choose the languages the rule should apply to

    • Choose the file types that should contain the rewrite rule once downloaded

    • Add a Rule Description

    • Enter what the rule should find and rewrite from

    • Enter what the rule should replace all with and rewrite to

    • Ensure the rule is enabled

  • Click Save

Modal to set up a Rewrite Rule

Rewrite rules are case-sensitive and must be unique. If you create multiple rules with the same Rewrite From, for the same projects, languages and files types, the first rule that was created takes precedence over the rest.

Rule ID

To save time and effort in identifying each Rewrite Rule with a unique ID, Smartling automatically creates a unique Rule ID for each File Rewrite Rule create. This way you can quickly identify a rule, and if needed, reference this ID both internal and external communication.

Search & Filters

You can locate any rule quickly and easily by using the following search and filters:

  • Project

  • Languages

  • File Type

  • Rewrite From

  • Rewrite To

  • Enabled / Disabled

It is possible to share your filter selection with another Account Owner user by sharing the URL.

Actions

Click the ellipses (3 dots) beside each File Rewrite Rule to complete any of the following actions, or you can also choose to carry out bulk actions by multi-selecting File Rewrite Rules and click the Actions button:

  • Edit - not available as a bulk action

  • Enable / Disable

  • Delete

  • Clone Rule - not available as a bulk action
    ​

Best Practices

Test Test Test

Always test any rule you create before implementing it with real content. Just as with any "Find & Replace All" action, Rewrite Rules are a powerful function that could potentially destroy your content if implemented without proper testing. Consider any possible corruption to the JSON or HTML in your content, including translatable HTML values in <tags>. As mentioned below, only translatable content can be rewritten, so keys shouldn’t be affected; however, testing is always recommended.

Mostly, Only Translatable Content Can Be Rewritten

For most file formats, only the translatable content from the file is rewritten - with the exception of URLs from docx, xlsx, pptx files.

It is not possible to rewrite file attributes, such as tags, as Smartling does not ingest native tags from files, such as with XLIFF files.

Special Considerations for HTML

The content rewrite process is designed to access text within HTML tags. Please be aware that if the same text appears inside HTML tags, it may also be picked up and modified by file rewrite rules. To avoid this, we recommend using matches that do not include any content that matches the text inside HTML tags, or changing the content inside the tags (such as words or class names) to be unique so they are not accidentally matched by a rewrite rule. Another alternative would be to add a term to your glossary instead of using file rewrite rules.

Did this answer your question?