hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

lang.Merge.md (832B)

    1 ---
    2 title: lang.Merge
    3 description: "Merge missing translations from other languages."
    4 date: 2018-03-16
    5 categories: [functions]
    6 keywords: [multilingual]
    7 menu:
    8   docs:
    9     parent: "functions"
   10 toc: false
   11 signature: ["lang.Merge FROM TO"]
   12 workson: []
   13 hugoversion:
   14 relatedfuncs: []
   15 deprecated: false
   16 draft: false
   17 aliases: []
   18 comments:
   19 ---
   20 
   21 As an example:
   22 
   23 ```bash
   24 {{ $pages := .Site.RegularPages | lang.Merge $frSite.RegularPages | lang.Merge $enSite.RegularPages }}
   25 ```
   26 
   27 Will "fill in the gaps" in the current site with, from left to right, content from the French site, and lastly the English.
   28 
   29 
   30 A more practical example is to fill in the missing translations from the other languages:
   31 
   32 ```bash
   33 {{ $pages := .Site.RegularPages }}
   34 {{ range .Site.Home.Translations }}
   35 {{ $pages = $pages | lang.Merge .Site.RegularPages }}
   36 {{ end }}
   37  ```