@register.filter
def truncate_chars_middle(value, max_length):
    max_length = int(max_length)
    value_length = len(value)
    if value_length > max_length:
        max_first = max_length/2
        div_rest = max_length%2
        truncd_val = value[:max_first-2+div_rest]
        truncd_val2 = value[-(max_first-1):]
        return truncd_val + "..." + truncd_val2
    return value
Truncate a string putting dots in the its middle after a certain number of
dataset/ETHPy150Open rvanlaar/easy-transifex/src/transifex/transifex/txcommon/templatetags/truncate.py/truncate_chars_middle