URI: 
       Fix i18n project vs theme order - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 00a238e32c82b0651e4145e306840cffa46e535d
   DIR parent e5f960245938d8d8b4e99f312e9907f8d3aebf7a
  HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
       Date:   Mon, 29 Jul 2019 17:23:10 +0200
       
       Fix i18n project vs theme order
       
       Fixes #6134
       
       Diffstat:
         M hugolib/hugo_modules_test.go        |      14 +++++++++-----
         M langs/i18n/translationProvider.go   |      12 +++++++-----
       
       2 files changed, 16 insertions(+), 10 deletions(-)
       ---
   DIR diff --git a/hugolib/hugo_modules_test.go b/hugolib/hugo_modules_test.go
       @@ -204,7 +204,7 @@ Data C: {{ $data.c.value }}
        Data D: {{ $data.d.value }}
        All Data: {{ $data }}
        
       -i18n hello: {{ i18n "hello" . }}
       +i18n hello1: {{ i18n "hello1" . }}
        i18n theme: {{ i18n "theme" . }}
        i18n theme2: {{ i18n "theme2" . }}
        `)
       @@ -238,9 +238,13 @@ other = %q
                b.WithSourceFile("themes/d/data/d.toml", `value="Hugo Rodks!"`)
        
                // i18n files
       -        b.WithSourceFile("i18n/en.toml", i18nContent("hello", "Project"))
       -        b.WithSourceFile("themes/c/en.toml", i18nContent("hello", "Theme C"))
       -        b.WithSourceFile("themes/c/i18n/en.toml", i18nContent("theme", "Theme C"))
       +        b.WithSourceFile("i18n/en.toml", i18nContent("hello1", "Project"))
       +        b.WithSourceFile("themes/c/i18n/en.toml", `
       +[hello1]
       +other="Theme C Hello"
       +[theme]
       +other="Theme C"
       +`)
                b.WithSourceFile("themes/d/i18n/en.toml", i18nContent("theme", "Theme D"))
                b.WithSourceFile("themes/d/i18n/en.toml", i18nContent("theme2", "Theme2 D"))
        
       @@ -261,7 +265,7 @@ other = %q
        
                // i18n
                b.AssertFileContent("public/index.html",
       -                "i18n hello: Project",
       +                "i18n hello1: Project",
                        "i18n theme: Theme C",
                        "i18n theme2: Theme2 D",
                )
   DIR diff --git a/langs/i18n/translationProvider.go b/langs/i18n/translationProvider.go
       @@ -50,7 +50,11 @@ func (tp *TranslationProvider) Update(d *deps.Deps) error {
                }
                var newLangs []string
        
       -        for _, dir := range d.BaseFs.I18n.Dirs {
       +        // The source dirs are ordered so the most important comes first. Since this is a
       +        // last key win situation, we have to reverse the iteration order.
       +        dirs := d.BaseFs.I18n.Dirs
       +        for i := len(dirs) - 1; i >= 0; i-- {
       +                dir := dirs[i]
                        src := spec.NewFilesystemFromFileMetaInfo(dir)
        
                        files, err := src.Files()
       @@ -71,10 +75,8 @@ func (tp *TranslationProvider) Update(d *deps.Deps) error {
                                language.RegisterPluralSpec(newLangs, en)
                        }
        
       -                // The source files are ordered so the most important comes first. Since this is a
       -                // last key win situation, we have to reverse the iteration order.
       -                for i := len(files) - 1; i >= 0; i-- {
       -                        if err := addTranslationFile(i18nBundle, files[i]); err != nil {
       +                for _, file := range files {
       +                        if err := addTranslationFile(i18nBundle, file); err != nil {
                                        return err
                                }
                        }