id_translation.offline.types#

Types used for offline translation.

Classes

PlaceholderTranslations(source, ...[, ...])

Matrix of ID translation components returned by fetchers.

class PlaceholderTranslations(source, placeholders, records, id_pos=-1, placeholder_aliases=<factory>)[source]#

Bases: Generic[SourceType]

Matrix of ID translation components returned by fetchers.

classmethod from_dataframe(source, data)[source]#

Create instance from a pandas DataFrame.

classmethod from_dict(source, data)[source]#

Create instance from a dict.

id_pos = -1#

Position if the ID placeholder in placeholders.

classmethod make(source, data)[source]#

Try to make in instance from arbitrary input data.

Parameters:
  • source – Source label for the translations.

  • data – Some data to convert to a PlaceholderTranslations instance.

Returns:

A new PlaceholderTranslations instance.

Raises:

TypeError – If data cannot be converted.

placeholder_aliases#

Alternative placeholder names.

placeholders#

Names of placeholders in the order in which they appear in records.

records#

Matrix of shape N x M where N is the number of IDs returned and M is the length of placeholders.

source#

Source from which translations were retrieved.

to_dict(max_rows=0)[source]#

Create a dict representation of the translations.

static to_dicts(source_translations, max_rows=0)[source]#

Create a nested dict representation of the translations.

to_pandas(max_rows=0)[source]#

Create a pandas DataFrame representation of the translations.