Configuring DITA Specializations for Translation

How to make the translation agent aware of custom DITA specializations.

The agent treats any well-formed XML file as translatable content, so a topic written in a custom DITA specialization is included in translation without additional configuration. However, you still need to configure how it is validated and how it is translated.

Configuring Validation Rules

Validation determines which elements and attributes must remain unchanged and which can be translated. To extend or override the built-in rules for a specialization, add an optional .contentfusion/i18n/validation-rules.xml file to your workspace:

<validation-rules version="1">
  <global>
    <keep-unchanged><element>my-token</element><attribute>my-ref</attribute></keep-unchanged>
    <translate><element>mytitle</element><attribute>my-label</attribute></translate>
  </global>
  <match root="learningContent">
    <keep-unchanged><element>custom-skip</element></keep-unchanged>
    <translate><element>lcTitle</element></translate>
  </match>
</validation-rules>

The rules applied to a document come from three layers, listed here in order of increasing precedence:

  1. Built-in defaults - The rules the agent always starts from (described below). They apply even when no validation-rules.xml file exists.
  2. <global> rules - Your project-wide additions and overrides, applied to every document.
  3. <match root="…"> rules - Overrides for documents whose root element matches the specified name. This is how you target one specialization without affecting others. For matching documents, these rules take precedence over both <global> and the built-in defaults.

In most cases, you do not need to list every element and attribute, because each type has a sensible default behavior:

  • Elements are translatable by default. The text content of an element is translated unless a built-in rule or one of your own <keep-unchanged> entries explicitly protects it. Adding an element under <translate> is only useful when you need to override an existing protection.
  • Attributes default to protected. An attribute is left unchanged unless a built-in rule or your own <translate> entry explicitly allows it to be translated. This is why a custom specialization usually only needs <translate> entries for its own label-like attributes, and rarely needs <keep-unchanged> for attributes.

In short, for elements, list the exceptions that must not be translated. For attributes, list the exceptions that must be translated.

The built-in defaults already protect the usual non-translatable DITA content, such as code, identifiers, keys, and similar values. They also already allow translation of the standard text-bearing attributes, such as navtitle, alt, spectitle, reftitle, standby, and value. Add rules only for the elements or attributes specific to your specialization that are not already handled correctly by these defaults.

Describing a Specialization in agent-instructions.md

Validation rules only constrain the output; they do not teach the agent the semantics of your specialization. Create a short Markdown file that describes the specialization in plain language, for example learning-content-guide.md, and reference it from agent-instructions.md. When translating documents that use your specialization, the agent uses this guidance together with its general DITA knowledge.

Based on the structure of the built-in doctype guidance, include the following when you describe your own specialization:

  • Titles and labels vs. body content - Which elements are titles, headings, or UI labels (which should read tersely, like a heading) versus narrative prose, including any titles nested inside structural child elements.
  • Protected, technical-looking content - Elements or attributes that look like ordinary words but are actually identifiers, keys, or code and must remain exactly as written.
  • Context-dependent elements - Elements that are only translatable in some contexts and act as fixed tokens in others.
  • Which attributes may change - Call out the specific attributes on your specialization's elements that hold translatable text (labels, alt text, and similar), since attributes are protected by default.
  • Tricky examples - For any case that is easy to get wrong, include a short before/after example showing the source and its expected translation.