id_translation.Translator#

For an introduction to translation, see the Translation primer page.

The recommended way of initializing Translator instances is the from_config() method, unless your setup is very simple. For configuration file details, please refer to the Configuration page.

Constructor#

Translator([fetcher, fmt, mapper, ...])

End-user interface for all translation tasks.

Translator.from_config(path[, extra_fetchers])

Create a Translator from TOML inputs.

Related attributes

Daily drivers#

You’ll be using these a lot.

Translator.map(translatable[, names, ...])

Map names to translation sources.

Translator.translate(translatable[, names, ...])

Translate IDs to human-readable strings.

Translator.fetch([translatable, names, ...])

Fetch translations.

Related methods

Translator.initialize_sources([task_id, force])

Perform source discovery (fetcher initialization).

Translator.map_scores(translatable[, names, ...])

Returns raw match scores for name-to-source mapping.

Translator.translated_names([with_source])

Return the names that were translated by the most recent translate()-call.

Related attributes

Translator.mapper

Return the Mapper instance used for name-to-source binding.

Translator.online

Return connectivity status.

Translator.fetcher

Return the Fetcher instance used to retrieve translations.

Translator.sources

A list of known sources names.

Translator.placeholders

A dict {source: [placeholders, ...]}.

Working offline#

Translator.go_offline([translatable, names, ...])

Retrieve and store translations in memory.

Translator.restore(path)

Restore a serialized Translator.

Translator.load_persistent_instance(...[, ...])

Load or create a persistent fetch_all-instance.

Related attributes

Translator.cache

Return a TranslationMap of cached translations.

Configuration#

Most Translator attributes are read-only. To change the attributes below, use the copy method with attribute overrides.

Methods

Translator.copy(**overrides)

Make a copy of this Translator.

Attributes

Translator.fmt

Main translation Format for this Translator instance.

Translator.default_fmt

Alternative translation Format, used for unknown IDs.

Translator.enable_uuid_heuristics

Improves matching when UUID-like IDs are in use.

Translator.transformers

Get a dict {source: transformer} of Transformer instances used by this Translator.