(43 lines)
1 '\" t2 .\" Copyright (c) 2026 Bruce Hill3 .\" All rights reserved.4 .\"5 .TH Text.translate 3 2026-03-08 "Tomo man-pages"6 .SH NAME7 Text.translate \- perform multiple replacements8 .SH LIBRARY9 Tomo Standard Library10 .SH SYNOPSIS11 .nf12 .BI Text.translate\ :\ func(text:\ Text,\ translations:\ {Text:Text}\ ->\ Text)13 .fi14 .SH DESCRIPTION15 Takes a table mapping target texts to their replacements and performs all the replacements in the table on the whole text. At each position, the first matching replacement is applied and the matching moves on to *after* the replacement text, so replacement text is not recursively modified. See Text.replace() for more information about replacement behavior.18 .SH ARGUMENTS20 .TS21 allbox;22 lb lb lbx23 l l l.24 Name Type Description25 text Text The text to be translated.26 translations {Text:Text} A table mapping from target text to its replacement.27 .TE28 .SH RETURN29 The text with all occurrences of the targets replaced with their corresponding replacement text.31 .SH EXAMPLES32 .EX33 text := "A <tag> & an ampersand".translate({34 "&": "&",35 "<": "<",36 ">": ">",37 '"': """,38 "'": "'",39 })40 assert text == "A <tag> & an ampersand"41 .EE42 .SH SEE ALSO43 .BR Tomo-Text (3)