diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-07-28 10:30:58 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-09-06 18:32:16 +0300 |
commit | 708bc78770a0b0361908f6404f57264c53252a95 (patch) | |
tree | 9b7e3a05b1e83a768bfa0dd96b61b07dd7917cfd /source/file.go | |
parent | f023dfd7636f73b11c94e86a05c6273941d52c58 (diff) |
Optimize the multilanguage build process
Work In Progress!
This commit makes a rework of the build and rebuild process to better suit a multi-site setup.
This also includes a complete overhaul of the site tests. Previous these were a messy mix that
were testing just small parts of the build chain, some of it testing code-paths not even used in
"real life". Now all tests that depends on a built site follows the same and real production code path.
See #2309
Closes #2211
Closes #477
Closes #1744
Diffstat (limited to 'source/file.go')
-rw-r--r-- | source/file.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/source/file.go b/source/file.go index 9012b91c4..4bee882a6 100644 --- a/source/file.go +++ b/source/file.go @@ -108,10 +108,11 @@ func (f *File) Path() string { } // NewFileWithContents creates a new File pointer with the given relative path and -// content. +// content. The language defaults to "en". func NewFileWithContents(relpath string, content io.Reader) *File { file := NewFile(relpath) file.Contents = content + file.lang = "en" return file } @@ -124,15 +125,16 @@ func NewFile(relpath string) *File { f.dir, f.logicalName = filepath.Split(f.relpath) f.ext = strings.TrimPrefix(filepath.Ext(f.LogicalName()), ".") f.baseName = helpers.Filename(f.LogicalName()) - if viper.GetBool("Multilingual") { - f.lang = strings.TrimPrefix(filepath.Ext(f.baseName), ".") + + f.lang = strings.TrimPrefix(filepath.Ext(f.baseName), ".") + if f.lang == "" { + f.lang = viper.GetString("DefaultContentLanguage") if f.lang == "" { - f.lang = viper.GetString("DefaultContentLanguage") + // TODO(bep) ml + f.lang = "en" } - f.translationBaseName = helpers.Filename(f.baseName) - } else { - f.translationBaseName = f.baseName } + f.translationBaseName = helpers.Filename(f.baseName) f.section = helpers.GuessSection(f.Dir()) f.uniqueID = helpers.Md5String(f.LogicalName()) |