Skip to main content

add_truncation_text

Appends or formats a truncation indicator to a given string, using a localized default or a provided template that supports optional string replacement.

def add_truncation_text(
text: string,
truncate: string = null
) - > string

Appends a truncation indicator to a string or formats it using a provided template to signal that content has been shortened.

Parameters

NameTypeDescription
textstringThe original text content that has been truncated.
truncatestring = nullA custom truncation string or template containing "%(truncated_text)s"; defaults to a localized ellipsis format.

Returns

TypeDescription
stringThe text with the truncation indicator applied, either via string interpolation or simple concatenation.