IsTranslated
Syntax
PAGE.IsTranslated
Returns
bool
使用以下站点配置:
hugo.
defaultContentLanguage: en
languages:
de:
contentDir: content/de
languageCode: de-DE
languageName: Deutsch
weight: 2
en:
contentDir: content/en
languageCode: en-US
languageName: English
weight: 1
defaultContentLanguage = 'en'
[languages]
[languages.de]
contentDir = 'content/de'
languageCode = 'de-DE'
languageName = 'Deutsch'
weight = 2
[languages.en]
contentDir = 'content/en'
languageCode = 'en-US'
languageName = 'English'
weight = 1
{
"defaultContentLanguage": "en",
"languages": {
"de": {
"contentDir": "content/de",
"languageCode": "de-DE",
"languageName": "Deutsch",
"weight": 2
},
"en": {
"contentDir": "content/en",
"languageCode": "en-US",
"languageName": "English",
"weight": 1
}
}
}
以及以下内容:
content/
├── de/
│ ├── books/
│ │ └── book-1.md
│ └── _index.md
├── en/
│ ├── books/
│ │ ├── book-1.md
│ │ └── book-2.md
│ └── _index.md
└── _index.md
渲染 content/en/books/book-1.md 时:
{{ .IsTranslated }} → true
渲染 content/en/books/book-2.md 时:
{{ .IsTranslated }} → false