aboutsummaryrefslogtreecommitdiff
path: root/api/api.md
diff options
context:
space:
mode:
Diffstat (limited to 'api/api.md')
-rw-r--r--api/api.md17
1 files changed, 9 insertions, 8 deletions
diff --git a/api/api.md b/api/api.md
index f355163b..15526d43 100644
--- a/api/api.md
+++ b/api/api.md
@@ -189,7 +189,7 @@ sleep(1.5)
Bool.parse : func(text: Text -> Bool?)
```
-Converts a string representation of a boolean value into a boolean. Acceptable boolean values are case-insensitive variations of `yes`/`no`, `y`/`n`, `true`/`false`, `on`/`off`.
+Converts a text representation of a boolean value into a boolean. Acceptable boolean values are case-insensitive variations of `yes`/`no`, `y`/`n`, `true`/`false`, `on`/`off`.
Argument | Type | Description | Default
---------|------|-------------|---------
@@ -4664,13 +4664,14 @@ last | `Int` | The index of the last grapheme cluster to include (1-indexed). |
## Text.translate
```tomo
-Text.translate : func(translations: {Text=Text} -> Text)
+Text.translate : func(text: Text, translations: {Text=Text} -> Text)
```
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.
Argument | Type | Description | Default
---------|------|-------------|---------
+text | `Text` | The text to be translated. | -
translations | `{Text=Text}` | A table mapping from target text to its replacement. | -
**Return:** The text with all occurrences of the targets replaced with their corresponding replacement text.
@@ -4679,12 +4680,12 @@ translations | `{Text=Text}` | A table mapping from target text to its replaceme
**Example:**
```tomo
>> "A <tag> & an amperand".translate({
-"&" = "&amp;",
-"<" = "&lt;",
-">" = "&gt;",
-'"" = "&quot",
-"'" = "&#39;",
-}
+ "&" = "&amp;",
+ "<" = "&lt;",
+ ">" = "&gt;",
+ '"" = "&quot",
+ "'" = "&#39;",
+})
= "A &lt;tag&gt; &amp; an ampersand"
```