# Translation Memory

Pootle provides suggested translations to the current string. Translator can use these suggestions as their translation or to aid their translation.

Suggestions are based on previous translations of similar strings. These Translation Memory (TM) matches mean that you can speed up your translation and ensure consistency across your work.

## Using Translation Memory

Translation Memory suggestions are automatically retrieved when you enter a new translation unit. These are displayed below the editing widget. You can insert a TM suggestion by clicking on the suggestion row.

The differences between the current string and the suggested string are highlighted, this allows you to see how the two differ and helps you make changes to the suggestion to make it work as the current translation.

## Configuring Translation Memory

Translation Memory will work out of the box with a default Pootle installation. There are three methods of getting Translation Memory.

1. Amagama - for remote Translation Memory
2. Elasticsearch - for local Translation Memory
3. Elasticsearch - for external Translation Memory

### Amagama based remote TM

By default Pootle will query Translate’s Amagama Translation Memory server, which hosts translations of an extensive collection of Opensource software.

If you want to setup and connect to your own TM server then the `AMAGAMA_URL` will allow you to point to a private TM server.

### Elasticsearch-based TMs

New in version 2.7.

Pootle can also retrieve TM matches stored on Elasticsearch-based TM servers. These TM servers require Elasticsearch to be installed and running.

Note

Elasticsearch depends on Java. Note that some systems may ship with OpenJDK, however elasticsearch recommends using Oracle JDK.

Pootle supports two types of Elasticsearch-based TMs:

- Local TM: (just one, named `local`) is populated using translations stored in Pootle database and every new translation gets automatically imported to it.
- External TMs: (several) are populated from translation files specifically provided by the server admins, and are not automatically updated.

Both local and external TM settings can be adjusted in `POOTLE_TM_SERVER`. A configuration example for local and external TM can be found in the default `~/.pootle/pootle.conf`, and can be enabled by uncommenting the example.

Please see the `POOTLE_TM_SERVER-WEIGHT` for a full example of the configuration necessary to set up local/external TM.

You may want to disable Amagama by setting `AMAGAMA_URL` to `''` if you are using Elasticsearch-based TMs, though both can operate together.

#### Elasticsearch-based local TM

New in version 2.7.

To use it, the `local` TM must be enabled on `POOTLE_TM_SERVER` and will need to be populated using the `update_tmserver` command:

    (env) $ pootle update_tmserver

Once populated Pootle will keep Local TM up-to-date.

#### Elasticsearch-based external TMs

New in version 2.7.3.

In order to use them they must be enabled on `POOTLE_TM_SERVER` and you will need to populate them using the `update_tmserver` command specifying the TM to use with `--tm` and the display name with `--display-name`:

    (env) $ pootle update_tmserver --tm=external --display-name=Pidgin af.po gl.tmx

A display name is a label used to group translations within a TM. A given TM can host translations for several labels. Just specify them with `--display-name`:

    (env) $ pootle update_tmserver --tm=external --display-name=GNOME pt.tmx eu.po xh.po

It is possible to have several Elasticsearch-based external TM servers working at once, along with the Elasticsearch-based local TM server. In order to do so just add new entries to `POOTLE_TM_SERVER`:

    POOTLE_TM_SERVER = {

        ...

        'libreoffice': {
            'ENGINE': 'pootle.core.search.backends.ElasticSearchBackend',
            'HOST': 'localhost',
            'PORT': 9200,
            'INDEX_NAME': 'whatever',
            'WEIGHT': 0.9,
            'MIN_SCORE': 'AUTO',
        },
    }

Make sure `INDEX_NAME` is unique. You might also want to tweak `WEIGHT` to change the score of the TM results in relation to other TM servers (valid values are between `0.0` and `1.0`).

To use these additional external TMs you will need to populate them using the `update_tmserver` command specifying the TM server with `--tm`:

    (env) $ pootle update_tmserver --tm=libreoffice --display-name=LibreOffice af.po gl.tmx

Check `update_tmserver` for more options.

Note that Pootle will not push new translations to these TM servers unless you explicitly use the `update_tmserver` command, giving you full control of which translations make into them.