mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-22 21:42:50 +02:00
Merge commit 'b9bd35d72e14932fb6588ff62b90cddef0a060fc' as 'docs'
This commit is contained in:
43
docs/content/en/functions/lang.Merge.md
Normal file
43
docs/content/en/functions/lang.Merge.md
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: lang.Merge
|
||||
description: "Merge missing translations from other languages."
|
||||
godocref: ""
|
||||
workson: []
|
||||
date: 2018-03-16
|
||||
categories: [functions]
|
||||
keywords: [multilingual]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
toc: false
|
||||
signature: ["lang.Merge FROM TO"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: []
|
||||
deprecated: false
|
||||
draft: false
|
||||
aliases: []
|
||||
comments:
|
||||
---
|
||||
|
||||
As an example:
|
||||
|
||||
```bash
|
||||
{{ $pages := .Site.RegularPages | lang.Merge $frSite.RegularPages | lang.Merge $enSite.RegularPages }}
|
||||
```
|
||||
|
||||
Will "fill in the gaps" in the current site with, from left to right, content from the French site, and lastly the English.
|
||||
|
||||
|
||||
A more practical example is to fill in the missing translations from the other languages:
|
||||
|
||||
```bash
|
||||
{{ $pages := .Site.RegularPages }}
|
||||
{{ range .Site.Home.Translations }}
|
||||
{{ $pages = $pages | lang.Merge .Site.RegularPages }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
Note that the slightly ugly `.Scratch` construct will not be needed once this is fixed: https://github.com/golang/go/issues/10608
|
||||
{{% /note %}}
|
Reference in New Issue
Block a user