---
title: "Glossary and style"
description: "See how glossary decisions and style rules reach the prompt and which QA checks enforce them."
canonical_url: "https://diglot.sh/machine-translation/glossary-and-style"
---
# Glossary and style

> See how glossary decisions and style rules reach the prompt and which QA checks enforce them.

The glossary and style files you write for a locale, described in the [guide](https://diglot.sh/guide/how-to/glossary-and-style), feed three places: the prompt, the typography step after translation and the QA checks. This page shows how each decision is used.

## Glossary decisions

`glossary` is a `Glossary` from `@diglot/core`: a list of terms, each with a decision. Load it with `loadGlossary` from [`@diglot/store`](https://diglot.sh/store/locale-files).

<table>
<thead>
  <tr>
    <th>
      Decision
    </th>
    
    <th>
      Prompt
    </th>
    
    <th>
      QA warning when
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        keep
      </code>
    </td>
    
    <td>
      Keep the term in English
    </td>
    
    <td>
      The term, or its plural, is missing from the output
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        translate
      </code>
      
       with <code>
        target
      </code>
    </td>
    
    <td>
      Translate as <code>
        target
      </code>
    </td>
    
    <td>
      Neither <code>
        target
      </code>
      
       nor any <code>
        accept
      </code>
      
       pattern is in the output
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        translate
      </code>
      
       without <code>
        target
      </code>
    </td>
    
    <td>
      Translate according to <code>
        note
      </code>
    </td>
    
    <td>
      Never
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        keep-gloss
      </code>
    </td>
    
    <td>
      Keep the term; on its first use in a page add <code>
        term (gloss)
      </code>
    </td>
    
    <td>
      The term is missing from the output
    </td>
  </tr>
</tbody>
</table>

A term matches source text as a whole word, ignoring case, or by the regular expression in `match`. `caseSensitive: true` makes either case-sensitive. A `note` is shown to the model next to the term.

Only the entries whose term occurs in a request are sent. A page title passed through `context` counts towards that match, so a glossary of hundreds of terms doesn't inflate every prompt.

## Sharing a glossary with x18n

[x18n](https://github.com/x18n-dev/x18n) keeps UI-string terminology in its `glossary` option. diglot reads the same shape, so one file can serve both tools. Entries map as follows:

<table>
<thead>
  <tr>
    <th>
      x18n
    </th>
    
    <th>
      diglot
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        doNotTranslate: true
      </code>
    </td>
    
    <td>
      <code>
        keep
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        translations[locale]
      </code>
      
       equal to the term
    </td>
    
    <td>
      <code>
        keep
      </code>
      
       for that locale
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        translations[locale]
      </code>
    </td>
    
    <td>
      <code>
        translate
      </code>
      
       with <code>
        target
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      no translation for the locale
    </td>
    
    <td>
      <code>
        translate
      </code>
      
       without <code>
        target
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        note
      </code>
    </td>
    
    <td>
      <code>
        note
      </code>
    </td>
  </tr>
</tbody>
</table>

Locale codes match exactly first, then with `_` and `-` treated alike and case ignored, so `pt_BR` serves `pt-BR`. A pointer to an `x18n.config.yml` also works, because its `glossary` key is read. Entries in `<locale>/glossary.yml` replace shared entries with the same term.

## Style

`style` is a `LocaleStyle`, as stored in `<locale>/style.yml`.

- `rules` and the `style` list of `glossary.yml` are added to the prompts as numbered rules.
- `typography` is applied to machine output after translation. A narrow no-break space (U+202F) goes before each `spaceBefore` character that ends a word, and after each `spaceAfter` character. In updates, it applies only to changed sentences.
- `lengthRatio` overrides the range that the `length-ratio` check accepts.

## The prompt

The system prompt tells the model that its output is a first draft that a human translator will review, and that it must never add content that isn't in the source. It explains the placeholder tokens and the markdown rules, then lists your style rules and the glossary lines that apply to the request. For updates, it lists them as guidance for new wording and tells the model not to change existing sentences to apply it.


## Sitemap

See the full [sitemap](https://diglot.sh/sitemap.md) for all pages.
