YAML – Ain’t that difficult to translate in Trados Studio anymore

Supertext has developed a third file type plugin for Trados Studio 2015 – 2017.

What can you do with it?

  • Translate YAML files (*.yaml, *.yml) directly in Trados Studio
  • Translate all texts
  • Use a path filter to:
    • Translate only specific texts
    • Translate bilingual YAML files
  • Process embedded content such as HTML tags

Download and installation

Download the plugin here and double click on the .sdlplugin file to start the plugin installer.

Troubles finding the installed plugin in Trados?

  1. Please verify whether our plugin has in fact been installed correctly and is active in the Studio version you’re using. For this, let’s run the Trados plugin management tool. You can find it either by clicking the start button in Windows and type “sdl plugin”. A window will open and you should see an entry for the YAML plugin (Supertext.Sdl.Trados.FileType.YamlFile)
  2. If you’re sure the plugin has been installed, fire up Trados. If the file type doesn’t appear in your file type list, click the blue link above the list (“Additional installed File Types exist”). Tick the box next to YAML-File, and hit OK.

YAML format

YAML stands for “Ain’t Markup Language” and is a human-readable data serialization standard. It is mostly used for configuration files, but can also be used as data-interchange format for the storage and exchange of any data. It is similar to the JSON format, but provides additional features that JSON lacks.

---
header:
  title: The YAML example
  descriptionText: This is some text.
content:
  title: The content example text
  elements:
  - title: The first element
    mainText: First element main text
    additionalText: First element additional text
  - title: The second element
    mainText: Second element main text
    additionalText: Second element additional text

More information about this format can be found on Wikipedia, on the official website, or on many other websites.

YAML path

A YAML document can be represented as a tree.  The example above:

A path describes how to get to a node of the tree. We are only interested in paths that lead to scalars (represented as leaves in the tree) with content that contains text.

Example path that leads to the scalar with content “The YAML example”: header.title

Example path that leads to the scalar with content “First element additional text”: content.elements[0].additionalText

Translate all YAML file texts

You’ll be able to use YAML files in your Trados projects once the plugin is installed. By default, the parser will extract all texts and no setting changes are required.

Use a path filter

The path filter setting can be found in the project settings under File Types -> YAML file -> Parsing settings. The filter rules are defined using regular expression. Each rule defines two expressions.

The source path expression is used to describe the pattern a path must match to be used as source, and therefore the scalar’s content as source text. If a path does not match any source path expressions, it is ignored. This way you can control what is used as translatable text.

The target path expression is used to describe the pattern of the path that should be used as target, and therefore the scalar’s content as target text. This expression needs to be the same as the source expression if the source text is to be replaced with the target text. However, if the YAML document is bilingual and therefore contains source as well as target text, it will be different from the source expression.

Translate only specific texts

You can either add filter rules yourself or extract all existing rules from a YAML file and then remove the rules matching the unwanted texts.

Example settings to get the header title and all “additionalText” properties of the above YAML document:

You could use “content\.elements\[0\]\.additionalText” instead of “content\.elements\[\d+\]\.additionalText” as the path expression to get only the first “additionalText”.

It is possible to use only “title” instead of “header\.title” and “content\.title” if both title properties should be translated, since the parser checks if the path contains the described pattern.

Translate bilingual YAML files

It is possible to specify a target path expression if the YAML document to translate is bilingual.

---
sourceLang: en
targetLang: de
texts:
- source: This is an example
  target: Das ist ein Beispiel
- source: This is a second example
  target: Das ist ein zweites Beispiel

In this case you need to mark the rule as bilingual and define the target path expression.

Select “Apply target text from YAML file” to extract any existing target text from the YAML file.

The extraction feature does not recognize source and target. The path expressions for source and target will be defined in separate rules; however, it is possible to join the rules:

  1. Hold down the Ctrl key on your keyboard
  2. Click on the first rule to select it
  3. Click on the second rule to select it
  4. Release the Ctrl key and click on the Join button

Process embedded content like HTML tags

The plugin supports embedded content replacement with tags. The default settings already contain common placeholders and tag pairs for HTML. This setting can be found under File Types -> YAML file -> Embedded Content.

FAQ

In the filetype preview you see the source text in both columns?
This is unfortunately normal. Just ignore this. Once you use the filetype for real, the source will only show up in the source column.

You need help?

Please write your question in the SDL Forum first:
https://community.sdl.com/developers-more/developers/language-developers/
Drop us a mail too with a link to the post, we don’t always monitor the group: development AT supertext DOT com.
Make sure you include the yaml and the sdlfiletype settings file.

We are giving this plugin away for free and we will try to help you nevertheless. But we do have other issues to work on sometimes.



Related posts


Ein Kommentar zu “YAML – Ain’t that difficult to translate in Trados Studio anymore”



  • François Chalumeau am 20. June 2017 10:47 Uhr

    Hello,

    I installed your plugin in my SDL Studio environment (2015 Freelance, SR3), but the YAML file type does not appear. Any reason?

    Looking forward to reading your reply
    Best regards


Leave a Reply

Your email address will not be published. Required fields are marked *