Translating YAML Files in Wordfast Pro

From Wordfast Wiki
Jump to: navigation, search

Wordfast Pro does not have a filter for translating YAML files but you can follow the steps below to create one.

YAML files are plain-text files with the .yml or .yaml extension and have the following structure: YAML file example.png

The structure is pretty simple: the variable name, a colon, a space, the translatable text that may be wrapped in double quotes or not.

In order to instruct Wordfast Pro how to segment YAML files, we need to create an extraction rules (*.properties) file. To do this, create a new empty file in your plain text editor. Paste the following in it:


Explanation: The first tag, called paragraphPrefix, tells Wordfast Pro how the translatable content begins – it begins after a colon. The paragraphSuffix tag tells Wordfast Pro that the translatable content ends at the end of the line, signalled by the $ special character. The (?m) part tells it that the content may be multi-line. We also add the paragraphFormat tag to indicate that the translatable content may include HTML tags. The internalTag tag tells Wordfast Pro that the translatable content may include non-translatable variables/placeholders like the %{email_link} one in the screenshot above. And the externalTag tag tells it to treat the double quotes at the start and end of translatable content as tags (they will be hidden).

Save the file as In your plain-text editor, click on File > Save As, then choose All Files (*.*) for File type and type the file name.

Now it's time to add the extraction rules file you've just created to Wordfast Pro. To do this:

  1. Click the Preferences button, then Filters (located under New Project Preferences).
  2. In the Filters pane, click the Add button.
  3. Choose the Text-based filter (*.xml) format.
  4. Give your filter a name – type YAML Filter in the Filter Name box.
  5. For Target Encoding, choose UTF-8.
  6. Click Browse next to Extraction Rules and point to the file.
  7. Leave xml in the Extension field.
  8. Click OK.
  9. Create a new project in Wordfast Pro.
  10. Because the YAML format is not natively supported, you will not be able to add YAML files by clicking the Add File button in the Project Creation window. This is why you will have to first rename your YAML file by adding the .xml extension to its name, e.g. rename contact.yml to contact.yml.xml. You will now be able to add your YAML file(s) to the project.
  11. Remember to change the target file name back to .yml by removing the .xml extension.

Note: If you want to add the YAML filter to an existing project, open the project first, then follows the steps above – but you will now see Current Project Preferences in step #2.