| 1 |
--- |
| 2 |
title: IsTranslated |
| 3 |
description: Reports whether the given page has one or more translations. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: bool |
| 9 |
signatures: [PAGE.IsTranslated] |
| 10 |
--- |
| 11 |
|
| 12 |
With this project configuration: |
| 13 |
|
| 14 |
{{< code-toggle file=hugo >}} |
| 15 |
defaultContentLanguage = 'en' |
| 16 |
|
| 17 |
[languages.en] |
| 18 |
contentDir = 'content/en' |
| 19 |
label = 'English' |
| 20 |
locale = 'en-US' |
| 21 |
weight = 1 |
| 22 |
|
| 23 |
[languages.de] |
| 24 |
contentDir = 'content/de' |
| 25 |
label = 'Deutsch' |
| 26 |
locale = 'de-DE' |
| 27 |
weight = 2 |
| 28 |
{{< /code-toggle >}} |
| 29 |
|
| 30 |
And this content: |
| 31 |
|
| 32 |
```tree |
| 33 |
content/ |
| 34 |
├── de/ |
| 35 |
│ ├── books/ |
| 36 |
│ │ └── book-1.md |
| 37 |
│ └── _index.md |
| 38 |
├── en/ |
| 39 |
│ ├── books/ |
| 40 |
│ │ ├── book-1.md |
| 41 |
│ │ └── book-2.md |
| 42 |
│ └── _index.md |
| 43 |
└── _index.md |
| 44 |
``` |
| 45 |
|
| 46 |
When rendering `content/en/books/book-1.md`: |
| 47 |
|
| 48 |
```go-html-template |
| 49 |
{{ .IsTranslated }} → true |
| 50 |
``` |
| 51 |
|
| 52 |
When rendering `content/en/books/book-2.md`: |
| 53 |
|
| 54 |
```go-html-template |
| 55 |
{{ .IsTranslated }} → false |
| 56 |
``` |