summaryrefslogtreecommitdiffstats
path: root/docs/content/en/functions/i18n.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/functions/i18n.md')
-rw-r--r--docs/content/en/functions/i18n.md23
1 files changed, 22 insertions, 1 deletions
diff --git a/docs/content/en/functions/i18n.md b/docs/content/en/functions/i18n.md
index 7d88292b9..34a6ff022 100644
--- a/docs/content/en/functions/i18n.md
+++ b/docs/content/en/functions/i18n.md
@@ -18,7 +18,7 @@ deprecated: false
aliases: []
---
-This translates a piece of content based on your `i18n/en-US.yaml` (and similar) files. You can use the [go-i18n](https://github.com/nicksnyder/go-i18n) tools to manage your translations. The translations can exist in both the theme and at the root of your repository.
+This translates a piece of content based on your `i18n/en-US.toml` files. You can use the [go-i18n](https://github.com/nicksnyder/go-i18n) tools to manage your translations. The translations can exist in both the theme and at the root of your repository.
```
{{ i18n "translation_id" }}
@@ -28,6 +28,27 @@ This translates a piece of content based on your `i18n/en-US.yaml` (and similar)
`T` is an alias to `i18n`. E.g. `{{ T "translation_id" }}`.
{{% /note %}}
+### Query a flexible translation with variables
+
+Often you will want to use the page variables in the translation strings. To do so, pass the `.` context when calling `i18n`:
+
+```
+{{ i18n "wordCount" . }}
+```
+
+The function will pass the `.` context to the `"wordCount"` id:
+
+{{< code-toggle file="i18n/en-US" >}}
+[wordCount]
+other = "This article has {{ .WordCount }} words."
+{{< /code-toggle >}}
+
+Assume `.WordCount` in the context has value is 101. The result will be:
+
+```
+This article has 101 words.
+```
+
For more information about string translations, see [Translation of Strings in Multilingual Mode][multistrings].
[multistrings]: /content-management/multilingual/#translation-of-strings