Takes as input either a string to translate either an actual string and
    transforms it into a JSON-serializable structure that can be reconstructed
    using `unserialize()`.

def serialize(text: TransText):
    """
    Takes as input either a string to translate either an actual string and
    transforms it into a JSON-serializable structure that can be reconstructed
    using `unserialize()`.
    """

    if isinstance(text, str):
        return {
            'type': 'string',
            'value': text,
        }
    elif isinstance(text, StringToTranslate):
        return {
            'type': 'trans',
            'key': text.key,
            'count': text.count,
            'params': text.params,
        }
    else:
        raise ValueError('Cannot accept type "{}"'
                         .format(text.__class__.__name__))